// File: /workspace/github_c_makefile_star2_O0/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
subq $0x30, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0x4ce0(%rip), %rdx      # 0x608b
callq 0x10b0
movb %al, -0x15(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0x1446
movsbl -0x15(%rbp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0xf, %eax
ja 0x1429
movq -0x30(%rbp), %rax
leaq 0x4c28(%rip), %rcx      # 0x6004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x6bf4(%rip), %rax      # 0x7fe0
movq (%rax), %rdi
callq 0x10c0
movl %eax, 0x6f66(%rip)      # 0x8360
jmp 0x1441
movq 0x6bdd(%rip), %rax      # 0x7fe0
movq (%rax), %rdi
callq 0x10c0
movl %eax, 0x6f53(%rip)      # 0x8364
jmp 0x1441
movq 0x6bc6(%rip), %rax      # 0x7fe0
movq (%rax), %rdi
callq 0x10c0
movl %eax, -0x1c(%rbp)
jmp 0x1441
jmp 0x1429
leaq 0x4c62(%rip), %rdi      # 0x6092
movb $0x0, %al
callq 0x1040
movl $0x1, %edi
callq 0x10d0
jmp 0x139d
movb $0x0, %al
callq 0x549b
movl 0x6f0d(%rip), %edi      # 0x8360
movl 0x6f0b(%rip), %esi      # 0x8364
leaq 0x6f10(%rip), %rdx      # 0x8370
leaq 0x46f09(%rip), %rcx     # 0x48370
callq 0x5630
leaq 0x4c48(%rip), %rdi      # 0x60bb
leaq 0x4c49(%rip), %rsi      # 0x60c3
callq 0x10a0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x148c
jmp 0x14ab
leaq 0x4c32(%rip), %rdi      # 0x60c5
leaq 0x4c35(%rip), %rsi      # 0x60cf
movl $0x51, %edx
leaq 0x4c34(%rip), %rcx      # 0x60da
callq 0x1050
movq -0x28(%rbp), %rdi
leaq 0x4c3b(%rip), %rsi      # 0x60f1
leaq 0x86eb3(%rip), %rdx     # 0x88370
leaq 0x86ead(%rip), %rcx     # 0x88371
movb $0x0, %al
callq 0x1080
movq -0x28(%rbp), %rdi
callq 0x1030
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl -0x1c(%rbp), %eax
jne 0x1581
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0x86e8d(%rip), %rcx     # 0x88380
cmpl (%rcx), %eax
jge 0x157f
movb $0x21, 0x86e6e(%rip)    # 0x88370
movslq -0x14(%rbp), %rcx
leaq 0x86e83(%rip), %rax     # 0x88390
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl 0x6e43(%rip), %edi      # 0x8360
movl 0x6e41(%rip), %esi      # 0x8364
leaq 0x6e46(%rip), %rdx      # 0x8370
leaq 0x46e3f(%rip), %rcx     # 0x48370
callq *%rax
movb $0x22, 0x86e37(%rip)    # 0x88371
movl -0x14(%rbp), %edi
movl 0x6e1d(%rip), %esi      # 0x8360
movl 0x6e1b(%rip), %edx      # 0x8364
leaq 0x6e20(%rip), %rcx      # 0x8370
leaq 0x46e19(%rip), %r8      # 0x48370
callq 0x11f0
cmpl $0x0, %eax
jne 0x156f
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x15fb
jmp 0x1571
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x14e9
jmp 0x15f4
movb $0x21, 0x86de8(%rip)    # 0x88370
movslq -0x1c(%rbp), %rcx
leaq 0x86dfd(%rip), %rax     # 0x88390
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl 0x6dbd(%rip), %edi      # 0x8360
movl 0x6dbb(%rip), %esi      # 0x8364
leaq 0x6dc0(%rip), %rdx      # 0x8370
leaq 0x46db9(%rip), %rcx     # 0x48370
callq *%rax
movb $0x22, 0x86db1(%rip)    # 0x88371
movl -0x1c(%rbp), %edi
movl 0x6d97(%rip), %esi      # 0x8360
movl 0x6d95(%rip), %edx      # 0x8364
leaq 0x6d9a(%rip), %rcx      # 0x8370
leaq 0x46d93(%rip), %r8      # 0x48370
callq 0x11f0
cmpl $0x0, %eax
jne 0x15f2
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x15fb
jmp 0x15f4
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq