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>          // printf(), scanf()
#include <stdbool.h>

long
gcd(long a, long b)
{
	if (b == 0)
		return a;

	return gcd(b, a % b);
}

long
lcm(long a, long b)
{
	return (a * b / gcd(a, b));
}

int
main(int argc, char **argv)
{
	while (true)
	{
		int a1, a2, a3;
		int m1, m2, m3;
		int x, y, z;
		long c1, c2, c3;

		scanf("%d %d %d %d %d %d", &a1, &m1, &a2, &m2, &a3, &m3);

		if (a1 == 0 && m1 == 0 && a2 == 0 && m2 == 0 && a3 == 0 && m3 == 0)
			break;

		x = 1;
		c1 = 0;
		do
		{
			x = (a1 * x) % m1;
			c1++;
		} while (x != 1);

		y = 1;
		c2 = 0;
		do
		{
			y = (a2 * y) % m2;
			c2++;
		} while (y != 1);

		z = 1;
		c3 = 0;
		do
		{
			z = (a3 * z) % m3;
			c3++;
		} while (z != 1);

		printf("%ld\n", lcm(lcm(c1, c2), c3));
	}

	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
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L2
	movq	-8(%rbp), %rax
	jmp	.L3
.L2:
	movq	-8(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	gcd, .-gcd
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	imulq	-32(%rbp), %rax
	movq	%rax, %rbx
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rcx
	movq	%rbx, %rax
	cqto
	idivq	%rcx
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	lcm, .-lcm
	.section	.rodata
.LC0:
	.string	"%d %d %d %d %d %d"
.LC1:
	.string	"%ld\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	$96, %rsp
	movl	%edi, -84(%rbp)
	movq	%rsi, -96(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L12:
	leaq	-60(%rbp), %r8
	leaq	-52(%rbp), %rdi
	leaq	-64(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-68(%rbp), %rax
	subq	$8, %rsp
	leaq	-48(%rbp), %rsi
	pushq	%rsi
	movq	%r8, %r9
	movq	%rdi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$16, %rsp
	movl	-68(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-56(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-64(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-52(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-48(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	jmp	.L14
.L7:
	movl	$1, -44(%rbp)
	movq	$0, -32(%rbp)
.L9:
	movl	-68(%rbp), %eax
	imull	-44(%rbp), %eax
	movl	-56(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -44(%rbp)
	addq	$1, -32(%rbp)
	cmpl	$1, -44(%rbp)
	jne	.L9
	movl	$1, -40(%rbp)
	movq	$0, -24(%rbp)
.L10:
	movl	-64(%rbp), %eax
	imull	-40(%rbp), %eax
	movl	-52(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -40(%rbp)
	addq	$1, -24(%rbp)
	cmpl	$1, -40(%rbp)
	jne	.L10
	movl	$1, -36(%rbp)
	movq	$0, -16(%rbp)
.L11:
	movl	-60(%rbp), %eax
	imull	-36(%rbp), %eax
	movl	-48(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -36(%rbp)
	addq	$1, -16(%rbp)
	cmpl	$1, -36(%rbp)
	jne	.L11
	movq	-24(%rbp), %rdx
	movq	-32(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	lcm
	movq	%rax, %rdx
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	lcm
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L14:
	call	__stack_chk_fail@PLT
.L13:
	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
	movq	%rdi, %rax
	movq	%rsi, %r8
	testq	%rsi, %rsi
	jne	.L2
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%rdx, %r8
.L2:
	cqto
	idivq	%r8
	movq	%r8, %rax
	testq	%rdx, %rdx
	jne	.L11
	movq	%r8, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%rdi, %r8
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.p2align 4
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB24:
	.cfi_startproc
	endbr64
	movq	%rdi, %rcx
	movq	%rdi, %rax
	imulq	%rsi, %rcx
	testq	%rsi, %rsi
	jne	.L13
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdx, %rsi
.L13:
	cqto
	idivq	%rsi
	movq	%rsi, %rax
	testq	%rdx, %rdx
	jne	.L15
	movq	%rcx, %rax
	cqto
	idivq	%rsi
	ret
	.p2align 4,,10
	.p2align 3
.L17:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	lcm, .-lcm
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d %d %d %d"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC0(%rip), %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	leaq	24(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	32(%rsp), %r14
	leaq	20(%rsp), %r13
	leaq	28(%rsp), %r12
	leaq	16(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L26:
	subq	$8, %rsp
	.cfi_def_cfa_offset 120
	movq	%r15, %r9
	movq	%r14, %r8
	movq	%r13, %rcx
	pushq	16(%rsp)
	.cfi_def_cfa_offset 128
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %r11d
	movl	44(%rsp), %r8d
	movl	36(%rsp), %r10d
	movl	48(%rsp), %edi
	movl	%r11d, %eax
	movl	40(%rsp), %r9d
	movl	52(%rsp), %esi
	orl	%r8d, %eax
	popq	%rdx
	.cfi_def_cfa_offset 120
	popq	%rcx
	.cfi_def_cfa_offset 112
	orl	%r10d, %eax
	orl	%edi, %eax
	orl	%r9d, %eax
	orl	%esi, %eax
	je	.L19
	xorl	%ecx, %ecx
	movl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L20:
	movl	%edx, %eax
	addq	$1, %rcx
	imull	%r11d, %eax
	cltd
	idivl	%r8d
	cmpl	$1, %edx
	jne	.L20
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%edx, %eax
	addq	$1, %r8
	imull	%r10d, %eax
	cltd
	idivl	%edi
	cmpl	$1, %edx
	jne	.L21
	xorl	%edi, %edi
	.p2align 4,,10
	.p2align 3
.L22:
	movl	%edx, %eax
	addq	$1, %rdi
	imull	%r9d, %eax
	cltd
	idivl	%esi
	cmpl	$1, %edx
	jne	.L22
	movq	%rcx, %rsi
	movq	%rcx, %rax
	imulq	%r8, %rsi
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L33:
	movq	%rdx, %r8
.L23:
	cqto
	idivq	%r8
	movq	%r8, %rax
	testq	%rdx, %rdx
	jne	.L33
	movq	%rsi, %rax
	movq	%rdi, %rcx
	cqto
	idivq	%r8
	imulq	%rax, %rcx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L34:
	movq	%rdx, %rdi
.L24:
	cqto
	idivq	%rdi
	movq	%rdi, %rax
	testq	%rdx, %rdx
	jne	.L34
	movq	%rcx, %rax
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rdi
	movl	$1, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L26
.L19:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L35
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L35:
	.cfi_restore_state
	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
	movq	%rdi, %rax
	movq	%rsi, %r8
	testq	%rsi, %rsi
	jne	.L2
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%rdx, %r8
.L2:
	cqto
	idivq	%r8
	movq	%r8, %rax
	testq	%rdx, %rdx
	jne	.L11
	movq	%r8, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%rdi, %r8
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.p2align 4
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB24:
	.cfi_startproc
	endbr64
	movq	%rdi, %rcx
	movq	%rdi, %rax
	imulq	%rsi, %rcx
	testq	%rsi, %rsi
	jne	.L13
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdx, %rsi
.L13:
	cqto
	idivq	%rsi
	movq	%rsi, %rax
	testq	%rdx, %rdx
	jne	.L15
	movq	%rcx, %rax
	cqto
	idivq	%rsi
	ret
	.p2align 4,,10
	.p2align 3
.L17:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	lcm, .-lcm
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d %d %d %d"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC0(%rip), %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	leaq	24(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	32(%rsp), %r14
	leaq	20(%rsp), %r13
	leaq	28(%rsp), %r12
	leaq	16(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L26:
	subq	$8, %rsp
	.cfi_def_cfa_offset 120
	movq	%r15, %r9
	movq	%r14, %r8
	movq	%r13, %rcx
	pushq	16(%rsp)
	.cfi_def_cfa_offset 128
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %r11d
	movl	44(%rsp), %r8d
	movl	36(%rsp), %r10d
	movl	48(%rsp), %edi
	movl	%r11d, %eax
	movl	40(%rsp), %r9d
	movl	52(%rsp), %esi
	orl	%r8d, %eax
	popq	%rdx
	.cfi_def_cfa_offset 120
	popq	%rcx
	.cfi_def_cfa_offset 112
	orl	%r10d, %eax
	orl	%edi, %eax
	orl	%r9d, %eax
	orl	%esi, %eax
	je	.L19
	xorl	%ecx, %ecx
	movl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L20:
	movl	%edx, %eax
	addq	$1, %rcx
	imull	%r11d, %eax
	cltd
	idivl	%r8d
	cmpl	$1, %edx
	jne	.L20
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%edx, %eax
	addq	$1, %r8
	imull	%r10d, %eax
	cltd
	idivl	%edi
	cmpl	$1, %edx
	jne	.L21
	xorl	%edi, %edi
	.p2align 4,,10
	.p2align 3
.L22:
	movl	%edx, %eax
	addq	$1, %rdi
	imull	%r9d, %eax
	cltd
	idivl	%esi
	cmpl	$1, %edx
	jne	.L22
	movq	%rcx, %rsi
	movq	%rcx, %rax
	imulq	%r8, %rsi
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L33:
	movq	%rdx, %r8
.L23:
	cqto
	idivq	%r8
	movq	%r8, %rax
	testq	%rdx, %rdx
	jne	.L33
	movq	%rsi, %rax
	movq	%rdi, %rcx
	cqto
	idivq	%r8
	imulq	%rax, %rcx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L34:
	movq	%rdx, %rdi
.L24:
	cqto
	idivq	%rdi
	movq	%rdi, %rax
	testq	%rdx, %rdx
	jne	.L34
	movq	%rcx, %rax
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rdi
	movl	$1, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L26
.L19:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L35
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L35:
	.cfi_restore_state
	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>          // printf(), scanf()
#include <stdbool.h>

long
gcd(long a, long b)
{
	if (b == 0)
		return a;

	return gcd(b, a % b);
}

long
lcm(long a, long b)
{
	return (a * b / gcd(a, b));
}

int
main(int argc, char **argv)
{
	while (true)
	{
		int a1, a2, a3;
		int m1, m2, m3;
		int x, y, z;
		long c1, c2, c3;

		scanf("%d %d %d %d %d %d", &a1, &m1, &a2, &m2, &a3, &m3);

		if (a1 == 0 && m1 == 0 && a2 == 0 && m2 == 0 && a3 == 0 && m3 == 0)
			break;

		x = 1;
		c1 = 0;
		do
		{
			x = (a1 * x) % m1;
			c1++;
		} while (x != 1);

		y = 1;
		c2 = 0;
		do
		{
			y = (a2 * y) % m2;
			c2++;
		} while (y != 1);

		z = 1;
		c3 = 0;
		do
		{
			z = (a3 * z) % m3;
			c3++;
		} while (z != 1);

		printf("%ld\n", lcm(lcm(c1, c2), c3));
	}

	return 0;
}
2 5 5 7 6 13
517 1024 746 6561 4303 3125
0 0 0 0 0 0
 2 5 5 7 6 13
517 1334 746 6561 4303 3125
0 0 0 0 0 0
 2 5 5 7 6 13
517 1024 746 11315 4303 3125
0 0 0 0 0 0
 2 5 5 7 6 13
913 1334 1228 6561 4303 3125
0 0 0 0 0 0
 2 5 5 7 6 13
517 1024 746 14921 4303 3125
0 0 0 0 0 0
 2 5 5 7 6 13
517 821 746 11315 4303 3125
0 0 0 0 0 0
 2 5 5 7 6 13
913 1334 764 6561 6799 3125
0 0 0 0 0 0
 2 5 6 7 6 13
517 1024 746 11867 4303 3125
0 0 0 0 0 0
 2 5 5 7 6 13
844 821 1163 11315 4303 3125
0 0 0 0 0 0
 2 5 5 7 6 13
913 1334 764 6561 10568 3125
0 0 0 0 0 0

12
116640000
 12
140332500
 12
1440000
 12
420997500
 12
581280000
 12
922500
 12
28066500
 12
949280000
 12
1845000
 12
5613300

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>          // printf(), scanf()
#include <stdbool.h>

long
gcd(long a, long b)
{
	if (b == 0)
		return a;

	return gcd(b, a % b);
}

long
lcm(long a, long b)
{
	return (a * b / gcd(a, b));
}

int
main(int argc, char **argv)
{
	while (true)
	{
		int a1, a2, a3;
		int m1, m2, m3;
		int x, y, z;
		long c1, c2, c3;

		scanf("%d %d %d %d %d %d", &a1, &m1, &a2, &m2, &a3, &m3);

		if (a1 == 0 && m1 == 0 && a2 == 0 && m2 == 0 && a3 == 0 && m3 == 0)
			break;

		x = 1;
		c1 = 0;
		do
		{
			x = (a1 * x) % m1;
			c1++;
		} while (x != 1);

		y = 1;
		c2 = 0;
		do
		{
			y = (a2 * y) % m2;
			c2++;
		} while (y != 1);

		z = 1;
		c3 = 0;
		do
		{
			z = (a3 * z) % m3;
			c3++;
		} while (z != 1);

		printf("%ld\n", lcm(lcm(c1, c2), c3));
	}

	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
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L2
	movq	-8(%rbp), %rax
	jmp	.L3
.L2:
	movq	-8(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	gcd, .-gcd
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	imulq	-32(%rbp), %rax
	movq	%rax, %rbx
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rcx
	movq	%rbx, %rax
	cqto
	idivq	%rcx
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	lcm, .-lcm
	.section	.rodata
.LC0:
	.string	"%d %d %d %d %d %d"
.LC1:
	.string	"%ld\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	$96, %rsp
	movl	%edi, -84(%rbp)
	movq	%rsi, -96(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L12:
	leaq	-60(%rbp), %r8
	leaq	-52(%rbp), %rdi
	leaq	-64(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-68(%rbp), %rax
	subq	$8, %rsp
	leaq	-48(%rbp), %rsi
	pushq	%rsi
	movq	%r8, %r9
	movq	%rdi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$16, %rsp
	movl	-68(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-56(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-64(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-52(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-48(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	jmp	.L14
.L7:
	movl	$1, -44(%rbp)
	movq	$0, -32(%rbp)
.L9:
	movl	-68(%rbp), %eax
	imull	-44(%rbp), %eax
	movl	-56(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -44(%rbp)
	addq	$1, -32(%rbp)
	cmpl	$1, -44(%rbp)
	jne	.L9
	movl	$1, -40(%rbp)
	movq	$0, -24(%rbp)
.L10:
	movl	-64(%rbp), %eax
	imull	-40(%rbp), %eax
	movl	-52(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -40(%rbp)
	addq	$1, -24(%rbp)
	cmpl	$1, -40(%rbp)
	jne	.L10
	movl	$1, -36(%rbp)
	movq	$0, -16(%rbp)
.L11:
	movl	-60(%rbp), %eax
	imull	-36(%rbp), %eax
	movl	-48(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -36(%rbp)
	addq	$1, -16(%rbp)
	cmpl	$1, -36(%rbp)
	jne	.L11
	movq	-24(%rbp), %rdx
	movq	-32(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	lcm
	movq	%rax, %rdx
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	lcm
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L14:
	call	__stack_chk_fail@PLT
.L13:
	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
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	cmpq	$0, -16(%rbp)
	jne	.L2
	movq	-8(%rbp), %rax
	jmp	.L3
.L2:
	movq	-8(%rbp), %rax
	cqto
	idivq	-16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	gcd, .-gcd
	.globl	lcm
	.type	lcm, @function
lcm:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	imulq	-32(%rbp), %rax
	movq	%rax, %rbx
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rcx
	movq	%rbx, %rax
	cqto
	idivq	%rcx
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	lcm, .-lcm
	.section	.rodata
.LC0:
	.string	"%d %d %d %d %d %d"
.LC1:
	.string	"%ld\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	$96, %rsp
	movl	%edi, -84(%rbp)
	movq	%rsi, -96(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L12:
	leaq	-60(%rbp), %r8
	leaq	-52(%rbp), %rdi
	leaq	-64(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-68(%rbp), %rax
	subq	$8, %rsp
	leaq	-48(%rbp), %rsi
	pushq	%rsi
	movq	%r8, %r9
	movq	%rdi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addq	$16, %rsp
	movl	-68(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-56(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-64(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-52(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	-48(%rbp), %eax
	testl	%eax, %eax
	jne	.L7
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L13
	jmp	.L14
.L7:
	movl	$1, -44(%rbp)
	movq	$0, -32(%rbp)
.L9:
	movl	-68(%rbp), %eax
	imull	-44(%rbp), %eax
	movl	-56(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -44(%rbp)
	addq	$1, -32(%rbp)
	cmpl	$1, -44(%rbp)
	jne	.L9
	movl	$1, -40(%rbp)
	movq	$0, -24(%rbp)
.L10:
	movl	-64(%rbp), %eax
	imull	-40(%rbp), %eax
	movl	-52(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -40(%rbp)
	addq	$1, -24(%rbp)
	cmpl	$1, -40(%rbp)
	jne	.L10
	movl	$1, -36(%rbp)
	movq	$0, -16(%rbp)
.L11:
	movl	-60(%rbp), %eax
	imull	-36(%rbp), %eax
	movl	-48(%rbp), %ecx
	cltd
	idivl	%ecx
	movl	%edx, -36(%rbp)
	addq	$1, -16(%rbp)
	cmpl	$1, -36(%rbp)
	jne	.L11
	movq	-24(%rbp), %rdx
	movq	-32(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	lcm
	movq	%rax, %rdx
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	movq	%rdx, %rdi
	call	lcm
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L14:
	call	__stack_chk_fail@PLT
.L13:
	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:
