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

```c
#include <stdio.h>
#define ll int
ll exgcd(ll p,ll q,ll*x,ll*y){
	ll tx,ty,t,x2=0,y2=1;
	*x=1;*y=0;
	while(q){
		tx=*x-p/q*x2;*x=x2;x2=tx;
		ty=*y-p/q*y2;*y=y2;y2=ty;
		t=p%q;p=q;q=t;
	}
	return p;
}

int main(){
	int p,q;
	scanf("%d%d",&p,&q);
	ll a,b;
	exgcd(p,q,&a,&b);	
	printf("%d %d\n",a,b);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	exgcd
	.type	exgcd, @function
exgcd:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movq	%rdx, -48(%rbp)
	movq	%rcx, -56(%rbp)
	movl	$0, -20(%rbp)
	movl	$1, -16(%rbp)
	movq	-48(%rbp), %rax
	movl	$1, (%rax)
	movq	-56(%rbp), %rax
	movl	$0, (%rax)
	jmp	.L2
.L3:
	movq	-48(%rbp), %rax
	movl	(%rax), %ecx
	movl	-36(%rbp), %eax
	cltd
	idivl	-40(%rbp)
	imull	-20(%rbp), %eax
	movl	%eax, %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movq	-48(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, (%rax)
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
	movq	-56(%rbp), %rax
	movl	(%rax), %ecx
	movl	-36(%rbp), %eax
	cltd
	idivl	-40(%rbp)
	imull	-16(%rbp), %eax
	movl	%eax, %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -8(%rbp)
	movq	-56(%rbp), %rax
	movl	-16(%rbp), %edx
	movl	%edx, (%rax)
	movl	-8(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-36(%rbp), %eax
	cltd
	idivl	-40(%rbp)
	movl	%edx, -4(%rbp)
	movl	-40(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -40(%rbp)
.L2:
	cmpl	$0, -40(%rbp)
	jne	.L3
	movl	-36(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	exgcd, .-exgcd
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %esi
	movl	-24(%rbp), %eax
	leaq	-12(%rbp), %rcx
	leaq	-16(%rbp), %rdx
	movl	%eax, %edi
	call	exgcd
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	exgcd
	.type	exgcd, @function
exgcd:
.LFB23:
	.cfi_startproc
	endbr64
	movl	$1, (%rdx)
	movl	%edi, %eax
	movq	%rdx, %r10
	movl	$0, (%rcx)
	testl	%esi, %esi
	je	.L2
	movl	$1, %r8d
	xorl	%edi, %edi
	.p2align 4,,10
	.p2align 3
.L3:
	cltd
	movl	%edi, %r9d
	idivl	%esi
	movl	%eax, %r11d
	imull	%r8d, %eax
	imull	%edi, %r11d
	movl	(%r10), %edi
	movl	%r9d, (%r10)
	movl	%r8d, %r9d
	movl	(%rcx), %r8d
	movl	%r9d, (%rcx)
	subl	%eax, %r8d
	subl	%r11d, %edi
	movl	%esi, %eax
	movl	%edx, %esi
	testl	%edx, %edx
	jne	.L3
.L2:
	ret
	.cfi_endproc
.LFE23:
	.size	exgcd, .-exgcd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d %d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdx
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ecx
	movl	(%rsp), %eax
	testl	%ecx, %ecx
	je	.L13
	xorl	%edi, %edi
	movl	$1, %esi
	movl	$1, %r9d
	xorl	%r8d, %r8d
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%r10d, %r9d
	movl	%r11d, %r8d
.L11:
	cltd
	idivl	%ecx
	movl	%eax, %r10d
	imull	%r9d, %eax
	imull	%r8d, %r10d
	subl	%eax, %edi
	movl	%ecx, %eax
	movl	%edx, %ecx
	subl	%r10d, %esi
	movl	%edi, %r10d
	movl	%r9d, %edi
	movl	%esi, %r11d
	movl	%r8d, %esi
	testl	%edx, %edx
	jne	.L14
.L10:
	xorl	%eax, %eax
	movl	%r9d, %ecx
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L13:
	.cfi_restore_state
	xorl	%r9d, %r9d
	movl	$1, %r8d
	jmp	.L10
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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
	.file	"temp.c"
	.text
	.p2align 4
	.globl	exgcd
	.type	exgcd, @function
exgcd:
.LFB23:
	.cfi_startproc
	endbr64
	movl	$1, (%rdx)
	movl	%edi, %eax
	movq	%rdx, %r10
	movl	$0, (%rcx)
	testl	%esi, %esi
	je	.L2
	movl	$1, %r8d
	xorl	%edi, %edi
	.p2align 4,,10
	.p2align 3
.L3:
	cltd
	movl	%edi, %r9d
	idivl	%esi
	movl	%eax, %r11d
	imull	%r8d, %eax
	imull	%edi, %r11d
	movl	(%r10), %edi
	movl	%r9d, (%r10)
	movl	%r8d, %r9d
	movl	(%rcx), %r8d
	movl	%r9d, (%rcx)
	subl	%eax, %r8d
	subl	%r11d, %edi
	movl	%esi, %eax
	movl	%edx, %esi
	testl	%edx, %edx
	jne	.L3
.L2:
	ret
	.cfi_endproc
.LFE23:
	.size	exgcd, .-exgcd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d %d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdx
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ecx
	movl	(%rsp), %eax
	testl	%ecx, %ecx
	je	.L13
	xorl	%edi, %edi
	movl	$1, %esi
	movl	$1, %r9d
	xorl	%r8d, %r8d
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L14:
	movl	%r10d, %r9d
	movl	%r11d, %r8d
.L11:
	cltd
	idivl	%ecx
	movl	%eax, %r10d
	imull	%r9d, %eax
	imull	%r8d, %r10d
	subl	%eax, %edi
	movl	%ecx, %eax
	movl	%edx, %ecx
	subl	%r10d, %esi
	movl	%edi, %r10d
	movl	%r9d, %edi
	movl	%esi, %r11d
	movl	%r8d, %esi
	testl	%edx, %edx
	jne	.L14
.L10:
	xorl	%eax, %eax
	movl	%r9d, %ecx
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L13:
	.cfi_restore_state
	xorl	%r9d, %r9d
	movl	$1, %r8d
	jmp	.L10
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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:

#include <stdio.h>
#define ll int
ll exgcd(ll p,ll q,ll*x,ll*y){
	ll tx,ty,t,x2=0,y2=1;
	*x=1;*y=0;
	while(q){
		tx=*x-p/q*x2;*x=x2;x2=tx;
		ty=*y-p/q*y2;*y=y2;y2=ty;
		t=p%q;p=q;q=t;
	}
	return p;
}

int main(){
	int p,q;
	scanf("%d%d",&p,&q);
	ll a,b;
	exgcd(p,q,&a,&b);	
	printf("%d %d\n",a,b);
}

5 8
 5 15
 5 1
 5 2
 15 2
 55 2
 61 2
 47 2
 11 2
 6 8

-3 2
 1 0
 0 1
 1 -2
 1 -7
 1 -27
 1 -30
 1 -23
 1 -5
 -1 1

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

```c
#include <stdio.h>
#define ll int
ll exgcd(ll p,ll q,ll*x,ll*y){
	ll tx,ty,t,x2=0,y2=1;
	*x=1;*y=0;
	while(q){
		tx=*x-p/q*x2;*x=x2;x2=tx;
		ty=*y-p/q*y2;*y=y2;y2=ty;
		t=p%q;p=q;q=t;
	}
	return p;
}

