// File: /workspace/github_c_makefile_star2_O1/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 0x4d60(%rip), %rdx      # 0x604b
callq 0x10c0
shll $0x18, %eax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0xff000000, %eax       # imm = 0xFF000000
je 0x1368
movq 0x6cda(%rip), %r13      # 0x7fe0
leaq 0x4d3e(%rip), %r12      # 0x604b
sarl $0x18, %eax
cmpl $0x46, %eax
je 0x1345
cmpl $0x4e, %eax
je 0x1334
cmpl $0x4d, %eax
jne 0x14d7
movq (%r13), %rdi
callq 0x10d0
movl %eax, 0x702e(%rip)      # 0x8360
jmp 0x1350
movq (%r13), %rdi
callq 0x10d0
movl %eax, 0x7021(%rip)      # 0x8364
jmp 0x1350
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 0x130d
xorl %eax, %eax
callq 0x53a3
movl 0x6feb(%rip), %edi      # 0x8360
movl 0x6fe9(%rip), %esi      # 0x8364
leaq 0x6fee(%rip), %rdx      # 0x8370
leaq 0x46fe7(%rip), %rcx     # 0x48370
callq 0x5521
leaq 0x4cbd(%rip), %rdi      # 0x6052
leaq 0x4cbe(%rip), %rsi      # 0x605a
callq 0x10b0
testq %rax, %rax
je 0x14ed
movq %rax, %r15
leaq 0x4cd4(%rip), %rsi      # 0x6088
leaq 0x86fb5(%rip), %rdx     # 0x88370
leaq 0x86faf(%rip), %rcx     # 0x88371
xorl %r14d, %r14d
movq %rax, %rdi
xorl %eax, %eax
callq 0x1090
movq %r15, %rdi
callq 0x1040
cmpl $-0x1, %ebx
je 0x144f
movb $0x21, 0x86f8d(%rip)    # 0x88370
movslq %ebx, %rax
shlq $0x5, %rax
leaq 0x86f9f(%rip), %r8      # 0x88390
movl 0x6f69(%rip), %edi      # 0x8360
movl 0x6f67(%rip), %esi      # 0x8364
leaq 0x6f6c(%rip), %r15      # 0x8370
leaq 0x46f65(%rip), %r12     # 0x48370
movq %r15, %rdx
movq %r12, %rcx
callq *(%r8,%rax)
movb $0x22, 0x86f55(%rip)    # 0x88371
movl 0x6f3e(%rip), %esi      # 0x8360
movl 0x6f3c(%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 0x86f2a(%rip), %r12     # 0x88380
cmpl $0x0, (%r12)
jle 0x143d
leaq 0x86f2c(%rip), %r13     # 0x88390
xorl %r14d, %r14d
leaq 0x6f02(%rip), %rbx      # 0x8370
leaq 0x46efb(%rip), %r15     # 0x48370
movb $0x21, 0x86ef4(%rip)    # 0x88370
movl 0x6ede(%rip), %edi      # 0x8360
movl 0x6edc(%rip), %esi      # 0x8364
movq %rbx, %rdx
movq %r15, %rcx
callq *(%r13)
movb $0x22, 0x86ed8(%rip)    # 0x88371
movl 0x6ec1(%rip), %esi      # 0x8360
movl 0x6ebf(%rip), %edx      # 0x8364
movl %r14d, %edi
movq %rbx, %rcx
movq %r15, %r8
callq 0x11fc
testl %eax, %eax
je 0x14cf
incq %r14
movslq (%r12), %rax
addq $0x20, %r13
cmpq %rax, %r14
jl 0x1475
xorl %r14d, %r14d
jmp 0x143d
incl %r14d
jmp 0x143d
leaq 0x4bb4(%rip), %rdi      # 0x6092
callq 0x1030
movl $0x1, %edi
callq 0x10e0
leaq 0x4b68(%rip), %rdi      # 0x605c
leaq 0x4b6b(%rip), %rsi      # 0x6066
leaq 0x4b6f(%rip), %rcx      # 0x6071
movl $0x51, %edx
callq 0x1060