// File: /workspace/github_c_makefile_star2_O0/vusec[P]fpvi-scsb/leak_rate_win_size/exception_suppression.c
// Function: main
int main(int argc, char **argv)
{
    int ret;
    pthread_t tid;

    //Ensure defualt settings for FP
    _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_OFF);
    _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_OFF);

    reload_buf   = (unsigned char *) mmap(NULL, 2*LEAK_SIZE*STRIDE, PROT_READ | PROT_WRITE,
                                          MAP_ANONYMOUS | MAP_PRIVATE | MAP_POPULATE | MAP_HUGETLB, -1, 0);
    assert(reload_buf != MAP_FAILED);
    
    ret = mprotect(&smc_win_size, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC);
    assert(ret == 0);
    
    ret = mprotect(&xmc_win_size, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC);
    assert(ret == 0);
    
    printf("tsx_win_size:\n");
    if(check_tsx())
    {
        win_size_run(tsx_win_size);
    }
    else
    {
        printf("Not supported on this processors!\n");
    }

    printf("smc_win_size:\n");
    win_size_run(smc_win_size);
    
    printf("xmc_win_size:\n");
    tid = create_thread(TRIGGER_CORE, xmc_trigger_loop, NULL);
    usleep(2000);                                             
    win_size_run(xmc_win_size);
    cancel_thread(tid);
    
    printf("fp_win_size:\n");
    win_size_run(fp_win_size);
    
    printf("fp_win_size_branch:\n");
    win_size_run(fp_win_size_branch);
    
    printf("md_win_size:\n");
    win_size_run(md_win_size);

    printf("md_win_size_branch:\n");
    win_size_run(md_win_size_branch);
    
    tid = create_thread(TRIGGER_CORE, mo_trigger_loop, NULL);
    usleep(2000);                                             
    printf("mo_win_size:\n");
    win_size_run(mo_win_size);
    cancel_thread(tid);
   
    printf("bht_win_size:\n");
    win_size_run(bht_win_size);
    
    printf("fault_win_size:\n");
    fault_win_size_run();
}

// Assembly:
subq $0x38, %rsp
movl $0x0, 0x34(%rsp)
movl %edi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
stmxcsr 0x14(%rsp)
movl 0x14(%rsp), %eax
andl $-0x41, %eax
orl $0x0, %eax
movl %eax, 0x10(%rsp)
ldmxcsr 0x10(%rsp)
stmxcsr 0xc(%rsp)
movl 0xc(%rsp), %eax
andl $0xffff7fff, %eax       # imm = 0xFFFF7FFF
orl $0x0, %eax
movl %eax, 0x8(%rsp)
ldmxcsr 0x8(%rsp)
xorl %eax, %eax
movl %eax, %r9d
movl $0x80000, %esi          # imm = 0x80000
movl $0x3, %edx
movl $0x48022, %ecx          # imm = 0x48022
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r9, %rdi
callq 0x401060
movq %rax, 0x175e0(%rip)     # 0x419800
movq $-0x1, %rax
cmpq %rax, 0x175d2(%rip)     # 0x419800
je 0x402232
jmp 0x402251
leaq 0x9dde(%rip), %rdi      # 0x40c017
leaq 0x9df0(%rip), %rsi      # 0x40c030
movl $0x41, %edx
leaq 0x9dfc(%rip), %rcx      # 0x40c048
callq 0x401080
movq $0x407000, %rdi         # imm = 0x407000
movl $0x1000, %esi           # imm = 0x1000
movl $0x7, %edx
callq 0x401130
movl %eax, 0x24(%rsp)
cmpl $0x0, 0x24(%rsp)
jne 0x402274
jmp 0x402293
leaq 0x9de4(%rip), %rdi      # 0x40c05f
leaq 0x9dae(%rip), %rsi      # 0x40c030
movl $0x44, %edx
leaq 0x9dba(%rip), %rcx      # 0x40c048
callq 0x401080
movq $0x40a000, %rdi         # imm = 0x40A000
movl $0x1000, %esi           # imm = 0x1000
movl $0x7, %edx
callq 0x401130
movl %eax, 0x24(%rsp)
cmpl $0x0, 0x24(%rsp)
jne 0x4022b6
jmp 0x4022d5
leaq 0x9da2(%rip), %rdi      # 0x40c05f
leaq 0x9d6c(%rip), %rsi      # 0x40c030
movl $0x47, %edx
leaq 0x9d78(%rip), %rcx      # 0x40c048
callq 0x401080
leaq 0x9d8c(%rip), %rdi      # 0x40c068
movb $0x0, %al
callq 0x401070
movb $0x0, %al
callq 0x40b2e0
cmpl $0x0, %eax
je 0x4022fd
movq $0x408090, %rdi         # imm = 0x408090
callq 0x402460
jmp 0x40230b
leaq 0x9d73(%rip), %rdi      # 0x40c077
movb $0x0, %al
callq 0x401070
leaq 0x9d88(%rip), %rdi      # 0x40c09a
movb $0x0, %al
callq 0x401070
movq $0x407000, %rdi         # imm = 0x407000
callq 0x402460
leaq 0x9d7d(%rip), %rdi      # 0x40c0a9
movb $0x0, %al
callq 0x401070
movl $0x1, %edi
leaq 0x2c1(%rip), %rsi       # 0x402600
xorl %eax, %eax
movl %eax, %edx
callq 0x40b190
movq %rax, 0x18(%rsp)
movl $0x7d0, %edi            # imm = 0x7D0
callq 0x401190
movq $0x40a000, %rdi         # imm = 0x40A000
callq 0x402460
movq 0x18(%rsp), %rdi
callq 0x40b2a0
leaq 0x9d44(%rip), %rdi      # 0x40c0b8
movb $0x0, %al
callq 0x401070
movq $0x403780, %rdi         # imm = 0x403780
callq 0x402460
leaq 0x9d38(%rip), %rdi      # 0x40c0c6
movb $0x0, %al
callq 0x401070
movq $0x403f00, %rdi         # imm = 0x403F00
callq 0x402460
leaq 0x9d33(%rip), %rdi      # 0x40c0db
movb $0x0, %al
callq 0x401070
movq $0x404a67, %rdi         # imm = 0x404A67
callq 0x402460
leaq 0x9d27(%rip), %rdi      # 0x40c0e9
movb $0x0, %al
callq 0x401070
movq $0x4051bb, %rdi         # imm = 0x4051BB
callq 0x402460
movl $0x1, %edi
leaq 0x22f(%rip), %rsi       # 0x402610
xorl %eax, %eax
movl %eax, %edx
callq 0x40b190
movq %rax, 0x18(%rsp)
movl $0x7d0, %edi            # imm = 0x7D0
callq 0x401190
leaq 0x9cfe(%rip), %rdi      # 0x40c0fe
movb $0x0, %al
callq 0x401070
movq $0x4059a5, %rdi         # imm = 0x4059A5
callq 0x402460
movq 0x18(%rsp), %rdi
callq 0x40b2a0
leaq 0x9ce8(%rip), %rdi      # 0x40c10c
movb $0x0, %al
callq 0x401070
movq $0x402f5d, %rdi         # imm = 0x402F5D
callq 0x402460
leaq 0x9cdd(%rip), %rdi      # 0x40c11b
movb $0x0, %al
callq 0x401070
callq 0x402620
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)