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 gcd(int a,int b){int r,tmp;if(a < b){tmp = a;a = b;b = tmp;}r = a % b;while(r != 0){a = b;b = r;r = a % b;}return b;}
int lcm(int a,int b){int r;r = gcd(a,b);r = a / r * b;return r;}

int main()
{
    int n,a[100000],i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }

    int r = a[0];
    for (i = 1; i < n; i++)
    {
        r = gcd(r,a[i]);
    }
    printf("%d",r);
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB39:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	cmpl	%esi, %edi
	jge	.L2
	movl	%esi, %eax
	movl	%edi, %esi
.L2:
	cltd
	idivl	%esi
	testl	%edx, %edx
	je	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%esi, %eax
	movl	%edx, %r8d
	cltd
	movl	%r8d, %esi
	idivl	%r8d
	testl	%edx, %edx
	jne	.L4
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%esi, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	gcd, .-gcd
	.p2align 4
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB40:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	jge	.L12
	movl	%esi, %eax
	movl	%edi, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L13
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ecx, %eax
	movl	%edx, %r8d
	movl	%edx, %ecx
	cltd
	idivl	%r8d
	testl	%edx, %edx
	jne	.L11
	movl	%edi, %eax
	cltd
	idivl	%r8d
	imull	%esi, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	movl	%edi, %eax
	movl	%esi, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L11
.L13:
	movl	%edi, %eax
	movl	%ecx, %r8d
	cltd
	idivl	%r8d
	imull	%esi, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	lcm, .-lcm
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397344
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2720, %rsp
	.cfi_def_cfa_offset 400064
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L16
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jg	.L17
	movl	16(%rsp), %r8d
	cmpl	$1, %eax
	jle	.L18
	subl	$2, %eax
	leaq	20(%rsp), %rsi
	leaq	24(%rsp,%rax,4), %rdi
	.p2align 4,,10
	.p2align 3
.L22:
	movl	(%rsi), %ecx
	cmpl	%r8d, %ecx
	jle	.L19
	movl	%r8d, %eax
	movl	%ecx, %r8d
	movl	%eax, %ecx
.L19:
	movl	%r8d, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L24
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%ecx, %eax
	movl	%edx, %r8d
	cltd
	movl	%r8d, %ecx
	idivl	%r8d
	testl	%edx, %edx
	jne	.L21
	addq	$4, %rsi
	cmpq	%rdi, %rsi
	jne	.L22
.L18:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$400032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addq	$4, %rsi
	movl	%ecx, %r8d
	cmpq	%rdi, %rsi
	jne	.L22
	jmp	.L18
.L16:
	movl	16(%rsp), %r8d
	jmp	.L18
.L30:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.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:
.LFB39:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	cmpl	%esi, %edi
	jge	.L2
	movl	%esi, %eax
	movl	%edi, %esi
.L2:
	cltd
	idivl	%esi
	testl	%edx, %edx
	je	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%esi, %eax
	movl	%edx, %r8d
	cltd
	movl	%r8d, %esi
	idivl	%r8d
	testl	%edx, %edx
	jne	.L4
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%esi, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	gcd, .-gcd
	.p2align 4
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB40:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	jge	.L12
	movl	%esi, %eax
	movl	%edi, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L13
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ecx, %eax
	movl	%edx, %r8d
	movl	%edx, %ecx
	cltd
	idivl	%r8d
	testl	%edx, %edx
	jne	.L11
	movl	%edi, %eax
	cltd
	idivl	%r8d
	imull	%esi, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	movl	%edi, %eax
	movl	%esi, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L11
.L13:
	movl	%edi, %eax
	movl	%ecx, %r8d
	cltd
	idivl	%r8d
	imull	%esi, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	lcm, .-lcm
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397344
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2720, %rsp
	.cfi_def_cfa_offset 400064
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L16
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jg	.L17
	movl	16(%rsp), %r8d
	cmpl	$1, %eax
	jle	.L18
	subl	$2, %eax
	leaq	20(%rsp), %rsi
	leaq	24(%rsp,%rax,4), %rdi
	.p2align 4,,10
	.p2align 3
.L22:
	movl	(%rsi), %ecx
	cmpl	%r8d, %ecx
	jle	.L19
	movl	%r8d, %eax
	movl	%ecx, %r8d
	movl	%eax, %ecx
.L19:
	movl	%r8d, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L24
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%ecx, %eax
	movl	%edx, %r8d
	cltd
	movl	%r8d, %ecx
	idivl	%r8d
	testl	%edx, %edx
	jne	.L21
	addq	$4, %rsi
	cmpq	%rdi, %rsi
	jne	.L22
.L18:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$400032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addq	$4, %rsi
	movl	%ecx, %r8d
	cmpq	%rdi, %rsi
	jne	.L22
	jmp	.L18
.L16:
	movl	16(%rsp), %r8d
	jmp	.L18
.L30:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.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:
.LFB39:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	cmpl	%esi, %edi
	jge	.L2
	movl	%esi, %eax
	movl	%edi, %esi
.L2:
	cltd
	idivl	%esi
	testl	%edx, %edx
	je	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%esi, %eax
	movl	%edx, %r8d
	cltd
	movl	%r8d, %esi
	idivl	%r8d
	testl	%edx, %edx
	jne	.L4
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%esi, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	gcd, .-gcd
	.p2align 4
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB40:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	jge	.L12
	movl	%esi, %eax
	movl	%edi, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L13
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ecx, %eax
	movl	%edx, %r8d
	movl	%edx, %ecx
	cltd
	idivl	%r8d
	testl	%edx, %edx
	jne	.L11
	movl	%edi, %eax
	cltd
	idivl	%r8d
	imull	%esi, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	movl	%edi, %eax
	movl	%esi, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L11
.L13:
	movl	%edi, %eax
	movl	%ecx, %r8d
	cltd
	idivl	%r8d
	imull	%esi, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	lcm, .-lcm
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397344
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2720, %rsp
	.cfi_def_cfa_offset 400064
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L16
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jg	.L17
	movl	16(%rsp), %r8d
	cmpl	$1, %eax
	jle	.L18
	subl	$2, %eax
	leaq	20(%rsp), %rsi
	leaq	24(%rsp,%rax,4), %rdi
	.p2align 4,,10
	.p2align 3
.L22:
	movl	(%rsi), %ecx
	cmpl	%r8d, %ecx
	jle	.L19
	movl	%r8d, %eax
	movl	%ecx, %r8d
	movl	%eax, %ecx
.L19:
	movl	%r8d, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L24
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%ecx, %eax
	movl	%edx, %r8d
	cltd
	movl	%r8d, %ecx
	idivl	%r8d
	testl	%edx, %edx
	jne	.L21
	addq	$4, %rsi
	cmpq	%rdi, %rsi
	jne	.L22
.L18:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$400032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addq	$4, %rsi
	movl	%ecx, %r8d
	cmpq	%rdi, %rsi
	jne	.L22
	jmp	.L18
.L16:
	movl	16(%rsp), %r8d
	jmp	.L18
.L30:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.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 gcd(int a,int b){int r,tmp;if(a < b){tmp = a;a = b;b = tmp;}r = a % b;while(r != 0){a = b;b = r;r = a % b;}return b;}
int lcm(int a,int b){int r;r = gcd(a,b);r = a / r * b;return r;}

int main()
{
    int n,a[100000],i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }

    int r = a[0];
    for (i = 1; i < n; i++)
    {
        r = gcd(r,a[i]);
    }
    printf("%d",r);
}```
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 gcd(int a,int b){int r,tmp;if(a < b){tmp = a;a = b;b = tmp;}r = a % b;while(r != 0){a = b;b = r;r = a % b;}return b;}
int lcm(int a,int b){int r;r = gcd(a,b);r = a / r * b;return r;}

int main()
{
    int n,a[100000],i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }

    int r = a[0];
    for (i = 1; i < n; i++)
    {
        r = gcd(r,a[i]);
    }
    printf("%d",r);
}```

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:

3
1000000100 1000000000 1000000000
 4
5 13 8 1000010000

100 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>
#include <stdlib.h>

int gcd(int a,int b){int r,tmp;if(a < b){tmp = a;a = b;b = tmp;}r = a % b;while(r != 0){a = b;b = r;r = a % b;}return b;}
int lcm(int a,int b){int r;r = gcd(a,b);r = a / r * b;return r;}

int main()
{
    int n,a[100000],i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }

    int r = a[0];
    for (i = 1; i < n; i++)
    {
        r = gcd(r,a[i]);
    }
    printf("%d",r);
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	gcd
	.type	gcd, @function
gcd:
.LFB39:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	cmpl	%esi, %edi
	jge	.L2
	movl	%esi, %eax
	movl	%edi, %esi
