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>

int gcd(int a, int b) {
	int tmp;
	if (b > a) {
		tmp = a;
		a = b;
		b = tmp;
	}

	while (b) {
		tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}

void ex_gcd(int a, int b, int* g, int* x, int* y) {
	int r0, r1, r2, x0, x1, x2, y0, y1, y2, q;
	r0 = a; r1 = b;
	x0 = 1; x1 = 0;
	y0 = 0; y1 = 1;
	while (r1 > 0) {
//		printf("x0 = %d, y0 = %d\n", x0, y0);
		r2 = r0 % r1;
		q = r0 / r1;
		x2 = x0 - q * x1;
		y2 = y0 - q * y1;
		r0 = r1; r1 = r2;
		x0 = x1; x1 = x2;
		y0 = y1; y1 = y2;
	}
	*g = r0;
	*x = x0;
	*y = y0;
	return;
}

int main(void) {
	int a, b, g;
	int x = 0, y = 0;
	scanf("%d %d", &a, &b);
	
//	g = gcd(a, b);
	ex_gcd(a, b, &g, &x, &y);
	printf("%d %d\n", x, y);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	gcd
	.type	gcd, @function
gcd:
.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, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L3
	movl	-20(%rbp), %eax
	movl	%eax, -4(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
	jmp	.L3
.L4:
	movl	-20(%rbp), %eax
	cltd
	idivl	-24(%rbp)
	movl	%edx, -4(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
.L3:
	cmpl	$0, -24(%rbp)
	jne	.L4
	movl	-20(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	gcd, .-gcd
	.globl	ex_gcd
	.type	ex_gcd, @function
ex_gcd:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -52(%rbp)
	movl	%esi, -56(%rbp)
	movq	%rdx, -64(%rbp)
	movq	%rcx, -72(%rbp)
	movq	%r8, -80(%rbp)
	movl	-52(%rbp), %eax
	movl	%eax, -40(%rbp)
	movl	-56(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	$1, -32(%rbp)
	movl	$0, -28(%rbp)
	movl	$0, -24(%rbp)
	movl	$1, -20(%rbp)
	jmp	.L7
.L8:
	movl	-40(%rbp), %eax
	cltd
	idivl	-36(%rbp)
	movl	%edx, -16(%rbp)
	movl	-40(%rbp), %eax
	cltd
	idivl	-36(%rbp)
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	imull	-28(%rbp), %eax
	movl	%eax, %edx
	movl	-32(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	imull	-20(%rbp), %eax
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-36(%rbp), %eax
	movl	%eax, -40(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -32(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, -28(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -20(%rbp)
.L7:
	cmpl	$0, -36(%rbp)
	jg	.L8
	movq	-64(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, (%rax)
	movq	-72(%rbp), %rax
	movl	-32(%rbp), %edx
	movl	%edx, (%rax)
	movq	-80(%rbp), %rax
	movl	-24(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	ex_gcd, .-ex_gcd
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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
	movl	$0, -16(%rbp)
	movl	$0, -12(%rbp)
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %esi
	movl	-28(%rbp), %eax
	leaq	-12(%rbp), %rdi
	leaq	-16(%rbp), %rcx
	leaq	-20(%rbp), %rdx
	movq	%rdi, %r8
	movl	%eax, %edi
	call	ex_gcd
	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	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	gcd
	.type	gcd, @function
gcd:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	movl	%esi, %edx
	cmpl	%edi, %esi
	jle	.L2
	movl	%esi, %eax
	movl	%edi, %edx
.L2:
	testl	%edx, %edx
	je	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edx, %r8d
	cltd
	idivl	%r8d
	movl	%r8d, %eax
	testl	%edx, %edx
	jne	.L4
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%eax, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.p2align 4
	.globl	ex_gcd
	.type	ex_gcd, @function
ex_gcd:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edi, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rcx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdx, %rbx
	testl	%esi, %esi
	jle	.L11
	movl	$1, %edi
	xorl	%r11d, %r11d
	xorl	%r9d, %r9d
	movl	$1, %r10d
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L12:
	movl	%edx, %edi
	movl	%r12d, %r9d
.L10:
	cltd
	idivl	%esi
	movl	%eax, %ecx
	movl	%esi, %eax
	movl	%edx, %esi
	movl	%ecx, %edx
	imull	%edi, %ecx
	imull	%r9d, %edx
	subl	%edx, %r10d
	movl	%r11d, %edx
	movl	%edi, %r11d
	movl	%r10d, %r12d
	subl	%ecx, %edx
	movl	%r9d, %r10d
	testl	%esi, %esi
	jg	.L12
	movl	%eax, (%rbx)
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	%r9d, 0(%rbp)
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	%edi, (%r8)
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	xorl	%edi, %edi
	movl	$1, %r9d
	movl	%eax, (%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 24
	movl	%r9d, 0(%rbp)
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	%edi, (%r8)
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE24:
	.size	ex_gcd, .-ex_gcd
	.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:
.LFB25:
	.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
	jle	.L18
	xorl	%r10d, %r10d
	movl	$1, %r9d
	movl	$1, %edi
	xorl	%r8d, %r8d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L19:
	movl	%edx, %r9d
	movl	%r11d, %r8d
.L16:
	cltd
	idivl	%ecx
	movl	%eax, %esi
	movl	%ecx, %eax
	movl	%edx, %ecx
	movl	%esi, %edx
	imull	%r9d, %esi
	imull	%r8d, %edx
	subl	%edx, %edi
	movl	%r10d, %edx
	movl	%r9d, %r10d
	movl	%edi, %r11d
	subl	%esi, %edx
	movl	%r8d, %edi
	testl	%ecx, %ecx
	jg	.L19
.L15:
	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	.L21
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L18:
	.cfi_restore_state
	xorl	%r9d, %r9d
	movl	$1, %r8d
	jmp	.L15
.L21:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.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	gcd
	.type	gcd, @function
gcd:
.LFB23:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	movl	%esi, %edx
	cmpl	%edi, %esi
	jle	.L2
	movl	%esi, %eax
	movl	%edi, %edx
.L2:
	testl	%edx, %edx
	je	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%edx, %r8d
	cltd
	idivl	%r8d
	movl	%r8d, %eax
	testl	%edx, %edx
	jne	.L4
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%eax, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.p2align 4
	.globl	ex_gcd
	.type	ex_gcd, @function
ex_gcd:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edi, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rcx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdx, %rbx
	testl	%esi, %esi
	jle	.L11
	movl	$1, %edi
	xorl	%r11d, %r11d
	xorl	%r9d, %r9d
	movl	$1, %r10d
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L12:
	movl	%edx, %edi
	movl	%r12d, %r9d
.L10:
	cltd
	idivl	%esi
	movl	%eax, %ecx
	movl	%esi, %eax
	movl	%edx, %esi
	movl	%ecx, %edx
	imull	%edi, %ecx
	imull	%r9d, %edx
	subl	%edx, %r10d
	movl	%r11d, %edx
	movl	%edi, %r11d
	movl	%r10d, %r12d
	subl	%ecx, %edx
	movl	%r9d, %r10d
	testl	%esi, %esi
	jg	.L12
	movl	%eax, (%rbx)
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	%r9d, 0(%rbp)
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	%edi, (%r8)
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	xorl	%edi, %edi
	movl	$1, %r9d
	movl	%eax, (%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 24
	movl	%r9d, 0(%rbp)
	popq	%rbp
	.cfi_def_cfa_offset 16
	movl	%edi, (%r8)
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE24:
	.size	ex_gcd, .-ex_gcd
	.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:
.LFB25:
	.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
	jle	.L18
	xorl	%r10d, %r10d
	movl	$1, %r9d
	movl	$1, %edi
	xorl	%r8d, %r8d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L19:
	movl	%edx, %r9d
	movl	%r11d, %r8d
.L16:
	cltd
	idivl	%ecx
	movl	%eax, %esi
	movl	%ecx, %eax
	movl	%edx, %ecx
	movl	%esi, %edx
	imull	%r9d, %esi
	imull	%r8d, %edx
	subl	%edx, %edi
	movl	%r10d, %edx
	movl	%r9d, %r10d
	movl	%edi, %r11d
	subl	%esi, %edx
	movl	%r8d, %edi
	testl	%ecx, %ecx
	jg	.L19
.L15:
	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	.L21
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L18:
	.cfi_restore_state
	xorl	%r9d, %r9d
	movl	$1, %r8d
	jmp	.L15
.L21:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.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>

int gcd(int a, int b) {
	int tmp;
	if (b > a) {
		tmp = a;
		a = b;
		b = tmp;
	}

	while (b) {
		tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}

void ex_gcd(int a, int b, int* g, int* x, int* y) {
	int r0, r1, r2, x0, x1, x2, y0, y1, y2, q;
	r0 = a; r1 = b;
	x0 = 1; x1 = 0;
	y0 = 0; y1 = 1;
	while (r1 > 0) {
//		printf("x0 = %d, y0 = %d\n", x0, y0);
		r2 = r0 % r1;
		q = r0 / r1;
		x2 = x0 - q * x1;
		y2 = y0 - q * y1;
		r0 = r1; r1 = r2;
		x0 = x1; x1 = x2;
		y0 = y1; y1 = y2;
	}
	*g = r0;
	*x = x0;
	*y = y0;
	return;
}

int main(void) {
	int a, b, g;
	int x = 0, y = 0;
	scanf("%d %d", &a, &b);
	
//	g = gcd(a, b);
	ex_gcd(a, b, &g, &x, &y);
	printf("%d %d\n", x, y);
	return 0;
}
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>

int gcd(int a, int b) {
	int tmp;
	if (b > a) {
		tmp = a;
		a = b;
		b = tmp;
	}

	while (b) {
		tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}

void ex_gcd(int a, int b, int* g, int* x, int* y) {
	int r0, r1, r2, x0, x1, x2, y0, y1, y2, q;
	r0 = a; r1 = b;
	x0 = 1; x1 = 0;
	y0 = 0; y1 = 1;
	while (r1 > 0) {
//		printf("x0 = %d, y0 = %d\n", x0, y0);
		r2 = r0 % r1;
		q = r0 / r1;
		x2 = x0 - q * x1;
		y2 = y0 - q * y1;
		r0 = r1; r1 = r2;
		x0 = x1; x1 = x2;
		y0 = y1; y1 = y2;
	}
	*g = r0;
	*x = x0;
	*y = y0;
	return;
}

int main(void) {
	int a, b, g;
	int x = 0, y = 0;
	scanf("%d %d", &a, &b);
	
//	g = gcd(a, b);
	ex_gcd(a, b, &g, &x, &y);
	printf("%d %d\n", x, y);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	gcd
	.type	gcd, @function
gcd:
.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, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L3
	movl	-20(%rbp), %eax
	movl	%eax, -4(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
	jmp	.L3
.L4:
	movl	-20(%rbp), %eax
	cltd
	idivl	-24(%rbp)
	movl	%edx, -4(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
.L3:
	cmpl	$0, -24(%rbp)
	jne	.L4
	movl	-20(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	gcd, .-gcd
	.globl	ex_gcd
	.type	ex_gcd, @function
ex_gcd:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -52(%rbp)
	movl	%esi, -56(%rbp)
	movq	%rdx, -64(%rbp)
	movq	%rcx, -72(%rbp)
	movq	%r8, -80(%rbp)
	movl	-52(%rbp), %eax
	movl	%eax, -40(%rbp)
	movl	-56(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	$1, -32(%rbp)
	movl	$0, -28(%rbp)
	movl	$0, -24(%rbp)
	movl	$1, -20(%rbp)
	jmp	.L7
.L8:
	movl	-40(%rbp), %eax
	cltd
	idivl	-36(%rbp)
	movl	%edx, -16(%rbp)
	movl	-40(%rbp), %eax
	cltd
	idivl	-36(%rbp)
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	imull	-28(%rbp), %eax
	movl	%eax, %edx
	movl	-32(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	imull	-20(%rbp), %eax
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-36(%rbp), %eax
	movl	%eax, -40(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -32(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, -28(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -20(%rbp)
.L7:
	cmpl	$0, -36(%rbp)
	jg	.L8
	movq	-64(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, (%rax)
	movq	-72(%rbp), %rax
	movl	-32(%rbp), %edx
	movl	%edx, (%rax)
	movq	-80(%rbp), %rax
	movl	-24(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	ex_gcd, .-ex_gcd
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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
	movl	$0, -16(%rbp)
	movl	$0, -12(%rbp)
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %esi
	movl	-28(%rbp), %eax
	leaq	-12(%rbp), %rdi
	leaq	-16(%rbp), %rcx
	leaq	-20(%rbp), %rdx
	movq	%rdi, %r8
	movl	%eax, %edi
	call	ex_gcd
	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	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	gcd
	.type	gcd, @function
gcd:
.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, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-24(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jle	.L3
	movl	-20(%rbp), %eax
	movl	%eax, -4(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
	jmp	.L3
.L4:
	movl	-20(%rbp), %eax
	cltd
	idivl	-24(%rbp)
	movl	%edx, -4(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -24(%rbp)
.L3:
	cmpl	$0, -24(%rbp)
	jne	.L4
	movl	-20(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	gcd, .-gcd
	.globl	ex_gcd
	.type	ex_gcd, @function
ex_gcd:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -52(%rbp)
	movl	%esi, -56(%rbp)
	movq	%rdx, -64(%rbp)
	movq	%rcx, -72(%rbp)
	movq	%r8, -80(%rbp)
	movl	-52(%rbp), %eax
	movl	%eax, -40(%rbp)
	movl	-56(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	$1, -32(%rbp)
	movl	$0, -28(%rbp)
	movl	$0, -24(%rbp)
	movl	$1, -20(%rbp)
	jmp	.L7
.L8:
	movl	-40(%rbp), %eax
	cltd
	idivl	-36(%rbp)
	movl	%edx, -16(%rbp)
	movl	-40(%rbp), %eax
	cltd
	idivl	-36(%rbp)
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	imull	-28(%rbp), %eax
	movl	%eax, %edx
	movl	-32(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	imull	-20(%rbp), %eax
	movl	%eax, %edx
	movl	-24(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-36(%rbp), %eax
	movl	%eax, -40(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, -36(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -32(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, -28(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, -20(%rbp)
.L7:
	cmpl	$0, -36(%rbp)
	jg	.L8
	movq	-64(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, (%rax)
	movq	-72(%rbp), %rax
	movl	-32(%rbp), %edx
	movl	%edx, (%rax)
	movq	-80(%rbp), %rax
	movl	-24(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	ex_gcd, .-ex_gcd
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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
	movl	$0, -16(%rbp)
	movl	$0, -12(%rbp)
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %esi
	movl	-28(%rbp), %eax
	leaq	-12(%rbp), %rdi
	leaq	-16(%rbp), %rcx
	leaq	-20(%rbp), %rdx
	movq	%rdi, %r8
	movl	%eax, %edi
	call	ex_gcd
	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	.L12
	call	__stack_chk_fail@PLT
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
