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

#define min(a, b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 50
int main(void) {
  char line[BUF_SIZE];
  FILE *fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int a, b, ab;
  int x, y;
  sscanf(line, "%d %d %d %d %d", &a, &b, &ab, &x, &y);
  int cost;
  if(ab*2 >= a + b) {
    cost = a*x + b*y;
  } else {
    int ma = min(ab*2, a);
    int mb = min(ab*2, b);
    if(x > y) {
      cost = y*ab*2 + (x-y)*ma;
    } else {
      cost = x*ab*2 + (y - x)*mb;
    }
  }
  printf("%d\n", cost);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$112, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rax
	movq	%rax, -72(%rbp)
	movq	-72(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movl	$50, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$0, %eax
	jmp	.L7
.L2:
	leaq	-92(%rbp), %r8
	leaq	-96(%rbp), %rdi
	leaq	-100(%rbp), %rcx
	leaq	-104(%rbp), %rdx
	leaq	-64(%rbp), %rax
	subq	$8, %rsp
	leaq	-88(%rbp), %rsi
	pushq	%rsi
	movq	%r8, %r9
	movq	%rdi, %r8
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	addq	$16, %rsp
	movl	-96(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-104(%rbp), %ecx
	movl	-100(%rbp), %eax
	addl	%ecx, %eax
	cmpl	%eax, %edx
	jl	.L4
	movl	-104(%rbp), %edx
	movl	-92(%rbp), %eax
	movl	%edx, %ecx
	imull	%eax, %ecx
	movl	-100(%rbp), %edx
	movl	-88(%rbp), %eax
	imull	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, -84(%rbp)
	jmp	.L5
.L4:
	movl	-96(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-104(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -80(%rbp)
	movl	-96(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-100(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -76(%rbp)
	movl	-92(%rbp), %edx
	movl	-88(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L6
	movl	-88(%rbp), %edx
	movl	-96(%rbp), %eax
	imull	%edx, %eax
	leal	(%rax,%rax), %ecx
	movl	-92(%rbp), %eax
	movl	-88(%rbp), %edx
	subl	%edx, %eax
	imull	-80(%rbp), %eax
	addl	%ecx, %eax
	movl	%eax, -84(%rbp)
	jmp	.L5
.L6:
	movl	-92(%rbp), %edx
	movl	-96(%rbp), %eax
	imull	%edx, %eax
	leal	(%rax,%rax), %ecx
	movl	-88(%rbp), %eax
	movl	-92(%rbp), %edx
	subl	%edx, %eax
	imull	-76(%rbp), %eax
	addl	%ecx, %eax
	movl	%eax, -84(%rbp)
.L5:
	movl	-84(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L7:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	$50, %esi
	subq	$96, %rsp
	.cfi_def_cfa_offset 112
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rbp
	movq	%rbp, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L2
	leaq	16(%rsp), %rcx
	leaq	12(%rsp), %rdx
	subq	$8, %rsp
	.cfi_def_cfa_offset 120
	movq	%rbp, %rdi
	leaq	36(%rsp), %rax
	leaq	.LC0(%rip), %rsi
	pushq	%rax
	.cfi_def_cfa_offset 128
	xorl	%eax, %eax
	leaq	40(%rsp), %r9
	leaq	36(%rsp), %r8
	call	__isoc99_sscanf@PLT
	movl	36(%rsp), %esi
	movl	28(%rsp), %edx
	movl	32(%rsp), %eax
	popq	%r8
	.cfi_def_cfa_offset 120
	leal	(%rsi,%rsi), %ecx
	popq	%r9
	.cfi_def_cfa_offset 112
	leal	(%rdx,%rax), %edi
	cmpl	%edi, %ecx
	jl	.L3
	imull	24(%rsp), %edx
	imull	28(%rsp), %eax
	addl	%eax, %edx
.L4:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L2:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L12
	addq	$96, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L3:
	.cfi_restore_state
	movl	24(%rsp), %r8d
	movl	28(%rsp), %edi
	cmpl	%edi, %r8d
	jle	.L5
	subl	%edi, %r8d
	cmpl	%edx, %ecx
	cmovg	%edx, %ecx
	imull	%edi, %esi
	imull	%ecx, %r8d
	leal	(%r8,%rsi,2), %edx
	jmp	.L4
.L5:
	subl	%r8d, %edi
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	imull	%r8d, %esi
	imull	%ecx, %edi
	leal	(%rdi,%rsi,2), %edx
	jmp	.L4
.L12:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	$50, %esi
	subq	$96, %rsp
	.cfi_def_cfa_offset 112
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rbp
	movq	%rbp, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L2
	leaq	16(%rsp), %rcx
	leaq	12(%rsp), %rdx
	subq	$8, %rsp
	.cfi_def_cfa_offset 120
	movq	%rbp, %rdi
	leaq	36(%rsp), %rax
	leaq	.LC0(%rip), %rsi
	pushq	%rax
	.cfi_def_cfa_offset 128
	xorl	%eax, %eax
	leaq	40(%rsp), %r9
	leaq	36(%rsp), %r8
	call	__isoc99_sscanf@PLT
	movl	36(%rsp), %esi
	movl	28(%rsp), %edx
	movl	32(%rsp), %eax
	popq	%r8
	.cfi_def_cfa_offset 120
	leal	(%rsi,%rsi), %ecx
	popq	%r9
	.cfi_def_cfa_offset 112
	leal	(%rdx,%rax), %edi
	cmpl	%edi, %ecx
	jl	.L3
	imull	24(%rsp), %edx
	imull	28(%rsp), %eax
	addl	%eax, %edx
.L4:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L2:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L12
	addq	$96, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L3:
	.cfi_restore_state
	movl	24(%rsp), %r8d
	movl	28(%rsp), %edi
	cmpl	%edi, %r8d
	jle	.L5
	subl	%edi, %r8d
	cmpl	%edx, %ecx
	cmovg	%edx, %ecx
	imull	%edi, %esi
	imull	%ecx, %r8d
	leal	(%r8,%rsi,2), %edx
	jmp	.L4
.L5:
	subl	%r8d, %edi
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	imull	%r8d, %esi
	imull	%ecx, %edi
	leal	(%rdi,%rsi,2), %edx
	jmp	.L4
.L12:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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>
#include <stdlib.h>

#define min(a, b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 50
int main(void) {
  char line[BUF_SIZE];
  FILE *fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int a, b, ab;
  int x, y;
  sscanf(line, "%d %d %d %d %d", &a, &b, &ab, &x, &y);
  int cost;
  if(ab*2 >= a + b) {
    cost = a*x + b*y;
  } else {
    int ma = min(ab*2, a);
    int mb = min(ab*2, b);
    if(x > y) {
      cost = y*ab*2 + (x-y)*ma;
    } else {
      cost = x*ab*2 + (y - x)*mb;
    }
  }
  printf("%d\n", cost);

  return 0;
}
1500 2000 1600 3 2

7900

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

#define min(a, b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 50
int main(void) {
  char line[BUF_SIZE];
  FILE *fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int a, b, ab;
  int x, y;
  sscanf(line, "%d %d %d %d %d", &a, &b, &ab, &x, &y);
  int cost;
  if(ab*2 >= a + b) {
    cost = a*x + b*y;
  } else {
    int ma = min(ab*2, a);
    int mb = min(ab*2, b);
    if(x > y) {
      cost = y*ab*2 + (x-y)*ma;
    } else {
      cost = x*ab*2 + (y - x)*mb;
    }
  }
  printf("%d\n", cost);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$112, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rax
	movq	%rax, -72(%rbp)
	movq	-72(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movl	$50, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$0, %eax
	jmp	.L7
.L2:
	leaq	-92(%rbp), %r8
	leaq	-96(%rbp), %rdi
	leaq	-100(%rbp), %rcx
	leaq	-104(%rbp), %rdx
	leaq	-64(%rbp), %rax
	subq	$8, %rsp
	leaq	-88(%rbp), %rsi
	pushq	%rsi
	movq	%r8, %r9
	movq	%rdi, %r8
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	addq	$16, %rsp
	movl	-96(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-104(%rbp), %ecx
	movl	-100(%rbp), %eax
	addl	%ecx, %eax
	cmpl	%eax, %edx
	jl	.L4
	movl	-104(%rbp), %edx
	movl	-92(%rbp), %eax
	movl	%edx, %ecx
	imull	%eax, %ecx
	movl	-100(%rbp), %edx
	movl	-88(%rbp), %eax
	imull	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, -84(%rbp)
	jmp	.L5
.L4:
	movl	-96(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-104(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -80(%rbp)
	movl	-96(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-100(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -76(%rbp)
	movl	-92(%rbp), %edx
	movl	-88(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L6
	movl	-88(%rbp), %edx
	movl	-96(%rbp), %eax
	imull	%edx, %eax
	leal	(%rax,%rax), %ecx
	movl	-92(%rbp), %eax
	movl	-88(%rbp), %edx
	subl	%edx, %eax
	imull	-80(%rbp), %eax
	addl	%ecx, %eax
	movl	%eax, -84(%rbp)
	jmp	.L5
.L6:
	movl	-92(%rbp), %edx
	movl	-96(%rbp), %eax
	imull	%edx, %eax
	leal	(%rax,%rax), %ecx
	movl	-88(%rbp), %eax
	movl	-92(%rbp), %edx
	subl	%edx, %eax
	imull	-76(%rbp), %eax
	addl	%ecx, %eax
	movl	%eax, -84(%rbp)
.L5:
	movl	-84(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L7:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
	.section	.rodata
.LC0:
	.string	"%d %d %d %d %d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$112, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rax
	movq	%rax, -72(%rbp)
	movq	-72(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movl	$50, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$0, %eax
	jmp	.L7
.L2:
	leaq	-92(%rbp), %r8
	leaq	-96(%rbp), %rdi
	leaq	-100(%rbp), %rcx
	leaq	-104(%rbp), %rdx
	leaq	-64(%rbp), %rax
	subq	$8, %rsp
	leaq	-88(%rbp), %rsi
	pushq	%rsi
	movq	%r8, %r9
	movq	%rdi, %r8
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	addq	$16, %rsp
	movl	-96(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-104(%rbp), %ecx
	movl	-100(%rbp), %eax
	addl	%ecx, %eax
	cmpl	%eax, %edx
	jl	.L4
	movl	-104(%rbp), %edx
	movl	-92(%rbp), %eax
	movl	%edx, %ecx
	imull	%eax, %ecx
	movl	-100(%rbp), %edx
	movl	-88(%rbp), %eax
	imull	%edx, %eax
	addl	%ecx, %eax
	movl	%eax, -84(%rbp)
	jmp	.L5
.L4:
	movl	-96(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-104(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -80(%rbp)
	movl	-96(%rbp), %eax
	leal	(%rax,%rax), %edx
	movl	-100(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -76(%rbp)
	movl	-92(%rbp), %edx
	movl	-88(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L6
	movl	-88(%rbp), %edx
	movl	-96(%rbp), %eax
	imull	%edx, %eax
	leal	(%rax,%rax), %ecx
	movl	-92(%rbp), %eax
	movl	-88(%rbp), %edx
	subl	%edx, %eax
	imull	-80(%rbp), %eax
	addl	%ecx, %eax
	movl	%eax, -84(%rbp)
	jmp	.L5
.L6:
	movl	-92(%rbp), %edx
	movl	-96(%rbp), %eax
	imull	%edx, %eax
	leal	(%rax,%rax), %ecx
	movl	-88(%rbp), %eax
	movl	-92(%rbp), %edx
	subl	%edx, %eax
	imull	-76(%rbp), %eax
	addl	%ecx, %eax
	movl	%eax, -84(%rbp)
.L5:
	movl	-84(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L7:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
