Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char S[500002];
	scanf("%s", S);
	
	int i = 0, j, up, down;
	long long sum = 0;
	while (S[i] != 0) {
		up = 0;
		down = 0;
		while (S[i] == '<') {
			up++;
			i++;
		}
		while (S[i] == '>') {
			down++;
			i++;
		}
		sum += (long long)up * (up - 1) / 2 + (long long)down * (down - 1) / 2 + ((up < down)? down: up);
	}
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	leaq	-499712(%rsp), %r11
	.cfi_def_cfa 11, 499720
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$312, %rsp
	.cfi_def_cfa_offset 500032
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 500008(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	xorl	%r10d, %r10d
	xorl	%edi, %edi
	leaq	-1(%rsp), %r8
	testb	%al, %al
	je	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	leal	1(%rdi), %edx
	xorl	%esi, %esi
	xorl	%r11d, %r11d
	movslq	%edx, %rdx
	cmpb	$60, %al
	jne	.L8
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edx, %edi
	addq	$1, %rdx
	movslq	%esi, %rcx
	addl	$1, %esi
	movzbl	(%r8,%rdx), %eax
	cmpb	$60, %al
	je	.L4
	movslq	%esi, %r11
	imulq	%rcx, %r11
	sarq	%r11
.L8:
	cmpb	$62, %al
	jne	.L11
	leal	1(%rdi), %edx
	xorl	%ecx, %ecx
	movslq	%edx, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%edx, %edi
	addq	$1, %rdx
	movslq	%ecx, %r9
	addl	$1, %ecx
	movzbl	(%r8,%rdx), %eax
	cmpb	$62, %al
	je	.L6
	movslq	%ecx, %rdx
	imulq	%r9, %rdx
	sarq	%rdx
	addq	%rdx, %r11
.L5:
	cmpl	%ecx, %esi
	cmovge	%esi, %ecx
	movslq	%ecx, %rcx
	addq	%r11, %rcx
	addq	%rcx, %r10
	testb	%al, %al
	jne	.L2
.L3:
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r10, %rdx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	500008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	xorl	%eax, %eax
	addq	$500024, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	xorl	%ecx, %ecx
	jmp	.L5
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	leaq	-499712(%rsp), %r11
	.cfi_def_cfa 11, 499720
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$312, %rsp
	.cfi_def_cfa_offset 500032
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 500008(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	xorl	%r10d, %r10d
	xorl	%edi, %edi
	leaq	-1(%rsp), %r8
	testb	%al, %al
	je	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	leal	1(%rdi), %edx
	xorl	%esi, %esi
	xorl	%r11d, %r11d
	movslq	%edx, %rdx
	cmpb	$60, %al
	jne	.L8
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edx, %edi
	addq	$1, %rdx
	movslq	%esi, %rcx
	addl	$1, %esi
	movzbl	(%r8,%rdx), %eax
	cmpb	$60, %al
	je	.L4
	movslq	%esi, %r11
	imulq	%rcx, %r11
	sarq	%r11
.L8:
	cmpb	$62, %al
	jne	.L11
	leal	1(%rdi), %edx
	xorl	%ecx, %ecx
	movslq	%edx, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%edx, %edi
	addq	$1, %rdx
	movslq	%ecx, %r9
	addl	$1, %ecx
	movzbl	(%r8,%rdx), %eax
	cmpb	$62, %al
	je	.L6
	movslq	%ecx, %rdx
	imulq	%r9, %rdx
	sarq	%rdx
	addq	%rdx, %r11
.L5:
	cmpl	%ecx, %esi
	cmovge	%esi, %ecx
	movslq	%ecx, %rcx
	addq	%r11, %rcx
	addq	%rcx, %r10
	testb	%al, %al
	jne	.L2
.L3:
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r10, %rdx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	500008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	xorl	%eax, %eax
	addq	$500024, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	xorl	%ecx, %ecx
	jmp	.L5
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```
rule
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	leaq	-499712(%rsp), %r11
	.cfi_def_cfa 11, 499720
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$312, %rsp
	.cfi_def_cfa_offset 500032
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 500008(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	xorl	%r10d, %r10d
	xorl	%edi, %edi
	leaq	-1(%rsp), %r8
	testb	%al, %al
	je	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	leal	1(%rdi), %edx
	xorl	%esi, %esi
	xorl	%r11d, %r11d
	movslq	%edx, %rdx
	cmpb	$60, %al
	jne	.L8
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edx, %edi
	addq	$1, %rdx
	movslq	%esi, %rcx
	addl	$1, %esi
	movzbl	(%r8,%rdx), %eax
	cmpb	$60, %al
	je	.L4
	movslq	%esi, %r11
	imulq	%rcx, %r11
	sarq	%r11
.L8:
	cmpb	$62, %al
	jne	.L11
	leal	1(%rdi), %edx
	xorl	%ecx, %ecx
	movslq	%edx, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%edx, %edi
	addq	$1, %rdx
	movslq	%ecx, %r9
	addl	$1, %ecx
	movzbl	(%r8,%rdx), %eax
	cmpb	$62, %al
	je	.L6
	movslq	%ecx, %rdx
	imulq	%r9, %rdx
	sarq	%rdx
	addq	%rdx, %r11
.L5:
	cmpl	%ecx, %esi
	cmovge	%esi, %ecx
	movslq	%ecx, %rcx
	addq	%r11, %rcx
	addq	%rcx, %r10
	testb	%al, %al
	jne	.L2
.L3:
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r10, %rdx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	500008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	xorl	%eax, %eax
	addq	$500024, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	xorl	%ecx, %ecx
	jmp	.L5
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```
```c
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char S[500002];
	scanf("%s", S);
	
	int i = 0, j, up, down;
	long long sum = 0;
	while (S[i] != 0) {
		up = 0;
		down = 0;
		while (S[i] == '<') {
			up++;
			i++;
		}
		while (S[i] == '>') {
			down++;
			i++;
		}
		sum += (long long)up * (up - 1) / 2 + (long long)down * (down - 1) / 2 + ((up < down)? down: up);
	}
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char S[500002];
	scanf("%s", S);
	
	int i = 0, j, up, down;
	long long sum = 0;
	while (S[i] != 0) {
		up = 0;
		down = 0;
		while (S[i] == '<') {
			up++;
			i++;
		}
		while (S[i] == '>') {
			down++;
			i++;
		}
		sum += (long long)up * (up - 1) / 2 + (long long)down * (down - 1) / 2 + ((up < down)? down: up);
	}
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
Optimized Assembly Code:

>><
 <>>><<<<<><<>>><
 ><>
 <>>>><<<<><<<>><
 <>><<<><<<<>>>><
 <<>><<><<<<>>>><
 <>>>><<<<><<>><<
 <>>>>><<<><<<><<
 <>>><>><<><<<><<
 <<><<<><<>><>>><

4
 29
 2
 28
 26
 24
 27
 30
 21
 20

Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>

int main()
{
	char S[500002];
	scanf("%s", S);
	
	int i = 0, j, up, down;
	long long sum = 0;
	while (S[i] != 0) {
		up = 0;
		down = 0;
		while (S[i] == '<') {
			up++;
			i++;
		}
		while (S[i] == '>') {
			down++;
			i++;
		}
		sum += (long long)up * (up - 1) / 2 + (long long)down * (down - 1) / 2 + ((up < down)? down: up);
	}
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	leaq	-499712(%rsp), %r11
	.cfi_def_cfa 11, 499720
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$312, %rsp
	.cfi_def_cfa_offset 500032
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 500008(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	xorl	%r10d, %r10d
	xorl	%edi, %edi
	leaq	-1(%rsp), %r8
	testb	%al, %al
	je	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	leal	1(%rdi), %edx
	xorl	%esi, %esi
	xorl	%r11d, %r11d
	movslq	%edx, %rdx
	cmpb	$60, %al
	jne	.L8
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edx, %edi
	addq	$1, %rdx
	movslq	%esi, %rcx
	addl	$1, %esi
	movzbl	(%r8,%rdx), %eax
	cmpb	$60, %al
	je	.L4
	movslq	%esi, %r11
	imulq	%rcx, %r11
	sarq	%r11
.L8:
	cmpb	$62, %al
	jne	.L11
	leal	1(%rdi), %edx
	xorl	%ecx, %ecx
	movslq	%edx, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%edx, %edi
	addq	$1, %rdx
	movslq	%ecx, %r9
	addl	$1, %ecx
	movzbl	(%r8,%rdx), %eax
	cmpb	$62, %al
	je	.L6
	movslq	%ecx, %rdx
	imulq	%r9, %rdx
	sarq	%rdx
	addq	%rdx, %r11
.L5:
	cmpl	%ecx, %esi
	cmovge	%esi, %ecx
	movslq	%ecx, %rcx
	addq	%r11, %rcx
	addq	%rcx, %r10
	testb	%al, %al
	jne	.L2
.L3:
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r10, %rdx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	500008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	xorl	%eax, %eax
	addq	$500024, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	xorl	%ecx, %ecx
	jmp	.L5
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	leaq	-499712(%rsp), %r11
	.cfi_def_cfa 11, 499720
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$312, %rsp
	.cfi_def_cfa_offset 500032
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 500008(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movzbl	(%rsp), %eax
	xorl	%r10d, %r10d
	xorl	%edi, %edi
	leaq	-1(%rsp), %r8
	testb	%al, %al
	je	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	leal	1(%rdi), %edx
	xorl	%esi, %esi
	xorl	%r11d, %r11d
	movslq	%edx, %rdx
	cmpb	$60, %al
	jne	.L8
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edx, %edi
	addq	$1, %rdx
	movslq	%esi, %rcx
	addl	$1, %esi
	movzbl	(%r8,%rdx), %eax
	cmpb	$60, %al
	je	.L4
	movslq	%esi, %r11
	imulq	%rcx, %r11
	sarq	%r11
.L8:
	cmpb	$62, %al
	jne	.L11
	leal	1(%rdi), %edx
	xorl	%ecx, %ecx
	movslq	%edx, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movl	%edx, %edi
	addq	$1, %rdx
	movslq	%ecx, %r9
	addl	$1, %ecx
	movzbl	(%r8,%rdx), %eax
	cmpb	$62, %al
	je	.L6
	movslq	%ecx, %rdx
	imulq	%r9, %rdx
	sarq	%rdx
	addq	%rdx, %r11
.L5:
	cmpl	%ecx, %esi
	cmovge	%esi, %ecx
	movslq	%ecx, %rcx
	addq	%r11, %rcx
	addq	%rcx, %r10
	testb	%al, %al
	jne	.L2
.L3:
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r10, %rdx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	500008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L23
	xorl	%eax, %eax
	addq	$500024, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	xorl	%ecx, %ecx
	jmp	.L5
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```