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>
#define OPERATOR_PLUS -1
#define OPERATOR_ASTERISK -2

/* 演算子の優先度を指定して計算式を計算する */
int calculate(const int* expression, int length, int plusPriority, int asteriskPriority) {
	int e[17];
	int i, j, p;
	for (i = 0; i < length; i++) e[i] = expression[i];

	/* 計算 */
	for (p = 0; p < 2; p++) {
		for (i = 0; i < length - 2; i++) {
			int flag = 0; /* 演算が行われたか */
			if (p == plusPriority && e[i+1] == OPERATOR_PLUS) {
				e[i] += e[i+2];
				flag = 1;
			} else if (p == asteriskPriority && e[i+1] == OPERATOR_ASTERISK) {
				e[i] *= e[i+2];
				flag = 1;
			}
			/* 処理を終えた計算式を消去して詰める */
			if (flag) {
				for (j = i + 1; j < length - 2; j++) {
					e[j] = e[j+2];
				}
				length -= 2;
				i--;
			}
		}
	}

	return e[0];
}

int main(void) {
	int expression[17];
	int length = 0;
	int answer;
	int m, l;
	char c;

	/* 計算式を読み込む */
	while (scanf("%1[0-9+*]", &c) == 1) {
		if (c == '+') expression[length++] = OPERATOR_PLUS;
		else if (c == '*') expression[length++] = OPERATOR_ASTERISK;
		else if (c >= '0' && c <= '9') expression[length++] = c - '0';
	}
	/* 計算結果を読み込む */
	scanf("%d", &answer);

	/* 各演算規則で実際に計算する */
	m = calculate(expression, length, 1, 0);
	l = calculate(expression, length, 0, 0);

	/* 出力 */
	if (answer == m && answer == l) c = 'U';
	else if (answer == m) c = 'M';
	else if (answer == l) c = 'L';
	else c = 'I';
	printf("%c\n", c);

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	calculate
	.type	calculate, @function
calculate:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%rdi, -104(%rbp)
	movl	%esi, -108(%rbp)
	movl	%edx, -112(%rbp)
	movl	%ecx, -116(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -96(%rbp)
	jmp	.L2
.L3:
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-104(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -96(%rbp)
.L2:
	movl	-96(%rbp), %eax
	cmpl	-108(%rbp), %eax
	jl	.L3
	movl	$0, -88(%rbp)
	jmp	.L4
.L12:
	movl	$0, -96(%rbp)
	jmp	.L5
.L11:
	movl	$0, -84(%rbp)
	movl	-88(%rbp), %eax
	cmpl	-112(%rbp), %eax
	jne	.L6
	movl	-96(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L6
	movl	-96(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	movl	$1, -84(%rbp)
	jmp	.L7
.L6:
	movl	-88(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jne	.L7
	movl	-96(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	cmpl	$-2, %eax
	jne	.L7
	movl	-96(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	imull	%eax, %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	movl	$1, -84(%rbp)
.L7:
	cmpl	$0, -84(%rbp)
	je	.L8
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -92(%rbp)
	jmp	.L9
.L10:
	movl	-92(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-92(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -92(%rbp)
.L9:
	movl	-108(%rbp), %eax
	subl	$2, %eax
	cmpl	%eax, -92(%rbp)
	jl	.L10
	subl	$2, -108(%rbp)
	subl	$1, -96(%rbp)
.L8:
	addl	$1, -96(%rbp)
.L5:
	movl	-108(%rbp), %eax
	subl	$2, %eax
	cmpl	%eax, -96(%rbp)
	jl	.L11
	addl	$1, -88(%rbp)
.L4:
	cmpl	$1, -88(%rbp)
	jle	.L12
	movl	-80(%rbp), %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calculate, .-calculate
	.section	.rodata
.LC0:
	.string	"%1[0-9+*]"
.LC1:
	.string	"%d"
.LC2:
	.string	"%c\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
	subq	$112, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -92(%rbp)
	jmp	.L16
.L19:
	movzbl	-97(%rbp), %eax
	cmpb	$43, %al
	jne	.L17
	movl	-92(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -92(%rbp)
	cltq
	movl	$-1, -80(%rbp,%rax,4)
	jmp	.L16
.L17:
	movzbl	-97(%rbp), %eax
	cmpb	$42, %al
	jne	.L18
	movl	-92(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -92(%rbp)
	cltq
	movl	$-2, -80(%rbp,%rax,4)
	jmp	.L16
.L18:
	movzbl	-97(%rbp), %eax
	cmpb	$47, %al
	jle	.L16
	movzbl	-97(%rbp), %eax
	cmpb	$57, %al
	jg	.L16
	movzbl	-97(%rbp), %eax
	movsbl	%al, %ecx
	movl	-92(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -92(%rbp)
	leal	-48(%rcx), %edx
	cltq
	movl	%edx, -80(%rbp,%rax,4)
.L16:
	leaq	-97(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L19
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %esi
	leaq	-80(%rbp), %rax
	movl	$0, %ecx
	movl	$1, %edx
	movq	%rax, %rdi
	call	calculate
	movl	%eax, -88(%rbp)
	movl	-92(%rbp), %esi
	leaq	-80(%rbp), %rax
	movl	$0, %ecx
	movl	$0, %edx
	movq	%rax, %rdi
	call	calculate
	movl	%eax, -84(%rbp)
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jne	.L20
	movl	-96(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jne	.L20
	movb	$85, -97(%rbp)
	jmp	.L21
.L20:
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jne	.L22
	movb	$77, -97(%rbp)
	jmp	.L21
.L22:
	movl	-96(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jne	.L23
	movb	$76, -97(%rbp)
	jmp	.L21
.L23:
	movb	$73, -97(%rbp)
.L21:
	movzbl	-97(%rbp), %eax
	movsbl	%al, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	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	calculate
	.type	calculate, @function
calculate:
.LFB23:
	.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
	movl	%ecx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edx, %r13d
	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
	movl	%esi, %ebx
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	testl	%esi, %esi
	jle	.L4
	movslq	%esi, %rdx
	movq	%rsp, %r8
	movq	%rdi, %rsi
	salq	$2, %rdx
	movq	%r8, %rdi
	call	memcpy@PLT
.L4:
	leal	-2(%rbx), %r12d
	xorl	%ebp, %ebp
	movq	%rsp, %r15
	testl	%r12d, %r12d
	jle	.L12
.L15:
	xorl	%ebx, %ebx
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L5:
	cmpl	%ebp, %r14d
	je	.L21
.L7:
	cmpl	%eax, %r12d
	jle	.L22
.L14:
	movl	%eax, %ebx
.L10:
	leal	1(%rbx), %eax
	cmpl	%ebp, %r13d
	jne	.L5
	movslq	%eax, %rdx
	cmpl	$-1, (%rsp,%rdx,4)
	jne	.L5
	leal	2(%rbx), %edi
	movslq	%ebx, %rsi
	movslq	%edi, %rdi
	movl	(%rsp,%rsi,4), %ecx
	addl	(%rsp,%rdi,4), %ecx
.L6:
	movl	%ecx, (%rsp,%rsi,4)
	cmpl	%eax, %r12d
	jle	.L9
	leal	-2(%r12), %eax
	salq	$2, %rdx
	subl	%ebx, %eax
	leaq	8(%r15,%rdx), %rsi
	leaq	(%r15,%rdx), %rdi
	leaq	4(,%rax,4), %r8
	movq	%r8, %rdx
	call	memmove@PLT
.L9:
	movl	%ebx, %eax
	subl	$2, %r12d
	cmpl	%eax, %r12d
	jg	.L14
	.p2align 4,,10
	.p2align 3
.L22:
	cmpl	$1, %ebp
	je	.L12
	movl	$1, %ebp
	testl	%r12d, %r12d
	jg	.L15
	.p2align 4,,10
	.p2align 3
.L12:
	movl	(%rsp), %eax
	movq	72(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L23
	addq	$88, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	movslq	%eax, %rdx
	cmpl	$-2, (%rsp,%rdx,4)
	jne	.L7
	leal	2(%rbx), %ecx
	movslq	%ebx, %rsi
	movslq	%ecx, %rcx
	movl	(%rsp,%rcx,4), %ecx
	imull	(%rsp,%rsi,4), %ecx
	jmp	.L6
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	calculate, .-calculate
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%1[0-9+*]"
.LC1:
	.string	"%d"
.LC2:
	.string	"%c\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	.LC0(%rip), %rbx
	subq	$96, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	11(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L25:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L36
	movzbl	11(%rsp), %eax
	cmpb	$43, %al
	je	.L37
	cmpb	$42, %al
	je	.L38
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L25
	movslq	%ebp, %rdx
	movsbl	%al, %eax
	addl	$1, %ebp
	movl	%eax, 16(%rsp,%rdx,4)
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L37:
	movslq	%ebp, %rax
	addl	$1, %ebp
	movl	$-1, 16(%rsp,%rax,4)
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L38:
	movslq	%ebp, %rax
	addl	$1, %ebp
	movl	$-2, 16(%rsp,%rax,4)
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L36:
	leaq	12(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	16(%rsp), %r12
	xorl	%ecx, %ecx
	movl	%ebp, %esi
	movl	$1, %edx
	movq	%r12, %rdi
	call	calculate
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	movl	%ebp, %esi
	movq	%r12, %rdi
	movl	%eax, %ebx
	call	calculate
	movl	12(%rsp), %edx
	cmpl	%ebx, %edx
	je	.L39
	cmpl	%eax, %edx
	sete	%dl
	leal	73(%rdx,%rdx,2), %edx
.L31:
	movb	%dl, 11(%rsp)
	xorl	%eax, %eax
	movsbl	%dl, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	addq	$96, %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
.L39:
	.cfi_restore_state
	cmpl	%eax, %edx
	sete	%dl
	leal	77(,%rdx,8), %edx
	jmp	.L31
.L40:
	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	calculate
	.type	calculate, @function
calculate:
.LFB23:
	.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
	movl	%ecx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edx, %r13d
	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
	movl	%esi, %ebx
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	testl	%esi, %esi
	jle	.L4
	movslq	%esi, %rdx
	movq	%rsp, %r8
	movq	%rdi, %rsi
	salq	$2, %rdx
	movq	%r8, %rdi
	call	memcpy@PLT
.L4:
	leal	-2(%rbx), %r12d
	xorl	%ebp, %ebp
	movq	%rsp, %r15
	testl	%r12d, %r12d
	jle	.L12
.L15:
	xorl	%ebx, %ebx
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L5:
	cmpl	%ebp, %r14d
	je	.L21
.L7:
	cmpl	%eax, %r12d
	jle	.L22
.L14:
	movl	%eax, %ebx
.L10:
	leal	1(%rbx), %eax
	cmpl	%ebp, %r13d
	jne	.L5
	movslq	%eax, %rdx
	cmpl	$-1, (%rsp,%rdx,4)
	jne	.L5
	leal	2(%rbx), %edi
	movslq	%ebx, %rsi
	movslq	%edi, %rdi
	movl	(%rsp,%rsi,4), %ecx
	addl	(%rsp,%rdi,4), %ecx
.L6:
	movl	%ecx, (%rsp,%rsi,4)
	cmpl	%eax, %r12d
	jle	.L9
	leal	-2(%r12), %eax
	salq	$2, %rdx
	subl	%ebx, %eax
	leaq	8(%r15,%rdx), %rsi
	leaq	(%r15,%rdx), %rdi
	leaq	4(,%rax,4), %r8
	movq	%r8, %rdx
	call	memmove@PLT
.L9:
	movl	%ebx, %eax
	subl	$2, %r12d
	cmpl	%eax, %r12d
	jg	.L14
	.p2align 4,,10
	.p2align 3
.L22:
	cmpl	$1, %ebp
	je	.L12
	movl	$1, %ebp
	testl	%r12d, %r12d
	jg	.L15
	.p2align 4,,10
	.p2align 3
.L12:
	movl	(%rsp), %eax
	movq	72(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L23
	addq	$88, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	movslq	%eax, %rdx
	cmpl	$-2, (%rsp,%rdx,4)
	jne	.L7
	leal	2(%rbx), %ecx
	movslq	%ebx, %rsi
	movslq	%ecx, %rcx
	movl	(%rsp,%rcx,4), %ecx
	imull	(%rsp,%rsi,4), %ecx
	jmp	.L6
.L23:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	calculate, .-calculate
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%1[0-9+*]"
.LC1:
	.string	"%d"
.LC2:
	.string	"%c\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.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
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	.LC0(%rip), %rbx
	subq	$96, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	11(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L25:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	jne	.L36
	movzbl	11(%rsp), %eax
	cmpb	$43, %al
	je	.L37
	cmpb	$42, %al
	je	.L38
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L25
	movslq	%ebp, %rdx
	movsbl	%al, %eax
	addl	$1, %ebp
	movl	%eax, 16(%rsp,%rdx,4)
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L37:
	movslq	%ebp, %rax
	addl	$1, %ebp
	movl	$-1, 16(%rsp,%rax,4)
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L38:
	movslq	%ebp, %rax
	addl	$1, %ebp
	movl	$-2, 16(%rsp,%rax,4)
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L36:
	leaq	12(%rsp), %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	16(%rsp), %r12
	xorl	%ecx, %ecx
	movl	%ebp, %esi
	movl	$1, %edx
	movq	%r12, %rdi
	call	calculate
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	movl	%ebp, %esi
	movq	%r12, %rdi
	movl	%eax, %ebx
	call	calculate
	movl	12(%rsp), %edx
	cmpl	%ebx, %edx
	je	.L39
	cmpl	%eax, %edx
	sete	%dl
	leal	73(%rdx,%rdx,2), %edx
.L31:
	movb	%dl, 11(%rsp)
	xorl	%eax, %eax
	movsbl	%dl, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	addq	$96, %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
.L39:
	.cfi_restore_state
	cmpl	%eax, %edx
	sete	%dl
	leal	77(,%rdx,8), %edx
	jmp	.L31
.L40:
	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>
#define OPERATOR_PLUS -1
#define OPERATOR_ASTERISK -2

/* 演算子の優先度を指定して計算式を計算する */
int calculate(const int* expression, int length, int plusPriority, int asteriskPriority) {
	int e[17];
	int i, j, p;
	for (i = 0; i < length; i++) e[i] = expression[i];

	/* 計算 */
	for (p = 0; p < 2; p++) {
		for (i = 0; i < length - 2; i++) {
			int flag = 0; /* 演算が行われたか */
			if (p == plusPriority && e[i+1] == OPERATOR_PLUS) {
				e[i] += e[i+2];
				flag = 1;
			} else if (p == asteriskPriority && e[i+1] == OPERATOR_ASTERISK) {
				e[i] *= e[i+2];
				flag = 1;
			}
			/* 処理を終えた計算式を消去して詰める */
			if (flag) {
				for (j = i + 1; j < length - 2; j++) {
					e[j] = e[j+2];
				}
				length -= 2;
				i--;
			}
		}
	}

	return e[0];
}

int main(void) {
	int expression[17];
	int length = 0;
	int answer;
	int m, l;
	char c;

	/* 計算式を読み込む */
	while (scanf("%1[0-9+*]", &c) == 1) {
		if (c == '+') expression[length++] = OPERATOR_PLUS;
		else if (c == '*') expression[length++] = OPERATOR_ASTERISK;
		else if (c >= '0' && c <= '9') expression[length++] = c - '0';
	}
	/* 計算結果を読み込む */
	scanf("%d", &answer);

	/* 各演算規則で実際に計算する */
	m = calculate(expression, length, 1, 0);
	l = calculate(expression, length, 0, 0);

	/* 出力 */
	if (answer == m && answer == l) c = 'U';
	else if (answer == m) c = 'M';
	else if (answer == l) c = 'L';
	else c = 'I';
	printf("%c\n", c);

	return 0;
}
1+2*3+4
9
 0+1*3+4
7
 4+3*0+4
8
 3*1+0*4
12
 1+2*3+4
7
 0+2*3+4
7
 1+2+3+4
11
 0+2*3+4
9
 1+2*3+4
14
 4+3+2+1
11

I
 U
 M
 L
 I
 I
 I
 I
 I
 I

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>
#define OPERATOR_PLUS -1
#define OPERATOR_ASTERISK -2

/* 演算子の優先度を指定して計算式を計算する */
int calculate(const int* expression, int length, int plusPriority, int asteriskPriority) {
	int e[17];
	int i, j, p;
	for (i = 0; i < length; i++) e[i] = expression[i];

	/* 計算 */
	for (p = 0; p < 2; p++) {
		for (i = 0; i < length - 2; i++) {
			int flag = 0; /* 演算が行われたか */
			if (p == plusPriority && e[i+1] == OPERATOR_PLUS) {
				e[i] += e[i+2];
				flag = 1;
			} else if (p == asteriskPriority && e[i+1] == OPERATOR_ASTERISK) {
				e[i] *= e[i+2];
				flag = 1;
			}
			/* 処理を終えた計算式を消去して詰める */
			if (flag) {
				for (j = i + 1; j < length - 2; j++) {
					e[j] = e[j+2];
				}
				length -= 2;
				i--;
			}
		}
	}

	return e[0];
}

int main(void) {
	int expression[17];
	int length = 0;
	int answer;
	int m, l;
	char c;

	/* 計算式を読み込む */
	while (scanf("%1[0-9+*]", &c) == 1) {
		if (c == '+') expression[length++] = OPERATOR_PLUS;
		else if (c == '*') expression[length++] = OPERATOR_ASTERISK;
		else if (c >= '0' && c <= '9') expression[length++] = c - '0';
	}
	/* 計算結果を読み込む */
	scanf("%d", &answer);

	/* 各演算規則で実際に計算する */
	m = calculate(expression, length, 1, 0);
	l = calculate(expression, length, 0, 0);

	/* 出力 */
	if (answer == m && answer == l) c = 'U';
	else if (answer == m) c = 'M';
	else if (answer == l) c = 'L';
	else c = 'I';
	printf("%c\n", c);

	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	calculate
	.type	calculate, @function
calculate:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%rdi, -104(%rbp)
	movl	%esi, -108(%rbp)
	movl	%edx, -112(%rbp)
	movl	%ecx, -116(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -96(%rbp)
	jmp	.L2
.L3:
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-104(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -96(%rbp)
.L2:
	movl	-96(%rbp), %eax
	cmpl	-108(%rbp), %eax
	jl	.L3
	movl	$0, -88(%rbp)
	jmp	.L4
.L12:
	movl	$0, -96(%rbp)
	jmp	.L5
.L11:
	movl	$0, -84(%rbp)
	movl	-88(%rbp), %eax
	cmpl	-112(%rbp), %eax
	jne	.L6
	movl	-96(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L6
	movl	-96(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	movl	$1, -84(%rbp)
	jmp	.L7
.L6:
	movl	-88(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jne	.L7
	movl	-96(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	cmpl	$-2, %eax
	jne	.L7
	movl	-96(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	imull	%eax, %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	movl	$1, -84(%rbp)
.L7:
	cmpl	$0, -84(%rbp)
	je	.L8
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -92(%rbp)
	jmp	.L9
.L10:
	movl	-92(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-92(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -92(%rbp)
.L9:
	movl	-108(%rbp), %eax
	subl	$2, %eax
	cmpl	%eax, -92(%rbp)
	jl	.L10
	subl	$2, -108(%rbp)
	subl	$1, -96(%rbp)
.L8:
	addl	$1, -96(%rbp)
.L5:
	movl	-108(%rbp), %eax
	subl	$2, %eax
	cmpl	%eax, -96(%rbp)
	jl	.L11
	addl	$1, -88(%rbp)
.L4:
	cmpl	$1, -88(%rbp)
	jle	.L12
	movl	-80(%rbp), %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calculate, .-calculate
	.section	.rodata
.LC0:
	.string	"%1[0-9+*]"
.LC1:
	.string	"%d"
.LC2:
	.string	"%c\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
	subq	$112, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -92(%rbp)
	jmp	.L16
.L19:
	movzbl	-97(%rbp), %eax
	cmpb	$43, %al
	jne	.L17
	movl	-92(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -92(%rbp)
	cltq
	movl	$-1, -80(%rbp,%rax,4)
	jmp	.L16
.L17:
	movzbl	-97(%rbp), %eax
	cmpb	$42, %al
	jne	.L18
	movl	-92(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -92(%rbp)
	cltq
	movl	$-2, -80(%rbp,%rax,4)
	jmp	.L16
.L18:
	movzbl	-97(%rbp), %eax
	cmpb	$47, %al
	jle	.L16
	movzbl	-97(%rbp), %eax
	cmpb	$57, %al
	jg	.L16
	movzbl	-97(%rbp), %eax
	movsbl	%al, %ecx
	movl	-92(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -92(%rbp)
	leal	-48(%rcx), %edx
	cltq
	movl	%edx, -80(%rbp,%rax,4)
.L16:
	leaq	-97(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L19
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %esi
	leaq	-80(%rbp), %rax
	movl	$0, %ecx
	movl	$1, %edx
	movq	%rax, %rdi
	call	calculate
	movl	%eax, -88(%rbp)
	movl	-92(%rbp), %esi
	leaq	-80(%rbp), %rax
	movl	$0, %ecx
	movl	$0, %edx
	movq	%rax, %rdi
	call	calculate
	movl	%eax, -84(%rbp)
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jne	.L20
	movl	-96(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jne	.L20
	movb	$85, -97(%rbp)
	jmp	.L21
.L20:
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jne	.L22
	movb	$77, -97(%rbp)
	jmp	.L21
.L22:
	movl	-96(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jne	.L23
	movb	$76, -97(%rbp)
	jmp	.L21
.L23:
	movb	$73, -97(%rbp)
.L21:
	movzbl	-97(%rbp), %eax
	movsbl	%al, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	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	calculate
	.type	calculate, @function
calculate:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%rdi, -104(%rbp)
	movl	%esi, -108(%rbp)
	movl	%edx, -112(%rbp)
	movl	%ecx, -116(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -96(%rbp)
	jmp	.L2
.L3:
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-104(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -96(%rbp)
.L2:
	movl	-96(%rbp), %eax
	cmpl	-108(%rbp), %eax
	jl	.L3
	movl	$0, -88(%rbp)
	jmp	.L4
.L12:
	movl	$0, -96(%rbp)
	jmp	.L5
.L11:
	movl	$0, -84(%rbp)
	movl	-88(%rbp), %eax
	cmpl	-112(%rbp), %eax
	jne	.L6
	movl	-96(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L6
	movl	-96(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	movl	$1, -84(%rbp)
	jmp	.L7
.L6:
	movl	-88(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jne	.L7
	movl	-96(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	cmpl	$-2, %eax
	jne	.L7
	movl	-96(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	imull	%eax, %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	movl	$1, -84(%rbp)
.L7:
	cmpl	$0, -84(%rbp)
	je	.L8
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -92(%rbp)
	jmp	.L9
.L10:
	movl	-92(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-92(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -92(%rbp)
.L9:
	movl	-108(%rbp), %eax
	subl	$2, %eax
	cmpl	%eax, -92(%rbp)
	jl	.L10
	subl	$2, -108(%rbp)
	subl	$1, -96(%rbp)
.L8:
	addl	$1, -96(%rbp)
.L5:
	movl	-108(%rbp), %eax
	subl	$2, %eax
	cmpl	%eax, -96(%rbp)
	jl	.L11
	addl	$1, -88(%rbp)
.L4:
	cmpl	$1, -88(%rbp)
	jle	.L12
	movl	-80(%rbp), %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calculate, .-calculate
	.section	.rodata
.LC0:
	.string	"%1[0-9+*]"
.LC1:
	.string	"%d"
.LC2:
	.string	"%c\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
	subq	$112, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -92(%rbp)
	jmp	.L16
.L19:
	movzbl	-97(%rbp), %eax
	cmpb	$43, %al
	jne	.L17
	movl	-92(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -92(%rbp)
	cltq
	movl	$-1, -80(%rbp,%rax,4)
	jmp	.L16
.L17:
	movzbl	-97(%rbp), %eax
	cmpb	$42, %al
	jne	.L18
	movl	-92(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -92(%rbp)
	cltq
	movl	$-2, -80(%rbp,%rax,4)
	jmp	.L16
.L18:
	movzbl	-97(%rbp), %eax
	cmpb	$47, %al
	jle	.L16
	movzbl	-97(%rbp), %eax
	cmpb	$57, %al
	jg	.L16
	movzbl	-97(%rbp), %eax
	movsbl	%al, %ecx
	movl	-92(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -92(%rbp)
	leal	-48(%rcx), %edx
	cltq
	movl	%edx, -80(%rbp,%rax,4)
.L16:
	leaq	-97(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L19
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %esi
	leaq	-80(%rbp), %rax
	movl	$0, %ecx
	movl	$1, %edx
	movq	%rax, %rdi
	call	calculate
	movl	%eax, -88(%rbp)
	movl	-92(%rbp), %esi
	leaq	-80(%rbp), %rax
	movl	$0, %ecx
	movl	$0, %edx
	movq	%rax, %rdi
	call	calculate
	movl	%eax, -84(%rbp)
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jne	.L20
	movl	-96(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jne	.L20
	movb	$85, -97(%rbp)
	jmp	.L21
.L20:
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jne	.L22
	movb	$77, -97(%rbp)
	jmp	.L21
.L22:
	movl	-96(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jne	.L23
	movb	$76, -97(%rbp)
	jmp	.L21
.L23:
	movb	$73, -97(%rbp)
.L21:
	movzbl	-97(%rbp), %eax
	movsbl	%al, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	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:
