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>
long long int gcd(long long int a, long long int b){
    long long int r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }
    return b;
}
int main(void){
    long long int a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    long long int l=c*d/gcd(c, d);
    long long int ans=(b-b/c-b/d+b/l)-(a-1-(a-1)/c-(a-1)/d+(a-1)/l);
    printf("%lld\n", ans);
    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
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	jmp	.L2
.L3:
	movq	-32(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-8(%rbp), %rax
	movq	%rax, -32(%rbp)
.L2:
	movq	-24(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	%rdx, -8(%rbp)
	cmpq	$0, -8(%rbp)
	jne	.L3
	movq	-32(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	gcd, .-gcd
	.section	.rodata
.LC0:
	.string	"%lld %lld %lld %lld"
.LC1:
	.string	"%lld\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
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rsi
	leaq	-56(%rbp), %rcx
	leaq	-64(%rbp), %rdx
	leaq	-72(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-56(%rbp), %rdx
	movq	-48(%rbp), %rax
	movq	%rdx, %rbx
	imulq	%rax, %rbx
	movq	-48(%rbp), %rdx
	movq	-56(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rdi
	movq	%rbx, %rax
	cqto
	idivq	%rdi
	movq	%rax, -40(%rbp)
	movq	-64(%rbp), %rcx
	movq	-64(%rbp), %rax
	movq	-56(%rbp), %rdi
	cqto
	idivq	%rdi
	subq	%rax, %rcx
	movq	-64(%rbp), %rax
	movq	-48(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rcx
	movq	-64(%rbp), %rax
	cqto
	idivq	-40(%rbp)
	addq	%rax, %rcx
	movq	-72(%rbp), %rax
	leaq	-1(%rax), %rsi
	movq	-72(%rbp), %rax
	subq	$1, %rax
	movq	-56(%rbp), %rdi
	cqto
	idivq	%rdi
	subq	%rax, %rsi
	movq	-72(%rbp), %rax
	subq	$1, %rax
	movq	-48(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rsi
	movq	-72(%rbp), %rax
	subq	$1, %rax
	cqto
	idivq	-40(%rbp)
	leaq	(%rsi,%rax), %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	movq	-8(%rbp), %rbx
	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	gcd
	.type	gcd, @function
gcd:
.LFB23:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	movq	%rsi, %rdx
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%rdx, %rcx
	cqto
	idivq	%rcx
	movq	%rcx, %rax
	testq	%rdx, %rdx
	jne	.L2
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld %lld %lld %lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$56, %rsp
	.cfi_def_cfa_offset 64
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	32(%rsp), %r8
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	24(%rsp), %r10
	movq	32(%rsp), %r9
	movq	%r10, %r8
	movq	%r9, %rdx
	movq	%r10, %rcx
	imulq	%r9, %r8
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%rcx, %rax
	movq	%rdx, %rsi
	cqto
	movq	%rsi, %rcx
	idivq	%rsi
	testq	%rdx, %rdx
	jne	.L6
	movq	%r8, %rax
	cqto
	idivq	%rsi
	movq	16(%rsp), %rsi
	movq	%rsi, %rdi
	movq	%rax, %r8
	movq	8(%rsp), %rax
	leaq	-1(%rax), %rcx
	movq	%rsi, %rax
	cqto
	idivq	%r10
	subq	%rax, %rdi
	movq	%rsi, %rax
	cqto
	idivq	%r9
	subq	%rax, %rdi
	movq	%rsi, %rax
	cqto
	idivq	%r8
	movq	%rax, %rsi
	movq	%rcx, %rax
	cqto
	addq	%rdi, %rsi
	movq	%rcx, %rdi
	idivq	%r10
	subq	%rax, %rdi
	movq	%rcx, %rax
	cqto
	idivq	%r9
	subq	%rax, %rdi
	movq	%rcx, %rax
	cqto
	idivq	%r8
	addq	%rax, %rdi
	xorl	%eax, %eax
	subq	%rdi, %rsi
	movl	$1, %edi
	movq	%rsi, %rdx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L10
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L10:
	.cfi_restore_state
	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	gcd
	.type	gcd, @function
gcd:
.LFB23:
	.cfi_startproc
	endbr64
	movq	%rdi, %rax
	movq	%rsi, %rdx
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%rdx, %rcx
	cqto
	idivq	%rcx
	movq	%rcx, %rax
	testq	%rdx, %rdx
	jne	.L2
	ret
	.cfi_endproc
.LFE23:
	.size	gcd, .-gcd
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld %lld %lld %lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$56, %rsp
	.cfi_def_cfa_offset 64
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	32(%rsp), %r8
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	24(%rsp), %r10
	movq	32(%rsp), %r9
	movq	%r10, %r8
	movq	%r9, %rdx
	movq	%r10, %rcx
	imulq	%r9, %r8
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%rcx, %rax
	movq	%rdx, %rsi
	cqto
	movq	%rsi, %rcx
	idivq	%rsi
	testq	%rdx, %rdx
	jne	.L6
	movq	%r8, %rax
	cqto
	idivq	%rsi
	movq	16(%rsp), %rsi
	movq	%rsi, %rdi
	movq	%rax, %r8
	movq	8(%rsp), %rax
	leaq	-1(%rax), %rcx
	movq	%rsi, %rax
	cqto
	idivq	%r10
	subq	%rax, %rdi
	movq	%rsi, %rax
	cqto
	idivq	%r9
	subq	%rax, %rdi
	movq	%rsi, %rax
	cqto
	idivq	%r8
	movq	%rax, %rsi
	movq	%rcx, %rax
	cqto
	addq	%rdi, %rsi
	movq	%rcx, %rdi
	idivq	%r10
	subq	%rax, %rdi
	movq	%rcx, %rax
	cqto
	idivq	%r9
	subq	%rax, %rdi
	movq	%rcx, %rax
	cqto
	idivq	%r8
	addq	%rax, %rdi
	xorl	%eax, %eax
	subq	%rdi, %rsi
	movl	$1, %edi
	movq	%rsi, %rdx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L10
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L10:
	.cfi_restore_state
	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>
long long int gcd(long long int a, long long int b){
    long long int r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }
    return b;
}
int main(void){
    long long int a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    long long int l=c*d/gcd(c, d);
    long long int ans=(b-b/c-b/d+b/l)-(a-1-(a-1)/c-(a-1)/d+(a-1)/l);
    printf("%lld\n", ans);
    return 0;
}

314159265358979323 84117665769283334 419716939 937510582
 10 40 10 8
 4 5 2 3
 314159265358979323 84117665769283334 419716939 1839634861
 4 40 10 8
 1 5 2 3
 314159265358979323 84117665769283334 103998089 1839634861
 4 40 14 8
 1 5 2 6
 314159265358979323 84117665769283334 5369186 1839634861

-230041598796233572
 24
 1
 -230041598916561084
 29
 2
 -230041597252669462
 30
 3
 -230041556619867350

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>
long long int gcd(long long int a, long long int b){
    long long int r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }
    return b;
}
int main(void){
    long long int a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    long long int l=c*d/gcd(c, d);
    long long int ans=(b-b/c-b/d+b/l)-(a-1-(a-1)/c-(a-1)/d+(a-1)/l);
    printf("%lld\n", ans);
    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
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	jmp	.L2
.L3:
	movq	-32(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-8(%rbp), %rax
	movq	%rax, -32(%rbp)
.L2:
	movq	-24(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	%rdx, -8(%rbp)
	cmpq	$0, -8(%rbp)
	jne	.L3
	movq	-32(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	gcd, .-gcd
	.section	.rodata
.LC0:
	.string	"%lld %lld %lld %lld"
.LC1:
	.string	"%lld\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
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rsi
	leaq	-56(%rbp), %rcx
	leaq	-64(%rbp), %rdx
	leaq	-72(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-56(%rbp), %rdx
	movq	-48(%rbp), %rax
	movq	%rdx, %rbx
	imulq	%rax, %rbx
	movq	-48(%rbp), %rdx
	movq	-56(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rdi
	movq	%rbx, %rax
	cqto
	idivq	%rdi
	movq	%rax, -40(%rbp)
	movq	-64(%rbp), %rcx
	movq	-64(%rbp), %rax
	movq	-56(%rbp), %rdi
	cqto
	idivq	%rdi
	subq	%rax, %rcx
	movq	-64(%rbp), %rax
	movq	-48(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rcx
	movq	-64(%rbp), %rax
	cqto
	idivq	-40(%rbp)
	addq	%rax, %rcx
	movq	-72(%rbp), %rax
	leaq	-1(%rax), %rsi
	movq	-72(%rbp), %rax
	subq	$1, %rax
	movq	-56(%rbp), %rdi
	cqto
	idivq	%rdi
	subq	%rax, %rsi
	movq	-72(%rbp), %rax
	subq	$1, %rax
	movq	-48(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rsi
	movq	-72(%rbp), %rax
	subq	$1, %rax
	cqto
	idivq	-40(%rbp)
	leaq	(%rsi,%rax), %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	movq	-8(%rbp), %rbx
	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	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
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	jmp	.L2
.L3:
	movq	-32(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-8(%rbp), %rax
	movq	%rax, -32(%rbp)
.L2:
	movq	-24(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	%rdx, -8(%rbp)
	cmpq	$0, -8(%rbp)
	jne	.L3
	movq	-32(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	gcd, .-gcd
	.section	.rodata
.LC0:
	.string	"%lld %lld %lld %lld"
.LC1:
	.string	"%lld\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
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rsi
	leaq	-56(%rbp), %rcx
	leaq	-64(%rbp), %rdx
	leaq	-72(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-56(%rbp), %rdx
	movq	-48(%rbp), %rax
	movq	%rdx, %rbx
	imulq	%rax, %rbx
	movq	-48(%rbp), %rdx
	movq	-56(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rdi
	movq	%rbx, %rax
	cqto
	idivq	%rdi
	movq	%rax, -40(%rbp)
	movq	-64(%rbp), %rcx
	movq	-64(%rbp), %rax
	movq	-56(%rbp), %rdi
	cqto
	idivq	%rdi
	subq	%rax, %rcx
	movq	-64(%rbp), %rax
	movq	-48(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rcx
	movq	-64(%rbp), %rax
	cqto
	idivq	-40(%rbp)
	addq	%rax, %rcx
	movq	-72(%rbp), %rax
	leaq	-1(%rax), %rsi
	movq	-72(%rbp), %rax
	subq	$1, %rax
	movq	-56(%rbp), %rdi
	cqto
	idivq	%rdi
	subq	%rax, %rsi
	movq	-72(%rbp), %rax
	subq	$1, %rax
	movq	-48(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rsi
	movq	-72(%rbp), %rax
	subq	$1, %rax
	cqto
	idivq	-40(%rbp)
	leaq	(%rsi,%rax), %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	movq	-8(%rbp), %rbx
	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:
