c:
#include <stdio.h>

int searchInsert(int* nums, int numsSize, int target) {
        for (int i = 0 ; i < numsSize ; i++){
            if(nums[i]==target){
                return i;
            }
        }
        int q=numsSize-1;
        while(q>=0){
            if(target==0 && nums[0]>0){
                return 0;

            }
            if(nums[q]<target){
                return q+1;
            }
            else if(nums[0]>target){
                return 0;
            }
            q--;

        }

        if (numsSize == 1 && target>nums[0]){
            return 1;
        }
        else if (numsSize == 1 && target<nums[0]){
            return 0;
        }
        return -1;
}

int main() {
    int nums1[] = {1, 3, 5, 6};
    int target1 = 5;
    int result1 = searchInsert(nums1, 4, target1);

    int target2 = 2;
    int result2 = searchInsert(nums1, 4, target2);

    int target3 = 7;
    int result3 = searchInsert(nums1, 4, target3);

    if (result1 == 2 && result2 == 1 && result3 == 4) {
        printf("<<<FUNCTION SUCCESS>>>\n");
    } else {
        printf("<<<FUNCTION FAILURE>>>\n");
    }
    return 0;
}

s:
	.text
	.globl	searchInsert
searchInsert:
	pushq	%rbp
	movq	%rsp, %rbp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -32(%rbp)
	jne	.L3
	movl	-4(%rbp), %eax
	jmp	.L4
.L3:
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L5
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -8(%rbp)
	jmp	.L6
.L10:
	cmpl	$0, -32(%rbp)
	jne	.L7
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jle	.L7
	movl	$0, %eax
	jmp	.L4
.L7:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L8
	movl	-8(%rbp), %eax
	addl	$1, %eax
	jmp	.L4
.L8:
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -32(%rbp)
	jge	.L9
	movl	$0, %eax
	jmp	.L4
.L9:
	subl	$1, -8(%rbp)
.L6:
	cmpl	$0, -8(%rbp)
	jns	.L10
	cmpl	$1, -28(%rbp)
	jne	.L11
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -32(%rbp)
	jle	.L11
	movl	$1, %eax
	jmp	.L4
.L11:
	cmpl	$1, -28(%rbp)
	jne	.L12
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -32(%rbp)
	jge	.L12
	movl	$0, %eax
	jmp	.L4
.L12:
	movl	$-1, %eax
.L4:
	popq	%rbp
	ret
	.section	.rodata
.LC0:
	.string	"<<<FUNCTION SUCCESS>>>"
.LC1:
	.string	"<<<FUNCTION FAILURE>>>"
	.text
	.globl	main
main:
	pushq	%rbp
	movq	%rsp, %rbp
	subq	$48, %rsp
	movl	$1, -48(%rbp)
	movl	$3, -44(%rbp)
	movl	$5, -40(%rbp)
	movl	$6, -36(%rbp)
	movl	$5, -4(%rbp)
	movl	-4(%rbp), %edx
	leaq	-48(%rbp), %rax
	movl	$4, %esi
	movq	%rax, %rdi
	call	searchInsert
	movl	%eax, -8(%rbp)
	movl	$2, -12(%rbp)
	movl	-12(%rbp), %edx
	leaq	-48(%rbp), %rax
	movl	$4, %esi
	movq	%rax, %rdi
	call	searchInsert
	movl	%eax, -16(%rbp)
	movl	$7, -20(%rbp)
	movl	-20(%rbp), %edx
	leaq	-48(%rbp), %rax
	movl	$4, %esi
	movq	%rax, %rdi
	call	searchInsert
	movl	%eax, -24(%rbp)
	cmpl	$2, -8(%rbp)
	jne	.L14
	cmpl	$1, -16(%rbp)
	jne	.L14
	cmpl	$4, -24(%rbp)
	jne	.L14
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L15
.L14:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L15:
	movl	$0, %eax
	leave
	ret
	.section	.note.GNU-stack,"",@progbits


c:
#include <stdio.h>

void reverse(int* arr, int start, int end) {
    for (; start < end; start++, end--) {
        int tmp = arr[start];
        arr[start] = arr[end];
        arr[end] = tmp;
    }
}

void rotate(int* nums, int numsSize, int k) {
    if (numsSize == 1)
        return;
    k %= numsSize;

    reverse(nums, 0, numsSize - 1);
    reverse(nums, 0, k - 1);
    reverse(nums, k, numsSize - 1);
}

int main() {
    int nums1[7] = {1, 2, 3, 4, 5, 6, 7};
    rotate(nums1, 7, 3);
    int target1[7] = {5, 6, 7, 1, 2, 3, 4};
    for(int i = 0; i < 7; i++) {
        if(nums1[i] != target1[i]) {
            printf("<<<FUNCTION FAILURE>>>\n");
            return 1;
        }
    }

    int nums2[4] = {-1, -100, 3, 99};
    rotate(nums2, 4, 2);
    int target2[4] = {3, 99, -1, -100};
    for(int i = 0; i < 4; i++) {
        if(nums2[i] != target2[i]) {
            printf("<<<FUNCTION FAILURE>>>\n");
            return 1;
        }
    }

    printf("<<<FUNCTION SUCCESS>>>\n");
    return 0;
}

s:
	.text
	.globl	reverse
reverse:
	pushq	%rbp
	movq	%rsp, %rbp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	jmp	.L2
.L3:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	addl	$1, -28(%rbp)
	subl	$1, -32(%rbp)
.L2:
	movl	-28(%rbp), %eax
	cmpl	-32(%rbp), %eax
	jl	.L3
	nop
	nop
	popq	%rbp
	ret
	.globl	rotate
