Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
main(n,i,d,r){for(;scanf("%d",&n)*n;printf("%d\n",r)){int h[50][32]={0};long long m[50],a=0,b;for(i=n;i--;m[i]=1LL<<i)for(scanf("%d",&r);r--;h[i][d]=1)scanf("%d",&d);for(r=d=-1;!~r&&++d<32;a=b)for(b=0,i=n;i--;b|=m[i]*h[i][d+1])r=(m[i]|=a*h[i][d])-(1LL<<n)+1?r:d;}}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$2752, %rsp
	movl	%edi, -6836(%rbp)
	movl	%esi, -6840(%rbp)
	movl	%edx, -6844(%rbp)
	movl	%ecx, -6848(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L14:
	leaq	-6416(%rbp), %rdx
	movl	$0, %eax
	movl	$800, %ecx
	movq	%rdx, %rdi
	rep stosq
	movq	$0, -6832(%rbp)
	movl	-6836(%rbp), %eax
	movl	%eax, -6840(%rbp)
	jmp	.L3
.L6:
	leaq	-6848(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L4
.L5:
	leaq	-6844(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-6844(%rbp), %eax
	movslq	%eax, %rdx
	movl	-6840(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rdx, %rax
	movl	$1, -6416(%rbp,%rax,4)
.L4:
	movl	-6848(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -6848(%rbp)
	testl	%eax, %eax
	jne	.L5
	movl	-6840(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	salq	%cl, %rdx
	movl	-6840(%rbp), %eax
	cltq
	movq	%rdx, -6816(%rbp,%rax,8)
.L3:
	movl	-6840(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -6840(%rbp)
	testl	%eax, %eax
	jne	.L6
	movl	$-1, -6844(%rbp)
	movl	-6844(%rbp), %eax
	movl	%eax, -6848(%rbp)
	jmp	.L7
.L13:
	movq	$0, -6824(%rbp)
	movl	-6836(%rbp), %eax
	movl	%eax, -6840(%rbp)
	jmp	.L8
.L11:
	movl	-6840(%rbp), %eax
	cltq
	movq	-6816(%rbp,%rax,8), %rdx
	movl	-6844(%rbp), %eax
	movslq	%eax, %rcx
	movl	-6840(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rcx, %rax
	movl	-6416(%rbp,%rax,4), %eax
	cltq
	imulq	-6832(%rbp), %rax
	orq	%rax, %rdx
	movl	-6840(%rbp), %eax
	cltq
	movq	%rdx, -6816(%rbp,%rax,8)
	movl	-6840(%rbp), %eax
	cltq
	movq	-6816(%rbp,%rax,8), %rdx
	movl	-6836(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	salq	%cl, %rsi
	movq	%rsi, %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	cmpq	$-1, %rax
	je	.L9
	movl	-6848(%rbp), %eax
	jmp	.L10
.L9:
	movl	-6844(%rbp), %eax
.L10:
	movl	%eax, -6848(%rbp)
	movl	-6840(%rbp), %eax
	cltq
	movq	-6816(%rbp,%rax,8), %rdx
	movl	-6844(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movl	-6840(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rcx, %rax
	movl	-6416(%rbp,%rax,4), %eax
	cltq
	imulq	%rdx, %rax
	orq	%rax, -6824(%rbp)
.L8:
	movl	-6840(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -6840(%rbp)
	testl	%eax, %eax
	jne	.L11
	movq	-6824(%rbp), %rax
	movq	%rax, -6832(%rbp)
.L7:
	movl	-6848(%rbp), %eax
	cmpl	$-1, %eax
	jne	.L12
	movl	-6844(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -6844(%rbp)
	movl	-6844(%rbp), %eax
	cmpl	$31, %eax
	jle	.L13
.L12:
	movl	-6848(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-6836(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-6836(%rbp), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L14
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	subq	$4096, %rsp
	.cfi_def_cfa_offset 4152
	orq	$0, (%rsp)
	subq	$2792, %rsp
	.cfi_def_cfa_offset 6944
	leaq	.LC0(%rip), %r15
	movl	%edi, 60(%rsp)
	movl	%edx, 56(%rsp)
	movl	%ecx, 52(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 6872(%rsp)
	xorl	%eax, %eax
	leaq	60(%rsp), %rax
	movq	%rax, 40(%rsp)
	leaq	464(%rsp), %rax
	movq	%rax, 32(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	40(%rsp), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	60(%rsp), %ebx
	imull	%ebx, %eax
	movl	%ebx, 8(%rsp)
	testl	%eax, %eax
	je	.L39
	movq	32(%rsp), %rdi
	xorl	%eax, %eax
	movl	$800, %ecx
	rep stosq
	leal	-1(%rbx), %eax
	testl	%ebx, %ebx
	je	.L20
	movslq	%ebx, %rdx
	leaq	52(%rsp), %r14
	leaq	56(%rsp), %rbx
	movslq	%eax, %r12
	subq	$2, %rdx
	movl	%eax, %eax
	subq	%rax, %rdx
	leaq	64(%rsp), %rax
	movq	%rdx, 8(%rsp)
	movq	%rax, 16(%rsp)
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r14, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	movslq	%r12d, %rbp
	call	scanf@PLT
	movl	52(%rsp), %eax
	movq	%rbp, %r13
	salq	$5, %rbp
	leal	-1(%rax), %edx
	movl	%edx, 52(%rsp)
	testl	%eax, %eax
	je	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	56(%rsp), %rax
	addq	%rbp, %rax
	movl	$1, 464(%rsp,%rax,4)
	movl	52(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 52(%rsp)
	testl	%eax, %eax
	jne	.L4
.L7:
	movq	16(%rsp), %rdi
	movl	$1, %eax
	movl	%r13d, %ecx
	salq	%cl, %rax
	movq	%rax, (%rdi,%r12,8)
	subq	$1, %r12
	cmpq	8(%rsp), %r12
	jne	.L5
	movl	60(%rsp), %eax
	movl	%eax, 8(%rsp)
	subl	$1, %eax
.L3:
	movzbl	8(%rsp), %ecx
	movslq	%eax, %rdx
	movl	$1, %r10d
	movl	%eax, %eax
	movq	32(%rsp), %rdi
	salq	$3, %rax
	xorl	%r11d, %r11d
	xorl	%r8d, %r8d
	salq	%cl, %r10
	movq	%rdx, %rcx
	salq	$3, %rdx
	movl	$-1, 52(%rsp)
	salq	$7, %rcx
	addq	%rdx, %rbx
	movl	$0, 56(%rsp)
	movl	$1, %r13d
	leaq	4(%rdi,%rcx), %r12
	movq	16(%rsp), %rdi
	movb	$0, 16(%rsp)
	subq	%rax, %rbx
	xorl	%eax, %eax
	addq	%rdx, %rdi
	movq	%rdi, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L14:
	movl	8(%rsp), %edx
	movl	%r11d, %r14d
	testl	%edx, %edx
	je	.L21
	movq	%r11, %r9
	movq	24(%rsp), %rdx
	movq	%r12, %rcx
	movl	$-1, %ebp
	xorl	%edi, %edi
	subq	%r13, %r9
	.p2align 4,,10
	.p2align 3
.L11:
	movslq	(%rcx,%r9,4), %rax
	imulq	%r8, %rax
	orq	(%rdx), %rax
	movq	%rax, %rsi
	movq	%rax, (%rdx)
	subq	%r10, %rsi
	cmpq	$-1, %rsi
	movslq	(%rcx), %rsi
	je	.L9
	imulq	%rsi, %rax
	subq	$8, %rdx
	addq	$-128, %rcx
	orq	%rax, %rdi
	cmpq	%rdx, %rbx
	jne	.L11
	cmpl	$-1, %ebp
	jne	.L18
	movq	%rdi, %r8
	movl	$1, %eax
.L8:
	addq	$1, %r11
	movl	%r13d, %edx
	movb	$1, 16(%rsp)
	addq	$4, %r12
	addq	$1, %r13
	cmpq	$32, %r11
	jne	.L14
	movl	%edx, 56(%rsp)
	testb	%al, %al
	je	.L15
	movl	$-1, 52(%rsp)
.L15:
	movl	$-1, %ebp
.L13:
	movl	%ebp, %esi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	printf@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L9:
	imulq	%rsi, %rax
	subq	$8, %rdx
	addq	$-128, %rcx
	movl	%r14d, %ebp
	orq	%rax, %rdi
	cmpq	%rdx, %rbx
	jne	.L11
.L18:
	cmpb	$0, 16(%rsp)
	je	.L12
	movl	%r14d, 56(%rsp)
.L12:
	movl	%ebp, 52(%rsp)
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L21:
	xorl	%r8d, %r8d
	jmp	.L8
.L39:
	movq	6872(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	addq	$6888, %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
.L20:
	.cfi_restore_state
	leaq	64(%rsp), %rbx
	movl	$-1, %eax
	movq	%rbx, 16(%rsp)
	leaq	56(%rsp), %rbx
	jmp	.L3
.L40:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.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"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	subq	$4096, %rsp
	.cfi_def_cfa_offset 4152
	orq	$0, (%rsp)
	subq	$2792, %rsp
	.cfi_def_cfa_offset 6944
	leaq	.LC0(%rip), %r15
	movl	%edi, 60(%rsp)
	movl	%edx, 56(%rsp)
	movl	%ecx, 52(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 6872(%rsp)
	xorl	%eax, %eax
	leaq	60(%rsp), %rax
	movq	%rax, 40(%rsp)
	leaq	464(%rsp), %rax
	movq	%rax, 32(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	40(%rsp), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	60(%rsp), %ebx
	imull	%ebx, %eax
	movl	%ebx, 8(%rsp)
	testl	%eax, %eax
	je	.L39
	movq	32(%rsp), %rdi
	xorl	%eax, %eax
	movl	$800, %ecx
	rep stosq
	leal	-1(%rbx), %eax
	testl	%ebx, %ebx
	je	.L20
	movslq	%ebx, %rdx
	leaq	52(%rsp), %r14
	leaq	56(%rsp), %rbx
	movslq	%eax, %r12
	subq	$2, %rdx
	movl	%eax, %eax
	subq	%rax, %rdx
	leaq	64(%rsp), %rax
	movq	%rdx, 8(%rsp)
	movq	%rax, 16(%rsp)
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r14, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	movslq	%r12d, %rbp
	call	scanf@PLT
	movl	52(%rsp), %eax
	movq	%rbp, %r13
	salq	$5, %rbp
	leal	-1(%rax), %edx
	movl	%edx, 52(%rsp)
	testl	%eax, %eax
	je	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%rbx, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	56(%rsp), %rax
	addq	%rbp, %rax
	movl	$1, 464(%rsp,%rax,4)
	movl	52(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 52(%rsp)
	testl	%eax, %eax
	jne	.L4
.L7:
	movq	16(%rsp), %rdi
	movl	$1, %eax
	movl	%r13d, %ecx
	salq	%cl, %rax
	movq	%rax, (%rdi,%r12,8)
	subq	$1, %r12
	cmpq	8(%rsp), %r12
	jne	.L5
	movl	60(%rsp), %eax
	movl	%eax, 8(%rsp)
	subl	$1, %eax
.L3:
	movzbl	8(%rsp), %ecx
	movslq	%eax, %rdx
	movl	$1, %r10d
	movl	%eax, %eax
	movq	32(%rsp), %rdi
	salq	$3, %rax
	xorl	%r11d, %r11d
	xorl	%r8d, %r8d
	salq	%cl, %r10
	movq	%rdx, %rcx
	salq	$3, %rdx
	movl	$-1, 52(%rsp)
	salq	$7, %rcx
	addq	%rdx, %rbx
	movl	$0, 56(%rsp)
	movl	$1, %r13d
	leaq	4(%rdi,%rcx), %r12
	movq	16(%rsp), %rdi
	movb	$0, 16(%rsp)
	subq	%rax, %rbx
	xorl	%eax, %eax
	addq	%rdx, %rdi
	movq	%rdi, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L14:
	movl	8(%rsp), %edx
	movl	%r11d, %r14d
	testl	%edx, %edx
	je	.L21
	movq	%r11, %r9
	movq	24(%rsp), %rdx
	movq	%r12, %rcx
	movl	$-1, %ebp
	xorl	%edi, %edi
	subq	%r13, %r9
	.p2align 4,,10
	.p2align 3
.L11:
	movslq	(%rcx,%r9,4), %rax
	imulq	%r8, %rax
	orq	(%rdx), %rax
	movq	%rax, %rsi
	movq	%rax, (%rdx)
	subq	%r10, %rsi
	cmpq	$-1, %rsi
	movslq	(%rcx), %rsi
	je	.L9
	imulq	%rsi, %rax
	subq	$8, %rdx
	addq	$-128, %rcx
	orq	%rax, %rdi
	cmpq	%rdx, %rbx
	jne	.L11
	cmpl	$-1, %ebp
	jne	.L18
	movq	%rdi, %r8
	movl	$1, %eax
.L8:
	addq	$1, %r11
	movl	%r13d, %edx
	movb	$1, 16(%rsp)
	addq	$4, %r12
	addq	$1, %r13
	cmpq	$32, %r11
	jne	.L14
	movl	%edx, 56(%rsp)
	testb	%al, %al
	je	.L15
	movl	$-1, 52(%rsp)
.L15:
	movl	$-1, %ebp
.L13:
	movl	%ebp, %esi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	printf@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L9:
	imulq	%rsi, %rax
	subq	$8, %rdx
	addq	$-128, %rcx
	movl	%r14d, %ebp
	orq	%rax, %rdi
	cmpq	%rdx, %rbx
	jne	.L11
.L18:
	cmpb	$0, 16(%rsp)
	je	.L12
	movl	%r14d, 56(%rsp)
.L12:
	movl	%ebp, 52(%rsp)
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L21:
	xorl	%r8d, %r8d
	jmp	.L8
.L39:
	movq	6872(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	addq	$6888, %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
.L20:
	.cfi_restore_state
	leaq	64(%rsp), %rbx
	movl	$-1, %eax
	movq	%rbx, 16(%rsp)
	leaq	56(%rsp), %rbx
	jmp	.L3
.L40:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.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:

main(n,i,d,r){for(;scanf("%d",&n)*n;printf("%d\n",r)){int h[50][32]={0};long long m[50],a=0,b;for(i=n;i--;m[i]=1LL<<i)for(scanf("%d",&r);r--;h[i][d]=1)scanf("%d",&d);for(r=d=-1;!~r&&++d<32;a=b)for(b=0,i=n;i--;b|=m[i]*h[i][d+1])r=(m[i]|=a*h[i][d])-(1LL<<n)+1?r:d;}}
4
1 1
2 2 3
2 1 2
3 4 4 5
0
 4
1 1
2 2 3
2 1 2
3 3 4 10
0
 4
1 1
2 2 5
2 0 2
3 1 4 5
0
 4
1 1
2 2 3
2 1 2
3 1 4 5
0
 4
1 1
2 1 3
2 0 1
3 1 4 5
0
 4
1 1
2 2 3
2 0 4
3 1 4 2
0
 4
1 1
2 2 3
2 1 2
3 4 4 0
0
 4
1 1
2 2 3
2 2 2
3 3 4 5
0
 4
1 1
1 2 3
2 1 2
3 4 4 0
0
 4
1 1
1 3 3
2 1 2
3 4 4 0
0

-1
 3
 5
 2
 1
 4
 -1
 -1
 -1
 -1

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
main(n,i,d,r){for(;scanf("%d",&n)*n;printf("%d\n",r)){int h[50][32]={0};long long m[50],a=0,b;for(i=n;i--;m[i]=1LL<<i)for(scanf("%d",&r);r--;h[i][d]=1)scanf("%d",&d);for(r=d=-1;!~r&&++d<32;a=b)for(b=0,i=n;i--;b|=m[i]*h[i][d+1])r=(m[i]|=a*h[i][d])-(1LL<<n)+1?r:d;}}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$2752, %rsp
	movl	%edi, -6836(%rbp)
	movl	%esi, -6840(%rbp)
	movl	%edx, -6844(%rbp)
	movl	%ecx, -6848(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L14:
	leaq	-6416(%rbp), %rdx
	movl	$0, %eax
	movl	$800, %ecx
	movq	%rdx, %rdi
	rep stosq
	movq	$0, -6832(%rbp)
	movl	-6836(%rbp), %eax
	movl	%eax, -6840(%rbp)
	jmp	.L3
.L6:
	leaq	-6848(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L4
.L5:
	leaq	-6844(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-6844(%rbp), %eax
	movslq	%eax, %rdx
	movl	-6840(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rdx, %rax
	movl	$1, -6416(%rbp,%rax,4)
.L4:
	movl	-6848(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -6848(%rbp)
	testl	%eax, %eax
	jne	.L5
	movl	-6840(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	salq	%cl, %rdx
	movl	-6840(%rbp), %eax
	cltq
	movq	%rdx, -6816(%rbp,%rax,8)
.L3:
	movl	-6840(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -6840(%rbp)
	testl	%eax, %eax
	jne	.L6
	movl	$-1, -6844(%rbp)
	movl	-6844(%rbp), %eax
	movl	%eax, -6848(%rbp)
	jmp	.L7
.L13:
	movq	$0, -6824(%rbp)
	movl	-6836(%rbp), %eax
	movl	%eax, -6840(%rbp)
	jmp	.L8
.L11:
	movl	-6840(%rbp), %eax
	cltq
	movq	-6816(%rbp,%rax,8), %rdx
	movl	-6844(%rbp), %eax
	movslq	%eax, %rcx
	movl	-6840(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rcx, %rax
	movl	-6416(%rbp,%rax,4), %eax
	cltq
	imulq	-6832(%rbp), %rax
	orq	%rax, %rdx
	movl	-6840(%rbp), %eax
	cltq
	movq	%rdx, -6816(%rbp,%rax,8)
	movl	-6840(%rbp), %eax
	cltq
	movq	-6816(%rbp,%rax,8), %rdx
	movl	-6836(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	salq	%cl, %rsi
	movq	%rsi, %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	cmpq	$-1, %rax
	je	.L9
	movl	-6848(%rbp), %eax
	jmp	.L10
.L9:
	movl	-6844(%rbp), %eax
.L10:
	movl	%eax, -6848(%rbp)
	movl	-6840(%rbp), %eax
	cltq
	movq	-6816(%rbp,%rax,8), %rdx
	movl	-6844(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movl	-6840(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rcx, %rax
	movl	-6416(%rbp,%rax,4), %eax
	cltq
	imulq	%rdx, %rax
	orq	%rax, -6824(%rbp)
.L8:
	movl	-6840(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -6840(%rbp)
	testl	%eax, %eax
	jne	.L11
	movq	-6824(%rbp), %rax
	movq	%rax, -6832(%rbp)
.L7:
	movl	-6848(%rbp), %eax
	cmpl	$-1, %eax
	jne	.L12
	movl	-6844(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -6844(%rbp)
	movl	-6844(%rbp), %eax
	cmpl	$31, %eax
	jle	.L13
.L12:
	movl	-6848(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-6836(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-6836(%rbp), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L14
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$2752, %rsp
	movl	%edi, -6836(%rbp)
	movl	%esi, -6840(%rbp)
	movl	%edx, -6844(%rbp)
	movl	%ecx, -6848(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L14:
	leaq	-6416(%rbp), %rdx
	movl	$0, %eax
	movl	$800, %ecx
	movq	%rdx, %rdi
	rep stosq
	movq	$0, -6832(%rbp)
	movl	-6836(%rbp), %eax
	movl	%eax, -6840(%rbp)
	jmp	.L3
.L6:
	leaq	-6848(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	jmp	.L4
.L5:
	leaq	-6844(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-6844(%rbp), %eax
	movslq	%eax, %rdx
	movl	-6840(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rdx, %rax
	movl	$1, -6416(%rbp,%rax,4)
.L4:
	movl	-6848(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -6848(%rbp)
	testl	%eax, %eax
	jne	.L5
	movl	-6840(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	salq	%cl, %rdx
	movl	-6840(%rbp), %eax
	cltq
	movq	%rdx, -6816(%rbp,%rax,8)
.L3:
	movl	-6840(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -6840(%rbp)
	testl	%eax, %eax
	jne	.L6
	movl	$-1, -6844(%rbp)
	movl	-6844(%rbp), %eax
	movl	%eax, -6848(%rbp)
	jmp	.L7
.L13:
	movq	$0, -6824(%rbp)
	movl	-6836(%rbp), %eax
	movl	%eax, -6840(%rbp)
	jmp	.L8
.L11:
	movl	-6840(%rbp), %eax
	cltq
	movq	-6816(%rbp,%rax,8), %rdx
	movl	-6844(%rbp), %eax
	movslq	%eax, %rcx
	movl	-6840(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rcx, %rax
	movl	-6416(%rbp,%rax,4), %eax
	cltq
	imulq	-6832(%rbp), %rax
	orq	%rax, %rdx
	movl	-6840(%rbp), %eax
	cltq
	movq	%rdx, -6816(%rbp,%rax,8)
	movl	-6840(%rbp), %eax
	cltq
	movq	-6816(%rbp,%rax,8), %rdx
	movl	-6836(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	salq	%cl, %rsi
	movq	%rsi, %rcx
	movq	%rdx, %rax
	subq	%rcx, %rax
	cmpq	$-1, %rax
	je	.L9
	movl	-6848(%rbp), %eax
	jmp	.L10
.L9:
	movl	-6844(%rbp), %eax
.L10:
	movl	%eax, -6848(%rbp)
	movl	-6840(%rbp), %eax
	cltq
	movq	-6816(%rbp,%rax,8), %rdx
	movl	-6844(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movl	-6840(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rcx, %rax
	movl	-6416(%rbp,%rax,4), %eax
	cltq
	imulq	%rdx, %rax
	orq	%rax, -6824(%rbp)
.L8:
	movl	-6840(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -6840(%rbp)
	testl	%eax, %eax
	jne	.L11
	movq	-6824(%rbp), %rax
	movq	%rax, -6832(%rbp)
.L7:
	movl	-6848(%rbp), %eax
	cmpl	$-1, %eax
	jne	.L12
	movl	-6844(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -6844(%rbp)
	movl	-6844(%rbp), %eax
	cmpl	$31, %eax
	jle	.L13
.L12:
	movl	-6848(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-6836(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	-6836(%rbp), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L14
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
