// File: /workspace/github_c_makefile_star2_O2/YanjieZe[P]CacheLab/tracegen.c
// Function: main
int main(int argc, char* argv[]){
    int i;

    char c;
    int selectedFunc=-1;
    while( (c=getopt(argc,argv,"M:N:F:")) != -1){
        switch(c){
        case 'M':
            M = atoi(optarg);
            break;
        case 'N':
            N = atoi(optarg);
            break;
        case 'F':
            selectedFunc = atoi(optarg);
            break;
        case '?':
        default:
            printf("./tracegen failed to parse its options.\n");
            exit(1);
        }
    }
  

    /*  Register transpose functions */
    registerFunctions();

    /* Fill A with data */
    initMatrix(M,N, A, B); 

    /* Record marker addresses */
    FILE* marker_fp = fopen(".marker","w");
    assert(marker_fp);
    fprintf(marker_fp, "%llx %llx", 
            (unsigned long long int) &MARKER_START,
            (unsigned long long int) &MARKER_END );
    fclose(marker_fp);

    if (-1==selectedFunc) {
        /* Invoke registered transpose functions */
        for (i=0; i < func_counter; i++) {
            MARKER_START = 33;
            (*func_list[i].func_ptr)(M, N, A, B);
            MARKER_END = 34;
            if (!validate(i,M,N,A,B))
                return i+1;
        }
    } else {
        MARKER_START = 33;
        (*func_list[selectedFunc].func_ptr)(M, N, A, B);
        MARKER_END = 34;
        if (!validate(selectedFunc,M,N,A,B))
            return selectedFunc+1;

    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %r15d
pushq $-0x1
popq %rbx
leaq 0x4d5a(%rip), %r12      # 0x604b
movq 0x6ce8(%rip), %r13      # 0x7fe0
movl %r15d, %edi
movq %r14, %rsi
movq %r12, %rdx
callq 0x10c0
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
je 0x1355
sarl $0x18, %eax
cmpl $0x4d, %eax
je 0x132e
cmpl $0x4e, %eax
jne 0x133f
movq (%r13), %rdi
callq 0x10d0
movl %eax, 0x7038(%rip)      # 0x8364
jmp 0x12f8
movq (%r13), %rdi
callq 0x10d0
movl %eax, 0x7023(%rip)      # 0x8360
jmp 0x12f8
cmpl $0x46, %eax
jne 0x14b6
movq (%r13), %rdi
callq 0x10d0
movl %eax, %ebx
jmp 0x12f8
xorl %eax, %eax
callq 0x537e
movl 0x6ffe(%rip), %edi      # 0x8360
movl 0x6ffc(%rip), %esi      # 0x8364
leaq 0x7001(%rip), %rdx      # 0x8370
leaq 0x46ffa(%rip), %rcx     # 0x48370
callq 0x54f7
leaq 0x4cd0(%rip), %rdi      # 0x6052
leaq 0x4cd1(%rip), %rsi      # 0x605a
callq 0x10b0
testq %rax, %rax
je 0x14ca
movq %rax, %r15
leaq 0x4ce7(%rip), %rsi      # 0x6088
leaq 0x86fc8(%rip), %rdx     # 0x88370
leaq 0x86fc2(%rip), %rcx     # 0x88371
xorl %r14d, %r14d
movq %rax, %rdi
xorl %eax, %eax
callq 0x1090
movq %r15, %rdi
callq 0x1040
cmpl $-0x1, %ebx
je 0x142c
movb $0x21, 0x86fa0(%rip)    # 0x88370
movslq %ebx, %rax
shlq $0x5, %rax
leaq 0x86fb2(%rip), %r8      # 0x88390
movl 0x6f7c(%rip), %edi      # 0x8360
movl 0x6f7a(%rip), %esi      # 0x8364
leaq 0x6f7f(%rip), %r15      # 0x8370
leaq 0x46f78(%rip), %r12     # 0x48370
movq %r15, %rdx
movq %r12, %rcx
callq *(%r8,%rax)
movb $0x22, 0x86f68(%rip)    # 0x88371
movl 0x6f51(%rip), %esi      # 0x8360
movl 0x6f4f(%rip), %edx      # 0x8364
movl %ebx, %edi
movq %r15, %rcx
movq %r12, %r8
callq 0x11fc
incl %ebx
testl %eax, %eax
cmovel %ebx, %r14d
jmp 0x14a4
leaq 0x86f5d(%rip), %r13     # 0x88390
leaq 0x86f46(%rip), %r14     # 0x88380
leaq 0x6f2f(%rip), %rbx      # 0x8370
leaq 0x46f28(%rip), %r12     # 0x48370
xorl %r15d, %r15d
movslq (%r14), %rax
cmpq %rax, %r15
jge 0x14a1
movb $0x21, 0x86f16(%rip)    # 0x88370
movl 0x6f00(%rip), %edi      # 0x8360
movl 0x6efe(%rip), %esi      # 0x8364
movq %rbx, %rdx
movq %r12, %rcx
callq *(%r13)
movb $0x22, 0x86efa(%rip)    # 0x88371
movl 0x6ee3(%rip), %esi      # 0x8360
movl 0x6ee1(%rip), %edx      # 0x8364
movl %r15d, %edi
movq %rbx, %rcx
movq %r12, %r8
callq 0x11fc
incq %r15
addq $0x20, %r13
testl %eax, %eax
jne 0x144b
movl %r15d, %r14d
jmp 0x14a4
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4bd5(%rip), %rdi      # 0x6092
callq 0x1030
pushq $0x1
popq %rdi
callq 0x10e0
leaq 0x4b8b(%rip), %rdi      # 0x605c
leaq 0x4b8e(%rip), %rsi      # 0x6066
leaq 0x4b92(%rip), %rcx      # 0x6071
pushq $0x51
popq %rdx
callq 0x1060