#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 */
int SEGV_ACCERR;
int SEGV_MAPERR;
char *si_code_str(int si_code) {
  if (si_code & SEGV_MAPERR) {
    return "SEGV_MAPERR";
  }
  if (si_code & SEGV_ACCERR) {
    return "SEGV_ACCERR";
  }
  if (si_code & ((3 << 16) | 3)) {
    return "SEGV_BNDERR";
  }
  if (si_code & ((3 << 16) | 4)) {
    return "SEGV_PKUERR";
  }
  return "UNKNOWN";
}


x86 assembly (clang, -O0):
<si_code_str>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2ec7(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     112c <si_code_str+0x2c>
lea    0xedd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119e <si_code_str+0x9e>
mov    -0xc(%rbp),%eax
mov    0x2eb2(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1151 <si_code_str+0x51>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119e <si_code_str+0x9e>
mov    -0xc(%rbp),%eax
and    $0x30003,%eax
cmp    $0x0,%eax
je     1172 <si_code_str+0x72>
lea    0xeaf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119e <si_code_str+0x9e>
mov    -0xc(%rbp),%eax
and    $0x30004,%eax
cmp    $0x0,%eax
je     1193 <si_code_str+0x93>
lea    0xe9a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119e <si_code_str+0x9e>
lea    0xe96(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<si_code_str>:
mov    0x2ed1(%rip),%rax
test   %edi,(%rax)
je     1113 <si_code_str+0x13>
lea    0xeee(%rip),%rax
ret
mov    0x2ece(%rip),%rax
test   %edi,(%rax)
je     1126 <si_code_str+0x26>
lea    0xee7(%rip),%rax
ret
test   $0x30003,%edi
je     1136 <si_code_str+0x36>
lea    0xee3(%rip),%rax
ret
test   $0x30004,%edi
lea    0xeed(%rip),%rcx
lea    0xeda(%rip),%rax
cmove  %rcx,%rax
ret

LLVM IR (-O0):
@SEGV_MAPERR = global i32 0
@.str = [12 x i8] c"SEGV_MAPERR\00"
@SEGV_ACCERR = global i32 0
@.str.1 = [12 x i8] c"SEGV_ACCERR\00"
@.str.2 = [12 x i8] c"SEGV_BNDERR\00"
@.str.3 = [12 x i8] c"SEGV_PKUERR\00"
@.str.4 = [8 x i8] c"UNKNOWN\00"
define i8* @si_code_str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = load i32, i32* @SEGV_MAPERR
%6 = and i32 %4, %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
br label %26
9: ; preds = %1
%10 = load i32, i32* %3
%11 = load i32, i32* @SEGV_ACCERR
%12 = and i32 %10, %11
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %26
15: ; preds = %9
%16 = load i32, i32* %3
%17 = and i32 %16, 196611
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %26
20: ; preds = %15
%21 = load i32, i32* %3
%22 = and i32 %21, 196612
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %26
25: ; preds = %20
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %26
26: ; preds = %25, %24, %19, %14, %8
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
@SEGV_MAPERR = global i32 0
@.str = [12 x i8] c"SEGV_MAPERR\00"
@SEGV_ACCERR = global i32 0
@.str.1 = [12 x i8] c"SEGV_ACCERR\00"
@.str.2 = [12 x i8] c"SEGV_BNDERR\00"
@.str.3 = [12 x i8] c"SEGV_PKUERR\00"
@.str.4 = [8 x i8] c"UNKNOWN\00"
define i8* @si_code_str(i32 %0) {
%2 = load i32, i32* @SEGV_MAPERR
%3 = and i32 %2, %0
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %1
%6 = load i32, i32* @SEGV_ACCERR
%7 = and i32 %6, %0
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = and i32 %0, 196611
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = and i32 %0, 196612
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0)
br label %16
16: ; preds = %12, %9, %5, %1
%17 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), %9 ], [ %15, %12 ]
ret i8* %17
}