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 <string.h>
typedef long long ll;

ll n;
char str[100005];

ll win, lose;
ll g, p;

int main()
{
	scanf("%s", str);

	n = strlen(str);
	for (ll i = 0; i < n; i++) {
		if (g == p) {
			g++;

			if (str[i] == 'p') {
				lose++;
			}

		} else {
			p++;

			if (str[i] == 'g') {
				win++;
			}
		}
	}

	printf("%lld\n", win - lose);

	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:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	str(%rip), %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	movq	win(%rip), %rdx
	movq	%rax, n(%rip)
	testq	%rax, %rax
	je	.L3
	movq	win(%rip), %rdx
	movq	%rbx, %rcx
	addq	%rbx, %rax
	xorl	%r12d, %r12d
	movq	g(%rip), %r8
	xorl	%ebx, %ebx
	xorl	%r9d, %r9d
	xorl	%r11d, %r11d
	movq	p(%rip), %rsi
	movq	lose(%rip), %rbp
	movq	%rdx, %r10
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	addq	$1, %rsi
	movl	$1, %r9d
	cmpb	$103, %dil
	jne	.L5
	addq	$1, %r10
	movl	$1, %ebx
.L5:
	addq	$1, %rcx
	cmpq	%rcx, %rax
	je	.L28
.L6:
	movzbl	(%rcx), %edi
	cmpq	%rsi, %r8
	jne	.L4
	addq	$1, %r8
	movl	$1, %r11d
	cmpb	$112, %dil
	jne	.L5
	addq	$1, %rcx
	addq	$1, %rbp
	movl	$1, %r12d
	cmpq	%rcx, %rax
	jne	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	testb	%bl, %bl
	je	.L7
	movq	%r10, win(%rip)
	movq	%r10, %rdx
.L7:
	testb	%r12b, %r12b
	je	.L8
	movq	%rbp, lose(%rip)
.L8:
	testb	%r9b, %r9b
	je	.L9
	movq	%rsi, p(%rip)
.L9:
	testb	%r11b, %r11b
	je	.L3
	movq	%r8, g(%rip)
.L3:
	subq	lose(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.globl	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	g
	.align 8
	.type	g, @object
	.size	g, 8
g:
	.zero	8
	.globl	lose
	.align 8
	.type	lose, @object
	.size	lose, 8
lose:
	.zero	8
	.globl	win
	.align 8
	.type	win, @object
	.size	win, 8
win:
	.zero	8
	.globl	str
	.align 32
	.type	str, @object
	.size	str, 100005
str:
	.zero	100005
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.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:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	str(%rip), %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	movq	win(%rip), %rdx
	movq	%rax, n(%rip)
	testq	%rax, %rax
	je	.L3
	movq	win(%rip), %rdx
	movq	%rbx, %rcx
	addq	%rbx, %rax
	xorl	%r12d, %r12d
	movq	g(%rip), %r8
	xorl	%ebx, %ebx
	xorl	%r9d, %r9d
	xorl	%r11d, %r11d
	movq	p(%rip), %rsi
	movq	lose(%rip), %rbp
	movq	%rdx, %r10
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	addq	$1, %rsi
	movl	$1, %r9d
	cmpb	$103, %dil
	jne	.L5
	addq	$1, %r10
	movl	$1, %ebx
.L5:
	addq	$1, %rcx
	cmpq	%rcx, %rax
	je	.L28
.L6:
	movzbl	(%rcx), %edi
	cmpq	%rsi, %r8
	jne	.L4
	addq	$1, %r8
	movl	$1, %r11d
	cmpb	$112, %dil
	jne	.L5
	addq	$1, %rcx
	addq	$1, %rbp
	movl	$1, %r12d
	cmpq	%rcx, %rax
	jne	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	testb	%bl, %bl
	je	.L7
	movq	%r10, win(%rip)
	movq	%r10, %rdx
.L7:
	testb	%r12b, %r12b
	je	.L8
	movq	%rbp, lose(%rip)
.L8:
	testb	%r9b, %r9b
	je	.L9
	movq	%rsi, p(%rip)
.L9:
	testb	%r11b, %r11b
	je	.L3
	movq	%r8, g(%rip)
.L3:
	subq	lose(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.globl	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	g
	.align 8
	.type	g, @object
	.size	g, 8
g:
	.zero	8
	.globl	lose
	.align 8
	.type	lose, @object
	.size	lose, 8
lose:
	.zero	8
	.globl	win
	.align 8
	.type	win, @object
	.size	win, 8
win:
	.zero	8
	.globl	str
	.align 32
	.type	str, @object
	.size	str, 100005
str:
	.zero	100005
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.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:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	str(%rip), %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	movq	win(%rip), %rdx
	movq	%rax, n(%rip)
	testq	%rax, %rax
	je	.L3
	movq	win(%rip), %rdx
	movq	%rbx, %rcx
	addq	%rbx, %rax
	xorl	%r12d, %r12d
	movq	g(%rip), %r8
	xorl	%ebx, %ebx
	xorl	%r9d, %r9d
	xorl	%r11d, %r11d
	movq	p(%rip), %rsi
	movq	lose(%rip), %rbp
	movq	%rdx, %r10
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	addq	$1, %rsi
	movl	$1, %r9d
	cmpb	$103, %dil
	jne	.L5
	addq	$1, %r10
	movl	$1, %ebx
.L5:
	addq	$1, %rcx
	cmpq	%rcx, %rax
	je	.L28
.L6:
	movzbl	(%rcx), %edi
	cmpq	%rsi, %r8
	jne	.L4
	addq	$1, %r8
	movl	$1, %r11d
	cmpb	$112, %dil
	jne	.L5
	addq	$1, %rcx
	addq	$1, %rbp
	movl	$1, %r12d
	cmpq	%rcx, %rax
	jne	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	testb	%bl, %bl
	je	.L7
	movq	%r10, win(%rip)
	movq	%r10, %rdx
.L7:
	testb	%r12b, %r12b
	je	.L8
	movq	%rbp, lose(%rip)
.L8:
	testb	%r9b, %r9b
	je	.L9
	movq	%rsi, p(%rip)
.L9:
	testb	%r11b, %r11b
	je	.L3
	movq	%r8, g(%rip)
.L3:
	subq	lose(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.globl	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	g
	.align 8
	.type	g, @object
	.size	g, 8
g:
	.zero	8
	.globl	lose
	.align 8
	.type	lose, @object
	.size	lose, 8
lose:
	.zero	8
	.globl	win
	.align 8
	.type	win, @object
	.size	win, 8
win:
	.zero	8
	.globl	str
	.align 32
	.type	str, @object
	.size	str, 100005
str:
	.zero	100005
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.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 <string.h>
typedef long long ll;

ll n;
char str[100005];

ll win, lose;
ll g, p;

int main()
{
	scanf("%s", str);

	n = strlen(str);
	for (ll i = 0; i < n; i++) {
		if (g == p) {
			g++;

			if (str[i] == 'p') {
				lose++;
			}

		} else {
			p++;

			if (str[i] == 'g') {
				win++;
			}
		}
	}

	printf("%lld\n", win - lose);

	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 <string.h>
typedef long long ll;

ll n;
char str[100005];

ll win, lose;
ll g, p;

int main()
{
	scanf("%s", str);

	n = strlen(str);
	for (ll i = 0; i < n; i++) {
		if (g == p) {
			g++;

			if (str[i] == 'p') {
				lose++;
			}

		} else {
			p++;

			if (str[i] == 'g') {
				win++;
			}
		}
	}

	printf("%lld\n", win - lose);

	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:

gpg

0

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 <string.h>
typedef long long ll;

ll n;
char str[100005];

ll win, lose;
ll g, p;

int main()
{
	scanf("%s", str);

	n = strlen(str);
	for (ll i = 0; i < n; i++) {
		if (g == p) {
			g++;

			if (str[i] == 'p') {
				lose++;
			}

		} else {
			p++;

			if (str[i] == 'g') {
				win++;
			}
		}
	}

	printf("%lld\n", win - lose);

	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:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	str(%rip), %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	movq	win(%rip), %rdx
	movq	%rax, n(%rip)
	testq	%rax, %rax
	je	.L3
	movq	win(%rip), %rdx
	movq	%rbx, %rcx
	addq	%rbx, %rax
	xorl	%r12d, %r12d
	movq	g(%rip), %r8
	xorl	%ebx, %ebx
	xorl	%r9d, %r9d
	xorl	%r11d, %r11d
	movq	p(%rip), %rsi
	movq	lose(%rip), %rbp
	movq	%rdx, %r10
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	addq	$1, %rsi
	movl	$1, %r9d
	cmpb	$103, %dil
	jne	.L5
	addq	$1, %r10
	movl	$1, %ebx
.L5:
	addq	$1, %rcx
	cmpq	%rcx, %rax
	je	.L28
.L6:
	movzbl	(%rcx), %edi
	cmpq	%rsi, %r8
	jne	.L4
	addq	$1, %r8
	movl	$1, %r11d
	cmpb	$112, %dil
	jne	.L5
	addq	$1, %rcx
	addq	$1, %rbp
	movl	$1, %r12d
	cmpq	%rcx, %rax
	jne	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	testb	%bl, %bl
	je	.L7
	movq	%r10, win(%rip)
	movq	%r10, %rdx
.L7:
	testb	%r12b, %r12b
	je	.L8
	movq	%rbp, lose(%rip)
.L8:
	testb	%r9b, %r9b
	je	.L9
	movq	%rsi, p(%rip)
.L9:
	testb	%r11b, %r11b
	je	.L3
	movq	%r8, g(%rip)
.L3:
	subq	lose(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.globl	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	g
	.align 8
	.type	g, @object
	.size	g, 8
g:
	.zero	8
	.globl	lose
	.align 8
	.type	lose, @object
	.size	lose, 8
lose:
	.zero	8
	.globl	win
	.align 8
	.type	win, @object
	.size	win, 8
win:
	.zero	8
	.globl	str
	.align 32
	.type	str, @object
	.size	str, 100005
str:
	.zero	100005
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.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:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	str(%rip), %rbx
	movq	%rbx, %rsi
	call	__isoc99_scanf@PLT
	movq	%rbx, %rdi
	call	strlen@PLT
	movq	win(%rip), %rdx
	movq	%rax, n(%rip)
	testq	%rax, %rax
	je	.L3
	movq	win(%rip), %rdx
	movq	%rbx, %rcx
	addq	%rbx, %rax
	xorl	%r12d, %r12d
	movq	g(%rip), %r8
	xorl	%ebx, %ebx
	xorl	%r9d, %r9d
	xorl	%r11d, %r11d
	movq	p(%rip), %rsi
	movq	lose(%rip), %rbp
	movq	%rdx, %r10
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	addq	$1, %rsi
	movl	$1, %r9d
	cmpb	$103, %dil
	jne	.L5
	addq	$1, %r10
	movl	$1, %ebx
.L5:
	addq	$1, %rcx
	cmpq	%rcx, %rax
	je	.L28
.L6:
	movzbl	(%rcx), %edi
	cmpq	%rsi, %r8
	jne	.L4
	addq	$1, %r8
	movl	$1, %r11d
	cmpb	$112, %dil
	jne	.L5
	addq	$1, %rcx
	addq	$1, %rbp
	movl	$1, %r12d
	cmpq	%rcx, %rax
	jne	.L6
	.p2align 4,,10
	.p2align 3
.L28:
	testb	%bl, %bl
	je	.L7
	movq	%r10, win(%rip)
	movq	%r10, %rdx
.L7:
	testb	%r12b, %r12b
	je	.L8
	movq	%rbp, lose(%rip)
.L8:
	testb	%r9b, %r9b
	je	.L9
	movq	%rsi, p(%rip)
.L9:
	testb	%r11b, %r11b
	je	.L3
	movq	%r8, g(%rip)
.L3:
	subq	lose(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.globl	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	g
	.align 8
	.type	g, @object
	.size	g, 8
g:
	.zero	8
	.globl	lose
	.align 8
	.type	lose, @object
	.size	lose, 8
lose:
	.zero	8
	.globl	win
	.align 8
	.type	win, @object
	.size	win, 8
win:
	.zero	8
	.globl	str
	.align 32
	.type	str, @object
	.size	str, 100005
str:
	.zero	100005
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.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:
```