// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
stmxcsr 0xc(%rsp)
movl 0xc(%rsp), %eax
andl $-0x41, %eax
movl %eax, 0x8(%rsp)
ldmxcsr 0x8(%rsp)
stmxcsr 0x4(%rsp)
movl $0xffff7fff, %eax       # imm = 0xFFFF7FFF
andl 0x4(%rsp), %eax
movl %eax, (%rsp)
ldmxcsr (%rsp)
movl $0x80000, %esi          # imm = 0x80000
xorl %edi, %edi
movl $0x3, %edx
movl $0x48022, %ecx          # imm = 0x48022
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
callq 0x401070
movq %rax, 0x1761c(%rip)     # 0x419800
cmpq $-0x1, %rax
je 0x4029c9
movq $0x407000, %rdi         # imm = 0x407000
movl $0x1000, %esi           # imm = 0x1000
movl $0x7, %edx
callq 0x401130
testl %eax, %eax
jne 0x4029e8
movq $0x40a000, %rdi         # imm = 0x40A000
movl $0x1000, %esi           # imm = 0x1000
movl $0x7, %edx
callq 0x401130
testl %eax, %eax
jne 0x402a07
leaq 0x9e37(%rip), %rdi      # 0x40c068
callq 0x401050
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x40b209
testl %eax, %eax
je 0x40230d
xorl %edi, %edi
callq 0x40b064
leaq 0x16daa(%rip), %rbx     # 0x419000
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4010a0
movq 0x17594(%rip), %rax     # 0x419800
xorl %ecx, %ecx
leaq (%rax,%rcx), %rdx
clflush (%rdx)
addq $0x400, %rcx            # imm = 0x400
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x40226e
mfence
movq 0x17571(%rip), %rdi     # 0x419800
callq 0x408090
movq 0x17565(%rip), %rdi     # 0x419800
mfence
movl $0xd, %r8d
movzbl %r8b, %r9d
movl %r9d, %r10d
shll $0xa, %r10d
rdtscp
movq %rdx, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
movb (%rdi,%r10), %al
rdtscp
shlq $0x20, %rdx
orq %rax, %rdx
subq %rsi, %rdx
cmpq $0x9f, %rdx
ja 0x4022da
incq (%rbx,%r9,8)
addq $0xa7, %r8
cmpq $0xa70d, %r8            # imm = 0xA70D
jne 0x4022a4
incl %r14d
cmpl $0x2710, %r14d          # imm = 0x2710
jne 0x402265
leaq 0x16cff(%rip), %rdi     # 0x419000
movl $0x1, %esi
callq 0x402128
jmp 0x402319
leaq 0x9d62(%rip), %rdi      # 0x40c076
callq 0x401050
leaq 0x9d78(%rip), %rdi      # 0x40c098
callq 0x401050
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x40b064
leaq 0x16cca(%rip), %rbx     # 0x419000
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4010a0
movq 0x174b4(%rip), %rax     # 0x419800
xorl %ecx, %ecx
leaq (%rax,%rcx), %rdx
clflush (%rdx)
addq $0x400, %rcx            # imm = 0x400
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x40234e
mfence
movq 0x17491(%rip), %rdi     # 0x419800
callq 0x407000
movq 0x17485(%rip), %rdi     # 0x419800
mfence
movl $0xd, %r8d
movzbl %r8b, %r9d
movl %r9d, %r10d
shll $0xa, %r10d
rdtscp
movq %rdx, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
movb (%rdi,%r10), %al
rdtscp
shlq $0x20, %rdx
orq %rax, %rdx
subq %rsi, %rdx
cmpq $0x9f, %rdx
ja 0x4023ba
incq (%rbx,%r9,8)
addq $0xa7, %r8
cmpq $0xa70d, %r8            # imm = 0xA70D
jne 0x402384
incl %r14d
cmpl $0x2710, %r14d          # imm = 0x2710
jne 0x402345
movl $0x1, %esi
movq %rbx, %rdi
callq 0x402128
leaq 0x9cb8(%rip), %rdi      # 0x40c0a6
callq 0x401050
leaq 0x6fc(%rip), %rsi       # 0x402af6
xorl %r15d, %r15d
movl $0x1, %edi
xorl %edx, %edx
callq 0x40b10b
movq %rax, %r14
movl $0x7d0, %edi            # imm = 0x7D0
callq 0x4011a0
xorl %edi, %edi
callq 0x40b064
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4010a0
movq 0x173cd(%rip), %rax     # 0x419800
xorl %ecx, %ecx
leaq (%rax,%rcx), %rdx
clflush (%rdx)
addq $0x400, %rcx            # imm = 0x400
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x402435
mfence
movq 0x173aa(%rip), %rdi     # 0x419800
callq 0x40a000
movq 0x1739e(%rip), %rdi     # 0x419800
mfence
movl $0xd, %r8d
movzbl %r8b, %r9d
movl %r9d, %r10d
shll $0xa, %r10d
rdtscp
movq %rdx, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
movb (%rdi,%r10), %al
rdtscp
shlq $0x20, %rdx
orq %rax, %rdx
subq %rsi, %rdx
cmpq $0x9f, %rdx
ja 0x4024a1
incq (%rbx,%r9,8)
addq $0xa7, %r8
cmpq $0xa70d, %r8            # imm = 0xA70D
jne 0x40246b
incl %r15d
cmpl $0x2710, %r15d          # imm = 0x2710
jne 0x40242c
movl $0x1, %esi
movq %rbx, %rdi
callq 0x402128
movq %r14, %rdi
callq 0x40b1e4
leaq 0x9bd7(%rip), %rdi      # 0x40c0b4
callq 0x401050
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x40b064
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4010a0
movq 0x172fe(%rip), %rax     # 0x419800
xorl %ecx, %ecx
leaq (%rax,%rcx), %rdx
clflush (%rdx)
addq $0x400, %rcx            # imm = 0x400
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x402504
mfence
movq 0x172db(%rip), %rdi     # 0x419800
callq 0x403500
movq 0x172cf(%rip), %rdi     # 0x419800
mfence
movl $0xd, %r8d
movzbl %r8b, %r9d
movl %r9d, %r10d
shll $0xa, %r10d
rdtscp
movq %rdx, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
movb (%rdi,%r10), %al
rdtscp
shlq $0x20, %rdx
orq %rax, %rdx
subq %rsi, %rdx
cmpq $0x9f, %rdx
ja 0x402570
incq (%rbx,%r9,8)
addq $0xa7, %r8
cmpq $0xa70d, %r8            # imm = 0xA70D
jne 0x40253a
incl %r14d
cmpl $0x2710, %r14d          # imm = 0x2710
jne 0x4024fb
movl $0x1, %esi
movq %rbx, %rdi
callq 0x402128
leaq 0x9b1d(%rip), %rdi      # 0x40c0c1
callq 0x401050
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x40b064
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4010a0
movq 0x17237(%rip), %rax     # 0x419800
xorl %ecx, %ecx
leaq (%rax,%rcx), %rdx
clflush (%rdx)
addq $0x400, %rcx            # imm = 0x400
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x4025cb
mfence
movq 0x17214(%rip), %rdi     # 0x419800
callq 0x403c80
movq 0x17208(%rip), %rdi     # 0x419800
mfence
movl $0xd, %r8d
movzbl %r8b, %r9d
movl %r9d, %r10d
shll $0xa, %r10d
rdtscp
movq %rdx, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
movb (%rdi,%r10), %al
rdtscp
shlq $0x20, %rdx
orq %rax, %rdx
subq %rsi, %rdx
cmpq $0x9f, %rdx
ja 0x402637
incq (%rbx,%r9,8)
addq $0xa7, %r8
cmpq $0xa70d, %r8            # imm = 0xA70D
jne 0x402601
incl %r14d
cmpl $0x2710, %r14d          # imm = 0x2710
jne 0x4025c2
movl $0x1, %esi
movq %rbx, %rdi
callq 0x402128
leaq 0x9a6a(%rip), %rdi      # 0x40c0d5
callq 0x401050
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x40b064
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4010a0
movq 0x17170(%rip), %rax     # 0x419800
xorl %ecx, %ecx
leaq (%rax,%rcx), %rdx
clflush (%rdx)
addq $0x400, %rcx            # imm = 0x400
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x402692
mfence
movq 0x1714d(%rip), %rdi     # 0x419800
callq 0x4047e7
movq 0x17141(%rip), %rdi     # 0x419800
mfence
movl $0xd, %r8d
movzbl %r8b, %r9d
movl %r9d, %r10d
shll $0xa, %r10d
rdtscp
movq %rdx, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
movb (%rdi,%r10), %al
rdtscp
shlq $0x20, %rdx
orq %rax, %rdx
subq %rsi, %rdx
cmpq $0x9f, %rdx
ja 0x4026fe
incq (%rbx,%r9,8)
addq $0xa7, %r8
cmpq $0xa70d, %r8            # imm = 0xA70D
jne 0x4026c8
incl %r14d
cmpl $0x2710, %r14d          # imm = 0x2710
jne 0x402689
movl $0x1, %esi
movq %rbx, %rdi
callq 0x402128
leaq 0x99b0(%rip), %rdi      # 0x40c0e2
callq 0x401050
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x40b064
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4010a0
movq 0x170a9(%rip), %rax     # 0x419800
xorl %ecx, %ecx
leaq (%rax,%rcx), %rdx
clflush (%rdx)
addq $0x400, %rcx            # imm = 0x400
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x402759
mfence
movq 0x17086(%rip), %rdi     # 0x419800
callq 0x404f3b
movq 0x1707a(%rip), %rdi     # 0x419800
mfence
movl $0xd, %r8d
movzbl %r8b, %r9d
movl %r9d, %r10d
shll $0xa, %r10d
rdtscp
movq %rdx, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
movb (%rdi,%r10), %al
rdtscp
shlq $0x20, %rdx
orq %rax, %rdx
subq %rsi, %rdx
cmpq $0x9f, %rdx
ja 0x4027c5
incq (%rbx,%r9,8)
addq $0xa7, %r8
cmpq $0xa70d, %r8            # imm = 0xA70D
jne 0x40278f
incl %r14d
cmpl $0x2710, %r14d          # imm = 0x2710
jne 0x402750
movl $0x1, %esi
movq %rbx, %rdi
callq 0x402128
leaq 0x305(%rip), %rsi       # 0x402afe
xorl %r15d, %r15d
movl $0x1, %edi
xorl %edx, %edx
callq 0x40b10b
movq %rax, %r14
movl $0x7d0, %edi            # imm = 0x7D0
callq 0x4011a0
leaq 0x98da(%rip), %rdi      # 0x40c0f6
callq 0x401050
xorl %edi, %edi
callq 0x40b064
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4010a0
movq 0x16fc2(%rip), %rax     # 0x419800
xorl %ecx, %ecx
leaq (%rax,%rcx), %rdx
clflush (%rdx)
addq $0x400, %rcx            # imm = 0x400
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x402840
mfence
movq 0x16f9f(%rip), %rdi     # 0x419800
callq 0x405725
movq 0x16f93(%rip), %rdi     # 0x419800
mfence
movl $0xd, %r8d
movzbl %r8b, %r9d
movl %r9d, %r10d
shll $0xa, %r10d
rdtscp
movq %rdx, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
movb (%rdi,%r10), %al
rdtscp
shlq $0x20, %rdx
orq %rax, %rdx
subq %rsi, %rdx
cmpq $0x9f, %rdx
ja 0x4028ac
incq (%rbx,%r9,8)
addq $0xa7, %r8
cmpq $0xa70d, %r8            # imm = 0xA70D
jne 0x402876
incl %r15d
cmpl $0x2710, %r15d          # imm = 0x2710
jne 0x402837
movl $0x1, %esi
movq %rbx, %rdi
callq 0x402128
movq %r14, %rdi
callq 0x40b1e4
leaq 0x981b(%rip), %rdi      # 0x40c103
callq 0x401050
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x40b064
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4010a0
movq 0x16ef3(%rip), %rax     # 0x419800
xorl %ecx, %ecx
leaq (%rax,%rcx), %rdx
clflush (%rdx)
addq $0x400, %rcx            # imm = 0x400
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x40290f
mfence
movq 0x16ed0(%rip), %rdi     # 0x419800
callq 0x402cf9
movq 0x16ec4(%rip), %rdi     # 0x419800
mfence
movl $0xd, %r8d
movzbl %r8b, %r9d
movl %r9d, %r10d
shll $0xa, %r10d
rdtscp
movq %rdx, %rsi
shlq $0x20, %rsi
orq %rax, %rsi
movb (%rdi,%r10), %al
rdtscp
shlq $0x20, %rdx
orq %rax, %rdx
subq %rsi, %rdx
cmpq $0x9f, %rdx
ja 0x40297b
incq (%rbx,%r9,8)
addq $0xa7, %r8
cmpq $0xa70d, %r8            # imm = 0xA70D
jne 0x402945
incl %r14d
cmpl $0x2710, %r14d          # imm = 0x2710
jne 0x402906
leaq 0x1665e(%rip), %rdi     # 0x419000
movl $0x1, %esi
callq 0x402128
leaq 0x975e(%rip), %rdi      # 0x40c111
callq 0x401050
callq 0x402b06
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x9647(%rip), %rdi      # 0x40c017
leaq 0x9659(%rip), %rsi      # 0x40c030
leaq 0x966a(%rip), %rcx      # 0x40c048
movl $0x41, %edx
callq 0x401090
leaq 0x9670(%rip), %rdi      # 0x40c05f
leaq 0x963a(%rip), %rsi      # 0x40c030
leaq 0x964b(%rip), %rcx      # 0x40c048
movl $0x44, %edx
callq 0x401090
leaq 0x9651(%rip), %rdi      # 0x40c05f
leaq 0x961b(%rip), %rsi      # 0x40c030
leaq 0x962c(%rip), %rcx      # 0x40c048
movl $0x47, %edx
callq 0x401090