int main(){
	int p,q;
	scanf("%d%d",&p,&q);
	ll a,b;
	exgcd(p,q,&a,&b);	
	printf("%d %d\n",a,b);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	exgcd
	.type	exgcd, @function
exgcd:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movq	%rdx, -48(%rbp)
	movq	%rcx, -56(%rbp)
	movl	$0, -20(%rbp)
	movl	$1, -16(%rbp)
	movq	-48(%rbp), %rax
	movl	$1, (%rax)
	movq	-56(%rbp), %rax
	movl	$0, (%rax)
	jmp	.L2
.L3:
	movq	-48(%rbp), %rax
	movl	(%rax), %ecx
	movl	-36(%rbp), %eax
	cltd
	idivl	-40(%rbp)
	imull	-20(%rbp), %eax
	movl	%eax, %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movq	-48(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, (%rax)
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
	movq	-56(%rbp), %rax
	movl	(%rax), %ecx
	movl	-36(%rbp), %eax
	cltd
	idivl	-40(%rbp)
	imull	-16(%rbp), %eax
	movl	%eax, %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -8(%rbp)
	movq	-56(%rbp), %rax
	movl	-16(%rbp), %edx
	movl	%edx, (%rax)
	movl	-8(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-36(%rbp), %eax
	cltd
	idivl	-40(%rbp)
	movl	%edx, -4(%rbp)
	movl	-40(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -40(%rbp)
.L2:
	cmpl	$0, -40(%rbp)
	jne	.L3
	movl	-36(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	exgcd, .-exgcd
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %esi
	movl	-24(%rbp), %eax
	leaq	-12(%rbp), %rcx
	leaq	-16(%rbp), %rdx
	movl	%eax, %edi
	call	exgcd
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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.
train
	.file	"temp.c"
	.text
	.globl	exgcd
	.type	exgcd, @function
exgcd:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movq	%rdx, -48(%rbp)
	movq	%rcx, -56(%rbp)
	movl	$0, -20(%rbp)
	movl	$1, -16(%rbp)
	movq	-48(%rbp), %rax
	movl	$1, (%rax)
	movq	-56(%rbp), %rax
	movl	$0, (%rax)
	jmp	.L2
.L3:
	movq	-48(%rbp), %rax
	movl	(%rax), %ecx
	movl	-36(%rbp), %eax
	cltd
	idivl	-40(%rbp)
	imull	-20(%rbp), %eax
	movl	%eax, %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movq	-48(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, (%rax)
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
	movq	-56(%rbp), %rax
	movl	(%rax), %ecx
	movl	-36(%rbp), %eax
	cltd
	idivl	-40(%rbp)
	imull	-16(%rbp), %eax
	movl	%eax, %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -8(%rbp)
	movq	-56(%rbp), %rax
	movl	-16(%rbp), %edx
	movl	%edx, (%rax)
	movl	-8(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-36(%rbp), %eax
	cltd
	idivl	-40(%rbp)
	movl	%edx, -4(%rbp)
	movl	-40(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -40(%rbp)
.L2:
	cmpl	$0, -40(%rbp)
	jne	.L3
	movl	-36(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	exgcd, .-exgcd
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-20(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %esi
	movl	-24(%rbp), %eax
	leaq	-12(%rbp), %rcx
	leaq	-16(%rbp), %rdx
	movl	%eax, %edi
	call	exgcd
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
