unsigned char *exception_code_to_string(unsigned int expevt) {
  switch (expevt) {
  case 0x1e0:
    return "User break";
    break;
  case 0x0e0:
    return "Address error (read)";
    break;
  case 0x040:
    return "TLB miss exception (read)";
    break;
  case 0x0a0:
    return "TLB protection violation exception (read)";
    break;
  case 0x180:
    return "General illegal instruction exception";
    break;
  case 0x1a0:
    return "Slot illegal instruction exception";
    break;
  case 0x800:
    return "General FPU disable exception";
    break;
  case 0x820:
    return "Slot FPU disable exception";
    break;
  case 0x100:
    return "Address error (write)";
    break;
  case 0x060:
    return "TLB miss exception (write)";
    break;
  case 0x0c0:
    return "TLB protection violation exception (write)";
    break;
  case 0x120:
    return "FPU exception";
    break;
  case 0x080:
    return "Initial page write exception";
    break;
  case 0x160:
    return "Unconditional trap (TRAPA)";
    break;
  default:
    return "Unknown exception";
    break;
  }
}


x86 assembly (clang, -O0):
<exception_code_to_string>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x40,%eax
je     1230 <exception_code_to_string+0x130>
jmp    111b <exception_code_to_string+0x1b>
mov    -0x10(%rbp),%eax
sub    $0x60,%eax
je     12a0 <exception_code_to_string+0x1a0>
jmp    112c <exception_code_to_string+0x2c>
mov    -0x10(%rbp),%eax
sub    $0x80,%eax
je     12d0 <exception_code_to_string+0x1d0>
jmp    113f <exception_code_to_string+0x3f>
mov    -0x10(%rbp),%eax
sub    $0xa0,%eax
je     1240 <exception_code_to_string+0x140>
jmp    1152 <exception_code_to_string+0x52>
mov    -0x10(%rbp),%eax
sub    $0xc0,%eax
je     12b0 <exception_code_to_string+0x1b0>
jmp    1165 <exception_code_to_string+0x65>
mov    -0x10(%rbp),%eax
sub    $0xe0,%eax
je     1220 <exception_code_to_string+0x120>
jmp    1178 <exception_code_to_string+0x78>
mov    -0x10(%rbp),%eax
sub    $0x100,%eax
je     1290 <exception_code_to_string+0x190>
jmp    118b <exception_code_to_string+0x8b>
mov    -0x10(%rbp),%eax
sub    $0x120,%eax
je     12c0 <exception_code_to_string+0x1c0>
jmp    119e <exception_code_to_string+0x9e>
mov    -0x10(%rbp),%eax
sub    $0x160,%eax
je     12e0 <exception_code_to_string+0x1e0>
jmp    11b1 <exception_code_to_string+0xb1>
mov    -0x10(%rbp),%eax
sub    $0x180,%eax
je     1250 <exception_code_to_string+0x150>
jmp    11c4 <exception_code_to_string+0xc4>
mov    -0x10(%rbp),%eax
sub    $0x1a0,%eax
je     1260 <exception_code_to_string+0x160>
jmp    11d7 <exception_code_to_string+0xd7>
mov    -0x10(%rbp),%eax
sub    $0x1e0,%eax
je     1210 <exception_code_to_string+0x110>
jmp    11ea <exception_code_to_string+0xea>
mov    -0x10(%rbp),%eax
sub    $0x800,%eax
je     1270 <exception_code_to_string+0x170>
jmp    11fd <exception_code_to_string+0xfd>
mov    -0x10(%rbp),%eax
sub    $0x820,%eax
je     1280 <exception_code_to_string+0x180>
jmp    12f0 <exception_code_to_string+0x1f0>
lea    0xde9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xde4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xde9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xdf3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe0d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe23(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe36(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe44(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe4f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe55(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe60(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe7b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe79(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe86(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12fb <exception_code_to_string+0x1fb>
lea    0xe91(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<exception_code_to_string>:
cmp    $0x11f,%edi
jg     113c <exception_code_to_string+0x3c>
cmp    $0x9f,%edi
jle    116c <exception_code_to_string+0x6c>
cmp    $0xdf,%edi
jg     11aa <exception_code_to_string+0xaa>
cmp    $0xa0,%edi
je     11da <exception_code_to_string+0xda>
cmp    $0xc0,%edi
jne    121a <exception_code_to_string+0x11a>
lea    0xfdc(%rip),%rax
ret
cmp    $0x19f,%edi
jle    118a <exception_code_to_string+0x8a>
cmp    $0x7ff,%edi
jg     11c2 <exception_code_to_string+0xc2>
cmp    $0x1a0,%edi
je     11e2 <exception_code_to_string+0xe2>
cmp    $0x1e0,%edi
jne    121a <exception_code_to_string+0x11a>
lea    0xe95(%rip),%rax
ret
cmp    $0x40,%edi
je     11ea <exception_code_to_string+0xea>
cmp    $0x60,%edi
je     11f2 <exception_code_to_string+0xf2>
cmp    $0x80,%edi
jne    121a <exception_code_to_string+0x11a>
lea    0xfc7(%rip),%rax
ret
cmp    $0x120,%edi
je     11fa <exception_code_to_string+0xfa>
cmp    $0x160,%edi
je     1202 <exception_code_to_string+0x102>
cmp    $0x180,%edi
jne    121a <exception_code_to_string+0x11a>
lea    0xebb(%rip),%rax
ret
cmp    $0xe0,%edi
je     120a <exception_code_to_string+0x10a>
cmp    $0x100,%edi
jne    121a <exception_code_to_string+0x11a>
lea    0xf25(%rip),%rax
ret
cmp    $0x800,%edi
je     1212 <exception_code_to_string+0x112>
cmp    $0x820,%edi
jne    121a <exception_code_to_string+0x11a>
lea    0xef2(%rip),%rax
ret
lea    0xe59(%rip),%rax
ret
lea    0xea1(%rip),%rax
ret
lea    0xe2f(%rip),%rax
ret
lea    0xf03(%rip),%rax
ret
lea    0xf41(%rip),%rax
ret
lea    0xf64(%rip),%rax
ret
lea    0xdfa(%rip),%rax
ret
lea    0xe94(%rip),%rax
ret
lea    0xf67(%rip),%rax
ret

LLVM IR (-O0):
@.str = [11 x i8] c"User break\00"
@.str.1 = [21 x i8] c"Address error (read)\00"
@.str.2 = [26 x i8] c"TLB miss exception (read)\00"
@.str.3 = [42 x i8] c"TLB protection violation exception (read)\00"
@.str.4 = [38 x i8] c"General illegal instruction exception\00"
@.str.5 = [35 x i8] c"Slot illegal instruction exception\00"
@.str.6 = [30 x i8] c"General FPU disable exception\00"
@.str.7 = [27 x i8] c"Slot FPU disable exception\00"
@.str.8 = [22 x i8] c"Address error (write)\00"
@.str.9 = [27 x i8] c"TLB miss exception (write)\00"
@.str.10 = [43 x i8] c"TLB protection violation exception (write)\00"
@.str.11 = [14 x i8] c"FPU exception\00"
@.str.12 = [29 x i8] c"Initial page write exception\00"
@.str.13 = [27 x i8] c"Unconditional trap (TRAPA)\00"
@.str.14 = [18 x i8] c"Unknown exception\00"
define i8* @exception_code_to_string(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %19 [
i32 480, label %5
i32 224, label %6
i32 64, label %7
i32 160, label %8
i32 384, label %9
i32 416, label %10
i32 2048, label %11
i32 2080, label %12
i32 256, label %13
i32 96, label %14
i32 192, label %15
i32 288, label %16
i32 128, label %17
i32 352, label %18
]
5: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
br label %20
6: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %20
7: ; preds = %1
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %20
8: ; preds = %1
store i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %20
9: ; preds = %1
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %20
10: ; preds = %1
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %20
11: ; preds = %1
store i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %20
12: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %20
13: ; preds = %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %20
14: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %20
15: ; preds = %1
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %20
16: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %20
17: ; preds = %1
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %20
18: ; preds = %1
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %20
19: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), i8** %2
br label %20
20: ; preds = %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@.str = [11 x i8] c"User break\00"
@.str.1 = [21 x i8] c"Address error (read)\00"
@.str.2 = [26 x i8] c"TLB miss exception (read)\00"
@.str.3 = [42 x i8] c"TLB protection violation exception (read)\00"
@.str.4 = [38 x i8] c"General illegal instruction exception\00"
@.str.5 = [35 x i8] c"Slot illegal instruction exception\00"
@.str.6 = [30 x i8] c"General FPU disable exception\00"
@.str.7 = [27 x i8] c"Slot FPU disable exception\00"
@.str.8 = [22 x i8] c"Address error (write)\00"
@.str.9 = [27 x i8] c"TLB miss exception (write)\00"
@.str.10 = [43 x i8] c"TLB protection violation exception (write)\00"
@.str.11 = [14 x i8] c"FPU exception\00"
@.str.12 = [29 x i8] c"Initial page write exception\00"
@.str.13 = [27 x i8] c"Unconditional trap (TRAPA)\00"
@.str.14 = [18 x i8] c"Unknown exception\00"
define i8* @exception_code_to_string(i32 %0) {
switch i32 %0, label %15 [
i32 480, label %16
i32 224, label %2
i32 64, label %3
i32 160, label %4
i32 384, label %5
i32 416, label %6
i32 2048, label %7
i32 2080, label %8
i32 256, label %9
i32 96, label %10
i32 192, label %11
i32 288, label %12
i32 128, label %13
i32 352, label %14
]
2: ; preds = %1
br label %16
3: ; preds = %1
br label %16
4: ; preds = %1
br label %16
5: ; preds = %1
br label %16
6: ; preds = %1
br label %16
7: ; preds = %1
br label %16
8: ; preds = %1
br label %16
9: ; preds = %1
br label %16
10: ; preds = %1
br label %16
11: ; preds = %1
br label %16
12: ; preds = %1
br label %16
13: ; preds = %1
br label %16
14: ; preds = %1
br label %16
15: ; preds = %1
br label %16
16: ; preds = %1, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%17 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0), %15 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.13, i64 0, i64 0), %14 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0), %13 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), %12 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), %10 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %17
}