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>

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;
}```

Assembly Code:

```assembly
	.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:
```

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
	.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
```assembly
	.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:
```
```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;
}```
Given the following C 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;
}```

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:

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 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;
}```

Assembly Code:

```assembly
	.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:
```

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
	.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:
```