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>

int min(int a,int b){return a < b ? a : b;}

int main()
{
    int n,v[100000],num[100005][2] = {0},i,j,max[2][2] = {0};

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&v[i]);
        num[v[i]][i % 2]++;
    }

    for (i = 0; i < 2; i++)
    {
        for (j = 0; j <= 100000; j++)
        {
            if(num[max[i][0]][i] < num[j][i])
            {
                max[i][1] = max[i][0];
                max[i][0] = j;
            }
            else if (num[max[i][1]][i] < num[j][i])
            {
                max[i][1] = j;
            }
        }
    }
    if(max[0][0] != max[1][0])
    {
        printf("%d",n - num[max[0][0]][0] - num[max[1][0]][1]);
    }
    else if(max[0][1] == 0 || max[1][1] == 0)
    {
        printf("%d",n / 2);
    }
    else
    {
        printf("%d",min(n / 2 - num[max[0][1]][0] + n / 2 - num[max[1][0]][1] , n / 2 - num[max[1][1]][1] + n / 2 - num[max[0][0]][0]));
    }
    
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	min
	.type	min, @function
min:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-1196032(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$4048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-800048(%rbp), %rax
	movl	$800040, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	$0, -1200064(%rbp)
	movq	$0, -1200056(%rbp)
	leaq	-1200076(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1200072(%rbp)
	jmp	.L4
.L5:
	leaq	-1200048(%rbp), %rdx
	movl	-1200072(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200048(%rbp,%rax,4), %eax
	movl	-1200072(%rbp), %edx
	movl	%edx, %ecx
	sarl	$31, %ecx
	shrl	$31, %ecx
	addl	%ecx, %edx
	andl	$1, %edx
	subl	%ecx, %edx
	movl	%edx, %ecx
	movslq	%ecx, %rsi
	movslq	%eax, %rdx
	addq	%rdx, %rdx
	addq	%rsi, %rdx
	movl	-800048(%rbp,%rdx,4), %edx
	addl	$1, %edx
	movslq	%ecx, %rcx
	cltq
	addq	%rax, %rax
	addq	%rcx, %rax
	movl	%edx, -800048(%rbp,%rax,4)
	addl	$1, -1200072(%rbp)
.L4:
	movl	-1200076(%rbp), %eax
	cmpl	%eax, -1200072(%rbp)
	jl	.L5
	movl	$0, -1200072(%rbp)
	jmp	.L6
.L11:
	movl	$0, -1200068(%rbp)
	jmp	.L7
.L10:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200064(%rbp,%rax,8), %eax
	movl	-1200072(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	addq	%rax, %rax
	addq	%rdx, %rax
	movl	-800048(%rbp,%rax,4), %edx
	movl	-1200072(%rbp), %eax
	movslq	%eax, %rcx
	movl	-1200068(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	%rcx, %rax
	movl	-800048(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L8
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200064(%rbp,%rax,8), %edx
	movl	-1200072(%rbp), %eax
	cltq
	movl	%edx, -1200060(%rbp,%rax,8)
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200068(%rbp), %edx
	movl	%edx, -1200064(%rbp,%rax,8)
	jmp	.L9
.L8:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200060(%rbp,%rax,8), %eax
	movl	-1200072(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	addq	%rax, %rax
	addq	%rdx, %rax
	movl	-800048(%rbp,%rax,4), %edx
	movl	-1200072(%rbp), %eax
	movslq	%eax, %rcx
	movl	-1200068(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	%rcx, %rax
	movl	-800048(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L9
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200068(%rbp), %edx
	movl	%edx, -1200060(%rbp,%rax,8)
.L9:
	addl	$1, -1200068(%rbp)
.L7:
	cmpl	$100000, -1200068(%rbp)
	jle	.L10
	addl	$1, -1200072(%rbp)
.L6:
	cmpl	$1, -1200072(%rbp)
	jle	.L11
	movl	-1200064(%rbp), %edx
	movl	-1200056(%rbp), %eax
	cmpl	%eax, %edx
	je	.L12
	movl	-1200076(%rbp), %edx
	movl	-1200064(%rbp), %eax
	cltq
	movl	-800048(%rbp,%rax,8), %eax
	subl	%eax, %edx
	movl	-1200056(%rbp), %eax
	cltq
	movl	-800044(%rbp,%rax,8), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L13
.L12:
	movl	-1200060(%rbp), %eax
	testl	%eax, %eax
	je	.L14
	movl	-1200052(%rbp), %eax
	testl	%eax, %eax
	jne	.L15
.L14:
	movl	-1200076(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L13
.L15:
	movl	-1200076(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-1200052(%rbp), %eax
	cltq
	movl	-800044(%rbp,%rax,8), %eax
	subl	%eax, %edx
	movl	-1200076(%rbp), %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	sarl	%eax
	addl	%eax, %edx
	movl	-1200064(%rbp), %eax
	cltq
	movl	-800048(%rbp,%rax,8), %eax
	subl	%eax, %edx
	movl	-1200076(%rbp), %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	sarl	%eax
	movl	%eax, %ecx
	movl	-1200060(%rbp), %eax
	cltq
	movl	-800048(%rbp,%rax,8), %eax
	subl	%eax, %ecx
	movl	-1200076(%rbp), %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	addl	%eax, %ecx
	movl	-1200056(%rbp), %eax
	cltq
	movl	-800044(%rbp,%rax,8), %esi
	movl	%ecx, %eax
	subl	%esi, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	min
	.type	min, @function
min:
.LFB39:
	.cfi_startproc
	endbr64
	cmpl	%edi, %esi
	movl	%edi, %eax
	cmovle	%esi, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	min, .-min
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-1196032(%rsp), %r11
	.cfi_def_cfa 11, 1196072
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$4056, %rsp
	.cfi_def_cfa_offset 1200128
	movl	$800040, %edx
	xorl	%esi, %esi
	leaq	.LC0(%rip), %rbp
	movq	%fs:40, %rax
	movq	%rax, 1200072(%rsp)
	xorl	%eax, %eax
	leaq	400032(%rsp), %rbx
	movq	%rbx, %rdi
	call	memset@PLT
	pxor	%xmm0, %xmm0
	leaq	12(%rsp), %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	movaps	%xmm0, 16(%rsp)
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L4
	leaq	32(%rsp), %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$4, %r13
	call	__isoc99_scanf@PLT
	movl	%r12d, %eax
	movslq	-4(%r13), %rdx
	addl	$1, %r12d
	andl	$1, %eax
	leaq	(%rax,%rdx,2), %rax
	addl	$1, 400032(%rsp,%rax,4)
	movl	12(%rsp), %eax
	cmpl	%r12d, %eax
	jg	.L5
.L4:
	leaq	16(%rsp), %rdi
	movq	%rbx, %r9
	xorl	%ecx, %ecx
	xorl	%r10d, %r10d
.L6:
	xorl	%edx, %edx
	movslq	%r10d, %r8
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L23:
	movq	%xmm0, (%rdi)
.L8:
	addq	$1, %rdx
	cmpq	$100001, %rdx
	je	.L22
.L9:
	movslq	(%rdi), %rcx
.L11:
	movd	%ecx, %xmm1
	movd	%edx, %xmm0
	leaq	(%r8,%rcx,2), %rcx
	movl	(%r9,%rdx,8), %esi
	punpckldq	%xmm1, %xmm0
	cmpl	%esi, 400032(%rsp,%rcx,4)
	jl	.L23
	movslq	4(%rdi), %rcx
	leaq	(%r8,%rcx,2), %rcx
	cmpl	400032(%rsp,%rcx,4), %esi
	jle	.L8
	movl	%edx, 4(%rdi)
	addq	$1, %rdx
	cmpq	$100001, %rdx
	jne	.L9
.L22:
	addq	$8, %rdi
	addq	$4, %r9
	cmpl	$1, %r10d
	je	.L10
	movslq	(%rdi), %rcx
	movl	$1, %r10d
	jmp	.L6
.L10:
	movslq	16(%rsp), %rcx
	movslq	24(%rsp), %rsi
	cmpl	%esi, %ecx
	jne	.L24
	movslq	20(%rsp), %rsi
	movl	$2, %edi
	cltd
	idivl	%edi
	testl	%esi, %esi
	je	.L14
	movslq	28(%rsp), %rdx
	testl	%edx, %edx
	jne	.L15
.L14:
	movl	%eax, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L13:
	movq	1200072(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L25
	addq	$1200088, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L24:
	.cfi_restore_state
	subl	400032(%rsp,%rcx,8), %eax
	subl	400036(%rsp,%rsi,8), %eax
	jmp	.L14
.L15:
	movl	%eax, %ebx
	subl	400036(%rsp,%rdx,8), %ebx
	movl	$1, %edi
	movl	%ebx, %edx
	movl	%eax, %ebx
	subl	400032(%rsp,%rsi,8), %ebx
	movq	%rbp, %rsi
	addl	%eax, %edx
	addl	%ebx, %eax
	subl	400032(%rsp,%rcx,8), %edx
	subl	400036(%rsp,%rcx,8), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L13
.L25:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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	min
	.type	min, @function
min:
.LFB39:
	.cfi_startproc
	endbr64
	cmpl	%edi, %esi
	movl	%edi, %eax
	cmovle	%esi, %eax
	ret
	.cfi_endproc
.LFE39:
	.size	min, .-min
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	-1196032(%rsp), %r11
	.cfi_def_cfa 11, 1196072
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$4056, %rsp
	.cfi_def_cfa_offset 1200128
	movl	$800040, %edx
	xorl	%esi, %esi
	leaq	.LC0(%rip), %rbp
	movq	%fs:40, %rax
	movq	%rax, 1200072(%rsp)
	xorl	%eax, %eax
	leaq	400032(%rsp), %rbx
	movq	%rbx, %rdi
	call	memset@PLT
	pxor	%xmm0, %xmm0
	leaq	12(%rsp), %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	movaps	%xmm0, 16(%rsp)
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L4
	leaq	32(%rsp), %r13
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$4, %r13
	call	__isoc99_scanf@PLT
	movl	%r12d, %eax
	movslq	-4(%r13), %rdx
	addl	$1, %r12d
	andl	$1, %eax
	leaq	(%rax,%rdx,2), %rax
	addl	$1, 400032(%rsp,%rax,4)
	movl	12(%rsp), %eax
	cmpl	%r12d, %eax
	jg	.L5
.L4:
	leaq	16(%rsp), %rdi
	movq	%rbx, %r9
	xorl	%ecx, %ecx
	xorl	%r10d, %r10d
.L6:
	xorl	%edx, %edx
	movslq	%r10d, %r8
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L23:
	movq	%xmm0, (%rdi)
.L8:
	addq	$1, %rdx
	cmpq	$100001, %rdx
	je	.L22
.L9:
	movslq	(%rdi), %rcx
.L11:
	movd	%ecx, %xmm1
	movd	%edx, %xmm0
	leaq	(%r8,%rcx,2), %rcx
	movl	(%r9,%rdx,8), %esi
	punpckldq	%xmm1, %xmm0
	cmpl	%esi, 400032(%rsp,%rcx,4)
	jl	.L23
	movslq	4(%rdi), %rcx
	leaq	(%r8,%rcx,2), %rcx
	cmpl	400032(%rsp,%rcx,4), %esi
	jle	.L8
	movl	%edx, 4(%rdi)
	addq	$1, %rdx
	cmpq	$100001, %rdx
	jne	.L9
.L22:
	addq	$8, %rdi
	addq	$4, %r9
	cmpl	$1, %r10d
	je	.L10
	movslq	(%rdi), %rcx
	movl	$1, %r10d
	jmp	.L6
.L10:
	movslq	16(%rsp), %rcx
	movslq	24(%rsp), %rsi
	cmpl	%esi, %ecx
	jne	.L24
	movslq	20(%rsp), %rsi
	movl	$2, %edi
	cltd
	idivl	%edi
	testl	%esi, %esi
	je	.L14
	movslq	28(%rsp), %rdx
	testl	%edx, %edx
	jne	.L15
.L14:
	movl	%eax, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L13:
	movq	1200072(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L25
	addq	$1200088, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L24:
	.cfi_restore_state
	subl	400032(%rsp,%rcx,8), %eax
	subl	400036(%rsp,%rsi,8), %eax
	jmp	.L14
.L15:
	movl	%eax, %ebx
	subl	400036(%rsp,%rdx,8), %ebx
	movl	$1, %edi
	movl	%ebx, %edx
	movl	%eax, %ebx
	subl	400032(%rsp,%rsi,8), %ebx
	movq	%rbp, %rsi
	addl	%eax, %edx
	addl	%ebx, %eax
	subl	400032(%rsp,%rcx,8), %edx
	subl	400036(%rsp,%rcx,8), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L13
.L25:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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>

int min(int a,int b){return a < b ? a : b;}

int main()
{
    int n,v[100000],num[100005][2] = {0},i,j,max[2][2] = {0};

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&v[i]);
        num[v[i]][i % 2]++;
    }

    for (i = 0; i < 2; i++)
    {
        for (j = 0; j <= 100000; j++)
        {
            if(num[max[i][0]][i] < num[j][i])
            {
                max[i][1] = max[i][0];
                max[i][0] = j;
            }
            else if (num[max[i][1]][i] < num[j][i])
            {
                max[i][1] = j;
            }
        }
    }
    if(max[0][0] != max[1][0])
    {
        printf("%d",n - num[max[0][0]][0] - num[max[1][0]][1]);
    }
    else if(max[0][1] == 0 || max[1][1] == 0)
    {
        printf("%d",n / 2);
    }
    else
    {
        printf("%d",min(n / 2 - num[max[0][1]][0] + n / 2 - num[max[1][0]][1] , n / 2 - num[max[1][1]][1] + n / 2 - num[max[0][0]][0]));
    }
    
}
4
3 2 3 2
 6
105 119 204 119 105 119
 4
4 1 3 2
 6
105 120 54 119 105 78
 6
105 120 54 119 190 78
 6
105 119 204 119 105 78
 4
4 1 3 0
 6
105 119 54 119 105 78
 4
4 1 3 1
 4
4 1 6 1

0 1 2 3 4 2 2 2 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
#include <stdio.h>
#include <stdlib.h>

int min(int a,int b){return a < b ? a : b;}

int main()
{
    int n,v[100000],num[100005][2] = {0},i,j,max[2][2] = {0};

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&v[i]);
        num[v[i]][i % 2]++;
    }

    for (i = 0; i < 2; i++)
    {
        for (j = 0; j <= 100000; j++)
        {
            if(num[max[i][0]][i] < num[j][i])
            {
                max[i][1] = max[i][0];
                max[i][0] = j;
            }
            else if (num[max[i][1]][i] < num[j][i])
            {
                max[i][1] = j;
            }
        }
    }
    if(max[0][0] != max[1][0])
    {
        printf("%d",n - num[max[0][0]][0] - num[max[1][0]][1]);
    }
    else if(max[0][1] == 0 || max[1][1] == 0)
    {
        printf("%d",n / 2);
    }
    else
    {
        printf("%d",min(n / 2 - num[max[0][1]][0] + n / 2 - num[max[1][0]][1] , n / 2 - num[max[1][1]][1] + n / 2 - num[max[0][0]][0]));
    }
    
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	min
	.type	min, @function
min:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-1196032(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$4048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-800048(%rbp), %rax
	movl	$800040, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	$0, -1200064(%rbp)
	movq	$0, -1200056(%rbp)
	leaq	-1200076(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1200072(%rbp)
	jmp	.L4
.L5:
	leaq	-1200048(%rbp), %rdx
	movl	-1200072(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200048(%rbp,%rax,4), %eax
	movl	-1200072(%rbp), %edx
	movl	%edx, %ecx
	sarl	$31, %ecx
	shrl	$31, %ecx
	addl	%ecx, %edx
	andl	$1, %edx
	subl	%ecx, %edx
	movl	%edx, %ecx
	movslq	%ecx, %rsi
	movslq	%eax, %rdx
	addq	%rdx, %rdx
	addq	%rsi, %rdx
	movl	-800048(%rbp,%rdx,4), %edx
	addl	$1, %edx
	movslq	%ecx, %rcx
	cltq
	addq	%rax, %rax
	addq	%rcx, %rax
	movl	%edx, -800048(%rbp,%rax,4)
	addl	$1, -1200072(%rbp)
.L4:
	movl	-1200076(%rbp), %eax
	cmpl	%eax, -1200072(%rbp)
	jl	.L5
	movl	$0, -1200072(%rbp)
	jmp	.L6
.L11:
	movl	$0, -1200068(%rbp)
	jmp	.L7
.L10:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200064(%rbp,%rax,8), %eax
	movl	-1200072(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	addq	%rax, %rax
	addq	%rdx, %rax
	movl	-800048(%rbp,%rax,4), %edx
	movl	-1200072(%rbp), %eax
	movslq	%eax, %rcx
	movl	-1200068(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	%rcx, %rax
	movl	-800048(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L8
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200064(%rbp,%rax,8), %edx
	movl	-1200072(%rbp), %eax
	cltq
	movl	%edx, -1200060(%rbp,%rax,8)
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200068(%rbp), %edx
	movl	%edx, -1200064(%rbp,%rax,8)
	jmp	.L9
.L8:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200060(%rbp,%rax,8), %eax
	movl	-1200072(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	addq	%rax, %rax
	addq	%rdx, %rax
	movl	-800048(%rbp,%rax,4), %edx
	movl	-1200072(%rbp), %eax
	movslq	%eax, %rcx
	movl	-1200068(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	%rcx, %rax
	movl	-800048(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L9
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200068(%rbp), %edx
	movl	%edx, -1200060(%rbp,%rax,8)
.L9:
	addl	$1, -1200068(%rbp)
.L7:
	cmpl	$100000, -1200068(%rbp)
	jle	.L10
	addl	$1, -1200072(%rbp)
.L6:
	cmpl	$1, -1200072(%rbp)
	jle	.L11
	movl	-1200064(%rbp), %edx
	movl	-1200056(%rbp), %eax
	cmpl	%eax, %edx
	je	.L12
	movl	-1200076(%rbp), %edx
	movl	-1200064(%rbp), %eax
	cltq
	movl	-800048(%rbp,%rax,8), %eax
	subl	%eax, %edx
	movl	-1200056(%rbp), %eax
	cltq
	movl	-800044(%rbp,%rax,8), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L13
.L12:
	movl	-1200060(%rbp), %eax
	testl	%eax, %eax
	je	.L14
	movl	-1200052(%rbp), %eax
	testl	%eax, %eax
	jne	.L15
.L14:
	movl	-1200076(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L13
.L15:
	movl	-1200076(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-1200052(%rbp), %eax
	cltq
	movl	-800044(%rbp,%rax,8), %eax
	subl	%eax, %edx
	movl	-1200076(%rbp), %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	sarl	%eax
	addl	%eax, %edx
	movl	-1200064(%rbp), %eax
	cltq
	movl	-800048(%rbp,%rax,8), %eax
	subl	%eax, %edx
	movl	-1200076(%rbp), %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	sarl	%eax
	movl	%eax, %ecx
	movl	-1200060(%rbp), %eax
	cltq
	movl	-800048(%rbp,%rax,8), %eax
	subl	%eax, %ecx
	movl	-1200076(%rbp), %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	addl	%eax, %ecx
	movl	-1200056(%rbp), %eax
	cltq
	movl	-800044(%rbp,%rax,8), %esi
	movl	%ecx, %eax
	subl	%esi, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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.
val
	.file	"temp.c"
	.text
	.globl	min
	.type	min, @function
min:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-1196032(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$4048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-800048(%rbp), %rax
	movl	$800040, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movq	$0, -1200064(%rbp)
	movq	$0, -1200056(%rbp)
	leaq	-1200076(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1200072(%rbp)
	jmp	.L4
.L5:
	leaq	-1200048(%rbp), %rdx
	movl	-1200072(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200048(%rbp,%rax,4), %eax
	movl	-1200072(%rbp), %edx
	movl	%edx, %ecx
	sarl	$31, %ecx
	shrl	$31, %ecx
	addl	%ecx, %edx
	andl	$1, %edx
	subl	%ecx, %edx
	movl	%edx, %ecx
	movslq	%ecx, %rsi
	movslq	%eax, %rdx
	addq	%rdx, %rdx
	addq	%rsi, %rdx
	movl	-800048(%rbp,%rdx,4), %edx
	addl	$1, %edx
	movslq	%ecx, %rcx
	cltq
	addq	%rax, %rax
	addq	%rcx, %rax
	movl	%edx, -800048(%rbp,%rax,4)
	addl	$1, -1200072(%rbp)
.L4:
	movl	-1200076(%rbp), %eax
	cmpl	%eax, -1200072(%rbp)
	jl	.L5
	movl	$0, -1200072(%rbp)
	jmp	.L6
.L11:
	movl	$0, -1200068(%rbp)
	jmp	.L7
.L10:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200064(%rbp,%rax,8), %eax
	movl	-1200072(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	addq	%rax, %rax
	addq	%rdx, %rax
	movl	-800048(%rbp,%rax,4), %edx
	movl	-1200072(%rbp), %eax
	movslq	%eax, %rcx
	movl	-1200068(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	%rcx, %rax
	movl	-800048(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L8
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200064(%rbp,%rax,8), %edx
	movl	-1200072(%rbp), %eax
	cltq
	movl	%edx, -1200060(%rbp,%rax,8)
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200068(%rbp), %edx
	movl	%edx, -1200064(%rbp,%rax,8)
	jmp	.L9
.L8:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200060(%rbp,%rax,8), %eax
	movl	-1200072(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	addq	%rax, %rax
	addq	%rdx, %rax
	movl	-800048(%rbp,%rax,4), %edx
	movl	-1200072(%rbp), %eax
	movslq	%eax, %rcx
	movl	-1200068(%rbp), %eax
	cltq
	addq	%rax, %rax
	addq	%rcx, %rax
	movl	-800048(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jge	.L9
	movl	-1200072(%rbp), %eax
	cltq
	movl	-1200068(%rbp), %edx
	movl	%edx, -1200060(%rbp,%rax,8)
.L9:
	addl	$1, -1200068(%rbp)
.L7:
	cmpl	$100000, -1200068(%rbp)
	jle	.L10
	addl	$1, -1200072(%rbp)
.L6:
	cmpl	$1, -1200072(%rbp)
	jle	.L11
	movl	-1200064(%rbp), %edx
	movl	-1200056(%rbp), %eax
	cmpl	%eax, %edx
	je	.L12
	movl	-1200076(%rbp), %edx
	movl	-1200064(%rbp), %eax
	cltq
	movl	-800048(%rbp,%rax,8), %eax
	subl	%eax, %edx
	movl	-1200056(%rbp), %eax
	cltq
	movl	-800044(%rbp,%rax,8), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L13
.L12:
	movl	-1200060(%rbp), %eax
	testl	%eax, %eax
	je	.L14
	movl	-1200052(%rbp), %eax
	testl	%eax, %eax
	jne	.L15
.L14:
	movl	-1200076(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L13
.L15:
	movl	-1200076(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, %edx
	movl	-1200052(%rbp), %eax
	cltq
	movl	-800044(%rbp,%rax,8), %eax
	subl	%eax, %edx
	movl	-1200076(%rbp), %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	sarl	%eax
	addl	%eax, %edx
	movl	-1200064(%rbp), %eax
	cltq
	movl	-800048(%rbp,%rax,8), %eax
	subl	%eax, %edx
	movl	-1200076(%rbp), %eax
	movl	%eax, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	sarl	%eax
	movl	%eax, %ecx
	movl	-1200060(%rbp), %eax
	cltq
	movl	-800048(%rbp,%rax,8), %eax
	subl	%eax, %ecx
	movl	-1200076(%rbp), %eax
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%esi, %eax
	sarl	%eax
	addl	%eax, %ecx
	movl	-1200056(%rbp), %eax
	cltq
	movl	-800044(%rbp,%rax,8), %esi
	movl	%ecx, %eax
	subl	%esi, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L13:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
