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>

typedef long long ll;

ll gcd (ll x, ll y)
{
  if (y == 0)
    return x;
  else
    return gcd (y, x % y);
}

int main(void)
{
  ll a, b, c, d, lcm;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
  
  lcm = c*d/gcd(c, d);
  
  printf("%lld", b-a+1 - (b / c - (a-1) / c + b / d - (a-1) / d - b / lcm + (a-1) / lcm));
    
  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
	.section	.rodata
.LC0:
	.string	"%lld%lld%lld%lld"
.LC1:
	.string	"%lld"
	.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	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rsi
	leaq	-48(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-48(%rbp), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rbx
	imulq	%rax, %rbx
	movq	-40(%rbp), %rdx
	movq	-48(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rdi
	movq	%rbx, %rax
	cqto
	idivq	%rdi
	movq	%rax, -32(%rbp)
	movq	-56(%rbp), %rax
	movq	-64(%rbp), %rdx
	subq	%rdx, %rax
	leaq	1(%rax), %rcx
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdi
	cqto
	idivq	%rdi
	movq	%rax, %rsi
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	-48(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rsi
	movq	-56(%rbp), %rax
	movq	-40(%rbp), %rdi
	cqto
	idivq	%rdi
	addq	%rax, %rsi
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	-40(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rsi
	movq	-56(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	subq	%rax, %rsi
	movq	-64(%rbp), %rax
	subq	$1, %rax
	cqto
	idivq	-32(%rbp)
	leaq	(%rsi,%rax), %rdx
	movq	%rcx, %rax
	subq	%rdx, %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	.L6
	call	__stack_chk_fail@PLT
.L6:
	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, %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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld%lld%lld%lld"
.LC1:
	.string	"%lld"
	.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	32(%rsp), %r8
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	24(%rsp), %r11
	movq	32(%rsp), %r9
	movq	%r11, %r8
	movq	%r11, %rax
	movq	%r9, %rcx
	imulq	%r9, %r8
	testq	%r9, %r9
	jne	.L13
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%rdx, %rcx
.L13:
	cqto
	idivq	%rcx
	movq	%rcx, %rax
	testq	%rdx, %rdx
	jne	.L25
.L14:
	movq	%r8, %rax
	movq	16(%rsp), %rsi
	cqto
	idivq	%rcx
	movq	%rsi, %r10
	movq	%rax, %r8
	movq	8(%rsp), %rax
	leaq	-1(%rax), %rdi
	subq	%rax, %r10
	movq	%rsi, %rax
	cqto
	addq	$1, %r10
	idivq	%r11
	movq	%rax, %rcx
	movq	%rdi, %rax
	cqto
	idivq	%r11
	subq	%rax, %rcx
	movq	%rsi, %rax
	cqto
	idivq	%r9
	addq	%rax, %rcx
	movq	%rdi, %rax
	cqto
	idivq	%r9
	subq	%rax, %rcx
	movq	%rsi, %rax
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%r8
	subq	%rax, %rcx
	movq	%rdi, %rax
	movl	$1, %edi
	cqto
	idivq	%r8
	movq	%r10, %rdx
	addq	%rax, %rcx
	xorl	%eax, %eax
	subq	%rcx, %rdx
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L24:
	.cfi_restore_state
	movq	%r11, %rcx
	jmp	.L14
.L26:
	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, %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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld%lld%lld%lld"
.LC1:
	.string	"%lld"
	.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	32(%rsp), %r8
	leaq	16(%rsp), %rdx
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	24(%rsp), %r11
	movq	32(%rsp), %r9
	movq	%r11, %r8
	movq	%r11, %rax
	movq	%r9, %rcx
	imulq	%r9, %r8
	testq	%r9, %r9
	jne	.L13
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%rdx, %rcx
.L13:
	cqto
	idivq	%rcx
	movq	%rcx, %rax
	testq	%rdx, %rdx
	jne	.L25
.L14:
	movq	%r8, %rax
	movq	16(%rsp), %rsi
	cqto
	idivq	%rcx
	movq	%rsi, %r10
	movq	%rax, %r8
	movq	8(%rsp), %rax
	leaq	-1(%rax), %rdi
	subq	%rax, %r10
	movq	%rsi, %rax
	cqto
	addq	$1, %r10
	idivq	%r11
	movq	%rax, %rcx
	movq	%rdi, %rax
	cqto
	idivq	%r11
	subq	%rax, %rcx
	movq	%rsi, %rax
	cqto
	idivq	%r9
	addq	%rax, %rcx
	movq	%rdi, %rax
	cqto
	idivq	%r9
	subq	%rax, %rcx
	movq	%rsi, %rax
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%r8
	subq	%rax, %rcx
	movq	%rdi, %rax
	movl	$1, %edi
	cqto
	idivq	%r8
	movq	%r10, %rdx
	addq	%rax, %rcx
	xorl	%eax, %eax
	subq	%rcx, %rdx
	call	__printf_chk@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L24:
	.cfi_restore_state
	movq	%r11, %rcx
	jmp	.L14
.L26:
	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>

typedef long long ll;

ll gcd (ll x, ll y)
{
  if (y == 0)
    return x;
  else
    return gcd (y, x % y);
}

int main(void)
{
  ll a, b, c, d, lcm;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
  
  lcm = c*d/gcd(c, d);
  
  printf("%lld", b-a+1 - (b / c - (a-1) / c + b / d - (a-1) / d - b / lcm + (a-1) / lcm));
    
  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>

typedef long long ll;

ll gcd (ll x, ll y)
{
  if (y == 0)
    return x;
  else
    return gcd (y, x % y);
}

int main(void)
{
  ll a, b, c, d, lcm;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
  
  lcm = c*d/gcd(c, d);
  
  printf("%lld", b-a+1 - (b / c - (a-1) / c + b / d - (a-1) / d - b / lcm + (a-1) / lcm));
    
  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
	.section	.rodata
.LC0:
	.string	"%lld%lld%lld%lld"
.LC1:
	.string	"%lld"
	.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	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rsi
	leaq	-48(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-48(%rbp), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rbx
	imulq	%rax, %rbx
	movq	-40(%rbp), %rdx
	movq	-48(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rdi
	movq	%rbx, %rax
	cqto
	idivq	%rdi
	movq	%rax, -32(%rbp)
	movq	-56(%rbp), %rax
	movq	-64(%rbp), %rdx
	subq	%rdx, %rax
	leaq	1(%rax), %rcx
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdi
	cqto
	idivq	%rdi
	movq	%rax, %rsi
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	-48(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rsi
	movq	-56(%rbp), %rax
	movq	-40(%rbp), %rdi
	cqto
	idivq	%rdi
	addq	%rax, %rsi
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	-40(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rsi
	movq	-56(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	subq	%rax, %rsi
	movq	-64(%rbp), %rax
	subq	$1, %rax
	cqto
	idivq	-32(%rbp)
	leaq	(%rsi,%rax), %rdx
	movq	%rcx, %rax
	subq	%rdx, %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	.L6
	call	__stack_chk_fail@PLT
.L6:
	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
	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
	.section	.rodata
.LC0:
	.string	"%lld%lld%lld%lld"
.LC1:
	.string	"%lld"
	.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	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rsi
	leaq	-48(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-48(%rbp), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rbx
	imulq	%rax, %rbx
	movq	-40(%rbp), %rdx
	movq	-48(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	gcd
	movq	%rax, %rdi
	movq	%rbx, %rax
	cqto
	idivq	%rdi
	movq	%rax, -32(%rbp)
	movq	-56(%rbp), %rax
	movq	-64(%rbp), %rdx
	subq	%rdx, %rax
	leaq	1(%rax), %rcx
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdi
	cqto
	idivq	%rdi
	movq	%rax, %rsi
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	-48(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rsi
	movq	-56(%rbp), %rax
	movq	-40(%rbp), %rdi
	cqto
	idivq	%rdi
	addq	%rax, %rsi
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	-40(%rbp), %rbx
	cqto
	idivq	%rbx
	subq	%rax, %rsi
	movq	-56(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	subq	%rax, %rsi
	movq	-64(%rbp), %rax
	subq	$1, %rax
	cqto
	idivq	-32(%rbp)
	leaq	(%rsi,%rax), %rdx
	movq	%rcx, %rax
	subq	%rdx, %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	.L6
	call	__stack_chk_fail@PLT
.L6:
	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:
