// File: /workspace/github_c_makefile_star2_O3/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
leaq 0x4d59(%rip), %rdx      # 0x604b
callq 0x10c0
shll $0x18, %eax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0xff000000, %eax       # imm = 0xFF000000
je 0x136f
movq 0x6cd3(%rip), %r13      # 0x7fe0
leaq 0x4d37(%rip), %r12      # 0x604b
sarl $0x18, %eax
cmpl $0x46, %eax
je 0x134c
cmpl $0x4e, %eax
je 0x133b
cmpl $0x4d, %eax
jne 0x14de
movq (%r13), %rdi
callq 0x10d0
movl %eax, 0x7027(%rip)      # 0x8360
jmp 0x1357
movq (%r13), %rdi
callq 0x10d0
movl %eax, 0x701a(%rip)      # 0x8364
jmp 0x1357
movq (%r13), %rdi
callq 0x10d0
movl %eax, %ebx
movl %r15d, %edi
movq %r14, %rsi
movq %r12, %rdx
callq 0x10c0
shll $0x18, %eax
cmpl $0xff000000, %eax       # imm = 0xFF000000
jne 0x1314
xorl %eax, %eax
callq 0x53aa
movl 0x6fe4(%rip), %edi      # 0x8360
movl 0x6fe2(%rip), %esi      # 0x8364
leaq 0x6fe7(%rip), %rdx      # 0x8370
leaq 0x46fe0(%rip), %rcx     # 0x48370
callq 0x5525
leaq 0x4cb6(%rip), %rdi      # 0x6052
leaq 0x4cb7(%rip), %rsi      # 0x605a
callq 0x10b0
testq %rax, %rax
je 0x14f4
movq %rax, %r15
leaq 0x4ccd(%rip), %rsi      # 0x6088
leaq 0x86fae(%rip), %rdx     # 0x88370
leaq 0x86fa8(%rip), %rcx     # 0x88371
xorl %r14d, %r14d
movq %rax, %rdi
xorl %eax, %eax
callq 0x1090
movq %r15, %rdi
callq 0x1040
cmpl $-0x1, %ebx
je 0x1456
movb $0x21, 0x86f86(%rip)    # 0x88370
movslq %ebx, %rax
shlq $0x5, %rax
leaq 0x86f98(%rip), %r8      # 0x88390
movl 0x6f62(%rip), %edi      # 0x8360
movl 0x6f60(%rip), %esi      # 0x8364
leaq 0x6f65(%rip), %r15      # 0x8370
leaq 0x46f5e(%rip), %r12     # 0x48370
movq %r15, %rdx
movq %r12, %rcx
callq *(%r8,%rax)
movb $0x22, 0x86f4e(%rip)    # 0x88371
movl 0x6f37(%rip), %esi      # 0x8360
movl 0x6f35(%rip), %edx      # 0x8364
movl %ebx, %edi
movq %r15, %rcx
movq %r12, %r8
callq 0x11fc
incl %ebx
testl %eax, %eax
cmovel %ebx, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x86f23(%rip), %r12     # 0x88380
cmpl $0x0, (%r12)
jle 0x1444
leaq 0x86f25(%rip), %r13     # 0x88390
xorl %r14d, %r14d
leaq 0x6efb(%rip), %rbx      # 0x8370
leaq 0x46ef4(%rip), %r15     # 0x48370
movb $0x21, 0x86eed(%rip)    # 0x88370
movl 0x6ed7(%rip), %edi      # 0x8360
movl 0x6ed5(%rip), %esi      # 0x8364
movq %rbx, %rdx
movq %r15, %rcx
callq *(%r13)
movb $0x22, 0x86ed1(%rip)    # 0x88371
movl 0x6eba(%rip), %esi      # 0x8360
movl 0x6eb8(%rip), %edx      # 0x8364
movl %r14d, %edi
movq %rbx, %rcx
movq %r15, %r8
callq 0x11fc
testl %eax, %eax
je 0x14d6
incq %r14
movslq (%r12), %rax
addq $0x20, %r13
cmpq %rax, %r14
jl 0x147c
xorl %r14d, %r14d
jmp 0x1444
incl %r14d
jmp 0x1444
leaq 0x4bad(%rip), %rdi      # 0x6092
callq 0x1030
movl $0x1, %edi
callq 0x10e0
leaq 0x4b61(%rip), %rdi      # 0x605c
leaq 0x4b64(%rip), %rsi      # 0x6066
leaq 0x4b68(%rip), %rcx      # 0x6071
movl $0x51, %edx
callq 0x1060