#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 /*<<< orphan*/ printf(char *, ...);
void CheckError(int aCode) {
  if (aCode != 0) {
    printf("LeddarC error (%d): ", aCode);
    switch (aCode) {
    case (-10):
      printf("LD_ACCESS_DENIED\n");
      break;
    case (-9):
      printf("LD_TIMEOUT\n");
      break;
    case (-8):
      printf("LD_START_OF_FILE\n");
      break;
    case (-7):
      printf("LD_END_OF_FILE\n");
      break;
    case (-6):
      printf("LD_NO_RECORD\n");
      break;
    case (-5):
      printf("LD_ALREADY_STARTED\n");
      break;
    case (-4):
      printf("LD_NO_DATA_TRANSFER\n");
      break;
    case (-3):
      printf("LD_NOT_CONNECTED\n");
      break;
    case (-2):
      printf("LD_INVALID_ARGUMENT\n");
      break;
    case (-1):
      printf("LD_ERROR\n");
      break;
    case 1:
      printf("LD_NOT_ENOUGH_SPACE\n");
      break;
    }
  }
}


x86 assembly (clang, -O0):
<CheckError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1230 <CheckError+0x120>
mov    -0x4(%rbp),%esi
lea    0xf01(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xa,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xb,%eax
ja     122b <CheckError+0x11b>
mov    -0x10(%rbp),%rax
lea    0xeaa(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <CheckError+0x11b>
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <CheckError+0x11b>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <CheckError+0x11b>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <CheckError+0x11b>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <CheckError+0x11b>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <CheckError+0x11b>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <CheckError+0x11b>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <CheckError+0x11b>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <CheckError+0x11b>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <CheckError+0x11b>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1230 <CheckError+0x120>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckError>:
push   %rbx
test   %edi,%edi
je     1149 <CheckError+0x29>
mov    %edi,%ebx
lea    0xed2(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xa,%ebx
cmp    $0xb,%ebx
ja     1149 <CheckError+0x29>
mov    $0xbff,%eax
bt     %ebx,%eax
jb     114b <CheckError+0x2b>
pop    %rbx
ret
movslq %ebx,%rax
lea    0xf73(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"LeddarC error (%d): \00"
@.str.1 = [18 x i8] c"LD_ACCESS_DENIED\0A\00"
@.str.2 = [12 x i8] c"LD_TIMEOUT\0A\00"
@.str.3 = [18 x i8] c"LD_START_OF_FILE\0A\00"
@.str.4 = [16 x i8] c"LD_END_OF_FILE\0A\00"
@.str.5 = [14 x i8] c"LD_NO_RECORD\0A\00"
@.str.6 = [20 x i8] c"LD_ALREADY_STARTED\0A\00"
@.str.7 = [21 x i8] c"LD_NO_DATA_TRANSFER\0A\00"
@.str.8 = [18 x i8] c"LD_NOT_CONNECTED\0A\00"
@.str.9 = [21 x i8] c"LD_INVALID_ARGUMENT\0A\00"
@.str.10 = [10 x i8] c"LD_ERROR\0A\00"
@.str.11 = [21 x i8] c"LD_NOT_ENOUGH_SPACE\0A\00"
define void @CheckError(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %32
5: ; preds = %1
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %2
switch i32 %8, label %31 [
i32 -10, label %9
i32 -9, label %11
i32 -8, label %13
i32 -7, label %15
i32 -6, label %17
i32 -5, label %19
i32 -4, label %21
i32 -3, label %23
i32 -2, label %25
i32 -1, label %27
i32 1, label %29
]
9: ; preds = %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %31
11: ; preds = %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %31
13: ; preds = %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %31
15: ; preds = %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %31
17: ; preds = %5
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %31
19: ; preds = %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %31
21: ; preds = %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %31
23: ; preds = %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %31
25: ; preds = %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %31
27: ; preds = %5
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
br label %31
29: ; preds = %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %31
31: ; preds = %5, %29, %27, %25, %23, %21, %19, %17, %15, %13, %11, %9
br label %32
32: ; preds = %31, %1
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"LeddarC error (%d): \00"
@str = [20 x i8] c"LD_NOT_ENOUGH_SPACE\00"
@str.12 = [9 x i8] c"LD_ERROR\00"
@str.13 = [20 x i8] c"LD_INVALID_ARGUMENT\00"
@str.14 = [17 x i8] c"LD_NOT_CONNECTED\00"
@str.15 = [20 x i8] c"LD_NO_DATA_TRANSFER\00"
@str.16 = [19 x i8] c"LD_ALREADY_STARTED\00"
@str.17 = [13 x i8] c"LD_NO_RECORD\00"
@str.18 = [15 x i8] c"LD_END_OF_FILE\00"
@str.19 = [17 x i8] c"LD_START_OF_FILE\00"
@str.20 = [11 x i8] c"LD_TIMEOUT\00"
@str.21 = [17 x i8] c"LD_ACCESS_DENIED\00"
@reltable.CheckError = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.21 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.20 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.19 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @str.18 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @str.17 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @str.16 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @str.15 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.14 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @str.13 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @str.12 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.21 to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @str to i64), i64 ptrtoint ([12 x i32]* @reltable.CheckError to i64)) to i32)]
define void @CheckError(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %17, label %3
3: ; preds = %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = add i32 %0, 10
%6 = icmp ult i32 %5, 12
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = trunc i32 %5 to i16
%9 = lshr i16 3071, %8
%10 = and i16 %9, 1
%11 = icmp eq i16 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = sext i32 %5 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.CheckError to i8*), i64 %14)
%16 = tail call i32 @puts(i8* dereferenceable(1) %15)
br label %17
17: ; preds = %7, %3, %12, %1
ret void
}