#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
unsigned long DR_STEP;
unsigned long DR_TRAP0;
unsigned long DR_TRAP1;
unsigned long DR_TRAP2;
unsigned long DR_TRAP3;
int TRAP_BRKPT;
int TRAP_HWBKPT;
int TRAP_TRACE;
int get_si_code(unsigned long condition) {
  if (condition & DR_STEP)
    return TRAP_TRACE;
  else if (condition & (DR_TRAP0 | DR_TRAP1 | DR_TRAP2 | DR_TRAP3))
    return TRAP_HWBKPT;
  else
    return TRAP_BRKPT;
}


x86 assembly (clang, -O0):
<get_si_code>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2ead(%rip),%rcx
and    (%rcx),%rax
cmp    $0x0,%rax
je     1131 <get_si_code+0x31>
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1187 <get_si_code+0x87>
mov    -0x10(%rbp),%rax
mov    0x2e64(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e8a(%rip),%rdx
or     (%rdx),%rcx
mov    0x2e58(%rip),%rdx
or     (%rdx),%rcx
mov    0x2e7e(%rip),%rdx
or     (%rdx),%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     117b <get_si_code+0x7b>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1187 <get_si_code+0x87>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_si_code>:
mov    0x2eb9(%rip),%rax
test   %rdi,(%rax)
je     1116 <get_si_code+0x16>
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2e83(%rip),%rax
mov    0x2eac(%rip),%rcx
mov    (%rcx),%rcx
or     (%rax),%rcx
mov    0x2e77(%rip),%rax
or     (%rax),%rcx
mov    0x2e9d(%rip),%rax
or     (%rax),%rcx
test   %rdi,%rcx
jne    114d <get_si_code+0x4d>
mov    0x2e9e(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2ea4(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
@DR_STEP = global i64 0
@TRAP_TRACE = global i32 0
@DR_TRAP0 = global i64 0
@DR_TRAP1 = global i64 0
@DR_TRAP2 = global i64 0
@DR_TRAP3 = global i64 0
@TRAP_HWBKPT = global i32 0
@TRAP_BRKPT = global i32 0
define i32 @get_si_code(i64 %0) {
%2 = alloca i32
%3 = alloca i64
store i64 %0, i64* %3
%4 = load i64, i64* %3
%5 = load i64, i64* @DR_STEP
%6 = and i64 %4, %5
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load i32, i32* @TRAP_TRACE
store i32 %9, i32* %2
br label %25
10: ; preds = %1
%11 = load i64, i64* %3
%12 = load i64, i64* @DR_TRAP0
%13 = load i64, i64* @DR_TRAP1
%14 = or i64 %12, %13
%15 = load i64, i64* @DR_TRAP2
%16 = or i64 %14, %15
%17 = load i64, i64* @DR_TRAP3
%18 = or i64 %16, %17
%19 = and i64 %11, %18
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %10
%22 = load i32, i32* @TRAP_HWBKPT
store i32 %22, i32* %2
br label %25
23: ; preds = %10
%24 = load i32, i32* @TRAP_BRKPT
store i32 %24, i32* %2
br label %25
25: ; preds = %23, %21, %8
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@DR_STEP = global i64 0
@TRAP_TRACE = global i32 0
@DR_TRAP0 = global i64 0
@DR_TRAP1 = global i64 0
@DR_TRAP2 = global i64 0
@DR_TRAP3 = global i64 0
@TRAP_HWBKPT = global i32 0
@TRAP_BRKPT = global i32 0
define i32 @get_si_code(i64 %0) {
%2 = load i64, i64* @DR_STEP
%3 = and i64 %2, %0
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %1
%6 = load i64, i64* @DR_TRAP0
%7 = load i64, i64* @DR_TRAP1
%8 = or i64 %7, %6
%9 = load i64, i64* @DR_TRAP2
%10 = or i64 %8, %9
%11 = load i64, i64* @DR_TRAP3
%12 = or i64 %10, %11
%13 = and i64 %12, %0
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i32* @TRAP_BRKPT, i32* @TRAP_HWBKPT
br label %16
16: ; preds = %5, %1
%17 = phi i32* [ @TRAP_TRACE, %1 ], [ %15, %5 ]
%18 = load i32, i32* %17
ret i32 %18
}