rotate:
	pushq	%rbp
	movq	%rsp, %rbp
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	%edx, -16(%rbp)
	cmpl	$1, -12(%rbp)
	je	.L7
	movl	-16(%rbp), %eax
	cltd
	idivl	-12(%rbp)
	movl	%edx, -16(%rbp)
	movl	-12(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-8(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	reverse
	movl	-16(%rbp), %eax
	leal	-1(%rax), %edx
	movq	-8(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	reverse
	movl	-12(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-16(%rbp), %ecx
	movq	-8(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	reverse
	jmp	.L4
.L7:
	nop
.L4:
	leave
	ret
	.section	.rodata
.LC0:
	.string	"<<<FUNCTION FAILURE>>>"
.LC1:
	.string	"<<<FUNCTION SUCCESS>>>"
	.text
	.globl	main
main:
	pushq	%rbp
	movq	%rsp, %rbp
	subq	$112, %rsp
	movl	$1, -48(%rbp)
	movl	$2, -44(%rbp)
	movl	$3, -40(%rbp)
	movl	$4, -36(%rbp)
	movl	$5, -32(%rbp)
	movl	$6, -28(%rbp)
	movl	$7, -24(%rbp)
	leaq	-48(%rbp), %rax
	movl	$3, %edx
	movl	$7, %esi
	movq	%rax, %rdi
	call	rotate
	movl	$5, -80(%rbp)
	movl	$6, -76(%rbp)
	movl	$7, -72(%rbp)
	movl	$1, -68(%rbp)
	movl	$2, -64(%rbp)
	movl	$3, -60(%rbp)
	movl	$4, -56(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L9
.L12:
	movl	-4(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-4(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L10
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %eax
	jmp	.L16
.L10:
	addl	$1, -4(%rbp)
.L9:
	cmpl	$6, -4(%rbp)
	jle	.L12
	movl	$-1, -96(%rbp)
	movl	$-100, -92(%rbp)
	movl	$3, -88(%rbp)
	movl	$99, -84(%rbp)
	leaq	-96(%rbp), %rax
	movl	$2, %edx
	movl	$4, %esi
	movq	%rax, %rdi
	call	rotate
	movl	$3, -112(%rbp)
	movl	$99, -108(%rbp)
	movl	$-1, -104(%rbp)
	movl	$-100, -100(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L13
.L15:
	movl	-8(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %edx
	movl	-8(%rbp), %eax
	cltq
	movl	-112(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L14
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %eax
	jmp	.L16
.L14:
	addl	$1, -8(%rbp)
.L13:
	cmpl	$3, -8(%rbp)
	jle	.L15
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L16:
	leave
	ret
	.section	.note.GNU-stack,"",@progbits


c:
#include <stdio.h>

void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n) {
    if(n == 0)return;
    int len1 = nums1Size;
    int end_idx = len1-1;
    while(n > 0 && m > 0){
        if(nums2[n-1] >= nums1[m-1]){
        nums1[end_idx] = nums2[n-1];
        n--;
        }else{
            nums1[end_idx] = nums1[m-1];
            m--;
        }
        end_idx--;
    }
    while (n > 0) {
        nums1[end_idx] = nums2[n-1];
        n--;
        end_idx--;
    }
}

int main() {
    int nums1[10] = {1, 2, 3, 0, 0, 0};
    int nums2[3] = {2, 5, 6};
    merge(nums1, 6, 3, nums2, 3, 3);
    int target1[6] = {1, 2, 2, 3, 5, 6};
    for(int i = 0; i < 6; i++) {
        if(nums1[i] != target1[i]) {
            printf("<<<FUNCTION FAILURE>>>\n");
            return 1;
        }
    }

    int nums3[5] = {4, 5, 6, 0, 0};
    int nums4[2] = {1, 2};
    merge(nums3, 5, 3, nums4, 2, 2);
    int target2[5] = {1, 2, 4, 5, 6};
    for(int i = 0; i < 5; i++) {
        if(nums3[i] != target2[i]) {
            printf("<<<FUNCTION FAILURE>>>\n");
            return 1;
        }
    }

    printf("<<<FUNCTION SUCCESS>>>\n");
    return 0;
}

s:
	.text
	.globl	merge
merge:
	pushq	%rbp
	movq	%rsp, %rbp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movq	%rcx, -40(%rbp)
	movl	%r8d, -44(%rbp)
	movl	%r9d, -48(%rbp)
	cmpl	$0, -48(%rbp)
	je	.L11
	movl	-28(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -4(%rbp)
	jmp	.L4
.L8:
	movl	-48(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-32(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L5
	movl	-48(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	subl	$1, -48(%rbp)
	jmp	.L6
.L5:
	movl	-32(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	subl	$1, -32(%rbp)
.L6:
	subl	$1, -4(%rbp)
.L4:
	cmpl	$0, -48(%rbp)
	jle	.L9
	cmpl	$0, -32(%rbp)
	jg	.L8
	jmp	.L9
.L10:
	movl	-48(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	subl	$1, -48(%rbp)
	subl	$1, -4(%rbp)
.L9:
	cmpl	$0, -48(%rbp)
	jg	.L10
	jmp	.L1
.L11:
	nop
.L1:
	popq	%rbp
	ret
	.section	.rodata
.LC0:
	.string	"<<<FUNCTION FAILURE>>>"
.LC1:
	.string	"<<<FUNCTION SUCCESS>>>"
	.text
	.globl	main
main:
	pushq	%rbp
	movq	%rsp, %rbp
	subq	$160, %rsp
	pxor	%xmm0, %xmm0
	movaps	%xmm0, -48(%rbp)
	movaps	%xmm0, -32(%rbp)
	movq	%xmm0, -16(%rbp)
	movl	$1, -48(%rbp)
	movl	$2, -44(%rbp)
	movl	$3, -40(%rbp)
	movl	$2, -60(%rbp)
	movl	$5, -56(%rbp)
	movl	$6, -52(%rbp)
	leaq	-60(%rbp), %rdx
	leaq	-48(%rbp), %rax
	movl	$3, %r9d
	movl	$3, %r8d
	movq	%rdx, %rcx
	movl	$3, %edx
	movl	$6, %esi
	movq	%rax, %rdi
	call	merge
	movl	$1, -96(%rbp)
	movl	$2, -92(%rbp)
	movl	$2, -88(%rbp)
	movl	$3, -84(%rbp)
	movl	$5, -80(%rbp)
	movl	$6, -76(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L13
.L16:
	movl	-4(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-4(%rbp), %eax
	cltq
	movl	-96(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L14
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %eax
	jmp	.L20
.L14:
	addl	$1, -4(%rbp)
.L13:
	cmpl	$5, -4(%rbp)
	jle	.L16
	movl	$4, -128(%rbp)
	movl	$5, -124(%rbp)
	movl	$6, -120(%rbp)
	movl	$0, -116(%rbp)
	movl	$0, -112(%rbp)
	movl	$1, -136(%rbp)
	movl	$2, -132(%rbp)
	leaq	-136(%rbp), %rdx
	leaq	-128(%rbp), %rax
	movl	$2, %r9d
	movl	$2, %r8d
	movq	%rdx, %rcx
	movl	$3, %edx
	movl	$5, %esi
	movq	%rax, %rdi
	call	merge
	movl	$1, -160(%rbp)
	movl	$2, -156(%rbp)
	movl	$4, -152(%rbp)
	movl	$5, -148(%rbp)
	movl	$6, -144(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L17
.L19:
	movl	-8(%rbp), %eax
	cltq
	movl	-128(%rbp,%rax,4), %edx
	movl	-8(%rbp), %eax
	cltq
	movl	-160(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L18
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %eax
	jmp	.L20
.L18:
	addl	$1, -8(%rbp)
.L17:
	cmpl	$4, -8(%rbp)
	jle	.L19
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L20:
	leave
	ret
	.section	.note.GNU-stack,"",@progbits


c:
#include <stdio.h>

int missingNumber(int* nums, int numsSize) {
    int res = numsSize;
    for(int i = 0; i != numsSize; i++){
        res = res + i - nums[i];
    }
    return res;
}

int main() {
    int nums1[4] = {3, 0, 1};
    int result1 = missingNumber(nums1, 3);
    if(result1 != 2) {
        printf("<<<FUNCTION FAILURE>>>\n");
        return 1;
    }

    int nums2[5] = {0, 1, 2, 3, 5};
    int result2 = missingNumber(nums2, 5);
    if(result2 != 4) {
        printf("<<<FUNCTION FAILURE>>>\n");
        return 1;
    }

    printf("<<<FUNCTION SUCCESS>>>\n");
    return 0;
}

s:
	.text
	.globl	missingNumber
missingNumber:
	pushq	%rbp
	movq	%rsp, %rbp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L2
.L3:
	movl	-4(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%eax, %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	subl	%eax, %edx
	movl	%edx, -4(%rbp)
	addl	$1, -8(%rbp)
.L2:
	movl	-8(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jne	.L3
	movl	-4(%rbp), %eax
	popq	%rbp
	ret
	.section	.rodata
.LC0:
	.string	"<<<FUNCTION FAILURE>>>"
.LC1:
	.string	"<<<FUNCTION SUCCESS>>>"
	.text
	.globl	main
main:
	pushq	%rbp
	movq	%rsp, %rbp
	subq	$64, %rsp
	movq	$0, -32(%rbp)
	movq	$0, -24(%rbp)
	movl	$3, -32(%rbp)
	movl	$1, -24(%rbp)
	leaq	-32(%rbp), %rax
	movl	$3, %esi
	movq	%rax, %rdi
	call	missingNumber
	movl	%eax, -4(%rbp)
	cmpl	$2, -4(%rbp)
	je	.L6
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %eax
	jmp	.L9
.L6:
	movl	$0, -64(%rbp)
	movl	$1, -60(%rbp)
	movl	$2, -56(%rbp)
	movl	$3, -52(%rbp)
	movl	$5, -48(%rbp)
	leaq	-64(%rbp), %rax
	movl	$5, %esi
	movq	%rax, %rdi
	call	missingNumber
	movl	%eax, -8(%rbp)
	cmpl	$4, -8(%rbp)
	je	.L8
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$1, %eax
	jmp	.L9
.L8:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L9:
	leave
	ret
	.section	.note.GNU-stack,"",@progbits