#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 */
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
char *get_error(int error) {
  char *ret = malloc(256);
  switch (error) {
  case -1:
    sprintf(ret, "overflowed src buffer at exit");
    break;
  case -2:
    sprintf(ret, "num of bytes to copy exceeds dst size");
    break;
  case -3:
    sprintf(ret, "copy offset before start of buffer");
    break;
  case -4:
    sprintf(ret, "overflowed src while reading length");
    break;
  case -5:
    sprintf(ret, "length greater than dst buffer");
    break;
  case -6:
    sprintf(ret, "overflowed src while reading raw byte");
    break;
  case -7:
    sprintf(ret, "overflowed dst while writing raw byte");
    break;
  case -8:
    sprintf(ret, "overflowed src after reading offset");
    break;
  case -9:
    sprintf(ret, "overflowed src while reading offset");
    break;
  case -10:
    sprintf(ret, "offset exceeds maximum");
    break;
  default:
    sprintf(ret, "program returned error %d", error);
  }
  return ret;
}


x86 assembly (clang, -O0):
<get_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x100,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     1248 <get_error+0x128>
mov    -0x18(%rbp),%rax
lea    0xea7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xebb(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    125d <get_error+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    125d <get_error+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xed1(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    125d <get_error+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xedd(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    125d <get_error+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xeea(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    125d <get_error+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xef2(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    125d <get_error+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xf01(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    125d <get_error+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xf10(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    125d <get_error+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xf1d(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    125d <get_error+0x13d>
mov    -0x10(%rbp),%rdi
lea    0xf2a(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    125d <get_error+0x13d>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xf27(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_error>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x100,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
lea    0xa(%rbx),%eax
cmp    $0x9,%eax
ja     1169 <get_error+0x49>
lea    0xebe(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movups 0x1014(%rip),%xmm0
movups %xmm0,(%r14)
movabs $0x6d756d6978616d,%rax
mov    %rax,0xf(%r14)
jmp    1291 <get_error+0x171>
lea    0x100d(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    1291 <get_error+0x171>
movups 0xfca(%rip),%xmm0
movups %xmm0,0x10(%r14)
movups 0xfae(%rip),%xmm0
jmp    11a9 <get_error+0x89>
movups 0xf91(%rip),%xmm0
movups %xmm0,0x10(%r14)
movups 0xf75(%rip),%xmm0
movups %xmm0,(%r14)
movl   $0x746573,0x20(%r14)
jmp    1291 <get_error+0x171>
movups 0xf47(%rip),%xmm0
movups %xmm0,0x10(%r14)
movups 0xf2b(%rip),%xmm0
jmp    11e2 <get_error+0xc2>
movups 0xf0c(%rip),%xmm0
movups %xmm0,0x10(%r14)
movups 0xef0(%rip),%xmm0
movups %xmm0,(%r14)
movabs $0x65747962207761,%rax
jmp    128d <get_error+0x16d>
movups 0xec6(%rip),%xmm0
movups %xmm0,0xf(%r14)
movups 0xeab(%rip),%xmm0
movups %xmm0,(%r14)
jmp    1291 <get_error+0x171>
movups 0xe87(%rip),%xmm0
movups %xmm0,0x10(%r14)
movups 0xe6b(%rip),%xmm0
movups %xmm0,(%r14)
movl   $0x687467,0x20(%r14)
jmp    1291 <get_error+0x171>
movups 0xe43(%rip),%xmm0
movups %xmm0,0x10(%r14)
movups 0xe27(%rip),%xmm0
movups %xmm0,(%r14)
movl   $0x726566,0x1f(%r14)
jmp    1291 <get_error+0x171>
movups 0xddc(%rip),%xmm0
movups %xmm0,0xe(%r14)
movups 0xdc2(%rip),%xmm0
movups %xmm0,(%r14)
jmp    1291 <get_error+0x171>
movups 0xde3(%rip),%xmm0
movups %xmm0,0x10(%r14)
movups 0xdc7(%rip),%xmm0
movups %xmm0,(%r14)
movabs $0x657a6973207473,%rax
mov    %rax,0x1e(%r14)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [30 x i8] c"overflowed src buffer at exit\00"
@.str.1 = [38 x i8] c"num of bytes to copy exceeds dst size\00"
@.str.2 = [35 x i8] c"copy offset before start of buffer\00"
@.str.3 = [36 x i8] c"overflowed src while reading length\00"
@.str.4 = [31 x i8] c"length greater than dst buffer\00"
@.str.5 = [38 x i8] c"overflowed src while reading raw byte\00"
@.str.6 = [38 x i8] c"overflowed dst while writing raw byte\00"
@.str.7 = [36 x i8] c"overflowed src after reading offset\00"
@.str.8 = [36 x i8] c"overflowed src while reading offset\00"
@.str.9 = [23 x i8] c"offset exceeds maximum\00"
@.str.10 = [26 x i8] c"program returned error %d\00"
define i8* @get_error(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = call i8* @malloc(i32 256)
store i8* %4, i8** %3
%5 = load i32, i32* %2
switch i32 %5, label %36 [
i32 -1, label %6
i32 -2, label %9
i32 -3, label %12
i32 -4, label %15
i32 -5, label %18
i32 -6, label %21
i32 -7, label %24
i32 -8, label %27
i32 -9, label %30
i32 -10, label %33
]
6: ; preds = %1
%7 = load i8*, i8** %3
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %40
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %40
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %40
15: ; preds = %1
%16 = load i8*, i8** %3
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %40
18: ; preds = %1
%19 = load i8*, i8** %3
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %40
21: ; preds = %1
%22 = load i8*, i8** %3
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
br label %40
24: ; preds = %1
%25 = load i8*, i8** %3
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
br label %40
27: ; preds = %1
%28 = load i8*, i8** %3
%29 = call i32 (i8*, i8*, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
br label %40
30: ; preds = %1
%31 = load i8*, i8** %3
%32 = call i32 (i8*, i8*, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %40
33: ; preds = %1
%34 = load i8*, i8** %3
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
br label %40
36: ; preds = %1
%37 = load i8*, i8** %3
%38 = load i32, i32* %2
%39 = call i32 (i8*, i8*, ...) @sprintf(i8* %37, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %6
%41 = load i8*, i8** %3
ret i8* %41
}

LLVM IR (-O2):
@.str = [30 x i8] c"overflowed src buffer at exit\00"
@.str.1 = [38 x i8] c"num of bytes to copy exceeds dst size\00"
@.str.2 = [35 x i8] c"copy offset before start of buffer\00"
@.str.3 = [36 x i8] c"overflowed src while reading length\00"
@.str.4 = [31 x i8] c"length greater than dst buffer\00"
@.str.5 = [38 x i8] c"overflowed src while reading raw byte\00"
@.str.6 = [38 x i8] c"overflowed dst while writing raw byte\00"
@.str.7 = [36 x i8] c"overflowed src after reading offset\00"
@.str.8 = [36 x i8] c"overflowed src while reading offset\00"
@.str.9 = [23 x i8] c"offset exceeds maximum\00"
@.str.10 = [26 x i8] c"program returned error %d\00"
define noalias i8* @get_error(i32 %0) {
%2 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
switch i32 %0, label %13 [
i32 -1, label %3
i32 -2, label %4
i32 -3, label %5
i32 -4, label %6
i32 -5, label %7
i32 -6, label %8
i32 -7, label %9
i32 -8, label %10
i32 -9, label %11
i32 -10, label %12
]
3: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(30) %2, i8* align 1 dereferenceable(30) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 30, i1 false)
br label %15
4: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(38) %2, i8* align 1 dereferenceable(38) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i64 38, i1 false)
br label %15
5: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(35) %2, i8* align 1 dereferenceable(35) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i64 35, i1 false)
br label %15
6: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(36) %2, i8* align 1 dereferenceable(36) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 36, i1 false)
br label %15
7: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(31) %2, i8* align 1 dereferenceable(31) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i64 31, i1 false)
br label %15
8: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(38) %2, i8* align 1 dereferenceable(38) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i64 38, i1 false)
br label %15
9: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(38) %2, i8* align 1 dereferenceable(38) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i64 38, i1 false)
br label %15
10: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(36) %2, i8* align 1 dereferenceable(36) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), i64 36, i1 false)
br label %15
11: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(36) %2, i8* align 1 dereferenceable(36) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i64 36, i1 false)
br label %15
12: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(23) %2, i8* align 1 dereferenceable(23) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i64 23, i1 false)
br label %15
13: ; preds = %1
%14 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %0)
br label %15
15: ; preds = %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3
ret i8* %2
}