.L2:
	cltd
	idivl	%esi
	testl	%edx, %edx
	je	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%esi, %eax
	movl	%edx, %r8d
	cltd
	movl	%r8d, %esi
	idivl	%r8d
	testl	%edx, %edx
	jne	.L4
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%esi, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	gcd, .-gcd
	.p2align 4
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB40:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	jge	.L12
	movl	%esi, %eax
	movl	%edi, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L13
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ecx, %eax
	movl	%edx, %r8d
	movl	%edx, %ecx
	cltd
	idivl	%r8d
	testl	%edx, %edx
	jne	.L11
	movl	%edi, %eax
	cltd
	idivl	%r8d
	imull	%esi, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	movl	%edi, %eax
	movl	%esi, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L11
.L13:
	movl	%edi, %eax
	movl	%ecx, %r8d
	cltd
	idivl	%r8d
	imull	%esi, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	lcm, .-lcm
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397344
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2720, %rsp
	.cfi_def_cfa_offset 400064
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L16
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jg	.L17
	movl	16(%rsp), %r8d
	cmpl	$1, %eax
	jle	.L18
	subl	$2, %eax
	leaq	20(%rsp), %rsi
	leaq	24(%rsp,%rax,4), %rdi
	.p2align 4,,10
	.p2align 3
.L22:
	movl	(%rsi), %ecx
	cmpl	%r8d, %ecx
	jle	.L19
	movl	%r8d, %eax
	movl	%ecx, %r8d
	movl	%eax, %ecx
.L19:
	movl	%r8d, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L24
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%ecx, %eax
	movl	%edx, %r8d
	cltd
	movl	%r8d, %ecx
	idivl	%r8d
	testl	%edx, %edx
	jne	.L21
	addq	$4, %rsi
	cmpq	%rdi, %rsi
	jne	.L22
.L18:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$400032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addq	$4, %rsi
	movl	%ecx, %r8d
	cmpq	%rdi, %rsi
	jne	.L22
	jmp	.L18
.L16:
	movl	16(%rsp), %r8d
	jmp	.L18
.L30:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.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:
.LFB39:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	cmpl	%esi, %edi
	jge	.L2
	movl	%esi, %eax
	movl	%edi, %esi
.L2:
	cltd
	idivl	%esi
	testl	%edx, %edx
	je	.L5
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%esi, %eax
	movl	%edx, %r8d
	cltd
	movl	%r8d, %esi
	idivl	%r8d
	testl	%edx, %edx
	jne	.L4
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	movl	%esi, %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	gcd, .-gcd
	.p2align 4
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB40:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	jge	.L12
	movl	%esi, %eax
	movl	%edi, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L13
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%ecx, %eax
	movl	%edx, %r8d
	movl	%edx, %ecx
	cltd
	idivl	%r8d
	testl	%edx, %edx
	jne	.L11
	movl	%edi, %eax
	cltd
	idivl	%r8d
	imull	%esi, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L12:
	movl	%edi, %eax
	movl	%esi, %ecx
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L11
.L13:
	movl	%edi, %eax
	movl	%ecx, %r8d
	cltd
	idivl	%r8d
	imull	%esi, %eax
	ret
	.cfi_endproc
.LFE40:
	.size	lcm, .-lcm
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397344
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2720, %rsp
	.cfi_def_cfa_offset 400064
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L16
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$4, %rbp
	cmpl	%ebx, %eax
	jg	.L17
	movl	16(%rsp), %r8d
	cmpl	$1, %eax
	jle	.L18
	subl	$2, %eax
	leaq	20(%rsp), %rsi
	leaq	24(%rsp,%rax,4), %rdi
	.p2align 4,,10
	.p2align 3
.L22:
	movl	(%rsi), %ecx
	cmpl	%r8d, %ecx
	jle	.L19
	movl	%r8d, %eax
	movl	%ecx, %r8d
	movl	%eax, %ecx
.L19:
	movl	%r8d, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	je	.L24
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%ecx, %eax
	movl	%edx, %r8d
	cltd
	movl	%r8d, %ecx
	idivl	%r8d
	testl	%edx, %edx
	jne	.L21
	addq	$4, %rsi
	cmpq	%rdi, %rsi
	jne	.L22
.L18:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$400032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	addq	$4, %rsi
	movl	%ecx, %r8d
	cmpq	%rdi, %rsi
	jne	.L22
	jmp	.L18
.L16:
	movl	16(%rsp), %r8d
	jmp	.L18
.L30:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.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:
```