// File: /workspace/github_c_makefile_star2_O2/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:
pushq %r14
pushq %rbx
subq $0x18, %rsp
stmxcsr 0x14(%rsp)
movl 0x14(%rsp), %eax
andl $-0x41, %eax
movl %eax, 0x10(%rsp)
ldmxcsr 0x10(%rsp)
stmxcsr 0xc(%rsp)
movl $0xffff7fff, %eax       # imm = 0xFFFF7FFF
andl 0xc(%rsp), %eax
movl %eax, 0x8(%rsp)
ldmxcsr 0x8(%rsp)
pushq $0x3
popq %rdx
pushq $-0x1
popq %r8
movl $0x80000, %esi          # imm = 0x80000
xorl %edi, %edi
movl $0x48022, %ecx          # imm = 0x48022
xorl %r9d, %r9d
callq 0x401070
movq %rax, 0x17657(%rip)     # 0x419800
cmpq $-0x1, %rax
je 0x402344
movq $0x407000, %rdi         # imm = 0x407000
pushq $0x7
popq %rdx
movl $0x1000, %esi           # imm = 0x1000
callq 0x401130
testl %eax, %eax
jne 0x40235d
movq $0x40a000, %rdi         # imm = 0x40A000
pushq $0x7
popq %rdx
movl $0x1000, %esi           # imm = 0x1000
callq 0x401130
testl %eax, %eax
jne 0x402376
leaq 0x9e76(%rip), %rdi      # 0x40c068
callq 0x401050
xorl %eax, %eax
callq 0x40b22d
testl %eax, %eax
je 0x402210
movq $0x408090, %rdi         # imm = 0x408090
callq 0x402393
jmp 0x40221c
leaq 0x9e5f(%rip), %rdi      # 0x40c076
callq 0x401050
leaq 0x9e75(%rip), %rdi      # 0x40c098
callq 0x401050
movq $0x407000, %rdi         # imm = 0x407000
callq 0x402393
leaq 0x9e6b(%rip), %rdi      # 0x40c0a6
callq 0x401050
leaq 0x22d(%rip), %rsi       # 0x402474
pushq $0x1
popq %rbx
movl %ebx, %edi
xorl %edx, %edx
callq 0x40b135
movq %rax, %r14
movl $0x7d0, %edi            # imm = 0x7D0
callq 0x4011a0
movq $0x40a000, %rdi         # imm = 0x40A000
callq 0x402393
movq %r14, %rdi
callq 0x40b20a
leaq 0x9e39(%rip), %rdi      # 0x40c0b4
callq 0x401050
movq $0x403500, %rdi         # imm = 0x403500
callq 0x402393
leaq 0x9e2e(%rip), %rdi      # 0x40c0c1
callq 0x401050
movq $0x403c80, %rdi         # imm = 0x403C80
callq 0x402393
leaq 0x9e2a(%rip), %rdi      # 0x40c0d5
callq 0x401050
movq $0x4047e7, %rdi         # imm = 0x4047E7
callq 0x402393
leaq 0x9e1f(%rip), %rdi      # 0x40c0e2
callq 0x401050
movq $0x404f3b, %rdi         # imm = 0x404F3B
callq 0x402393
leaq 0x1a1(%rip), %rsi       # 0x40247c
movl %ebx, %edi
xorl %edx, %edx
callq 0x40b135
movq %rax, %rbx
movl $0x7d0, %edi            # imm = 0x7D0
callq 0x4011a0
leaq 0x9dfe(%rip), %rdi      # 0x40c0f6
callq 0x401050
movq $0x405725, %rdi         # imm = 0x405725
callq 0x402393
movq %rbx, %rdi
callq 0x40b20a
leaq 0x9deb(%rip), %rdi      # 0x40c103
callq 0x401050
movq $0x402ced, %rdi         # imm = 0x402CED
callq 0x402393
leaq 0x9de1(%rip), %rdi      # 0x40c111
callq 0x401050
callq 0x402484
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
leaq 0x9ccc(%rip), %rdi      # 0x40c017
leaq 0x9cde(%rip), %rsi      # 0x40c030
leaq 0x9cef(%rip), %rcx      # 0x40c048
pushq $0x41
jmp 0x40238d
leaq 0x9cfb(%rip), %rdi      # 0x40c05f
leaq 0x9cc5(%rip), %rsi      # 0x40c030
leaq 0x9cd6(%rip), %rcx      # 0x40c048
pushq $0x44
jmp 0x40238d
leaq 0x9ce2(%rip), %rdi      # 0x40c05f
leaq 0x9cac(%rip), %rsi      # 0x40c030
leaq 0x9cbd(%rip), %rcx      # 0x40c048
pushq $0x47
popq %rdx
callq 0x401090