#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*/ kwrite(int, char *, int /*<<< orphan*/);
void print_error(int ret) {
  kwrite(15, "Error : ", 0);
  switch (ret) {
  case -1:
    kwrite(15, "No more memory\n", 0);
    break;
  case -2:
    kwrite(15, "Operation not permitted\n", 0);
    break;
  case -3:
    kwrite(15, "Invalid argument\n", 0);
    break;
  case -4:
    kwrite(15, "No such process\n", 0);
    break;
  case -5:
    kwrite(15, "Bad address\n", 0);
    break;
  case -6:
    kwrite(15, "Bad message\n", 0);
    break;
  case -7:
    kwrite(15, "Message too long\n", 0);
    break;
  }
}


x86 assembly (clang, -O0):
<print_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xefa(%rip),%rsi
mov    $0xf,%edi
xor    %edx,%edx
call   1030 <kwrite@plt>
mov    -0x4(%rbp),%eax
add    $0x7,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     11fa <print_error+0xea>
mov    -0x10(%rbp),%rax
lea    0xeb2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0xf,%edi
lea    0xec2(%rip),%rsi
xor    %edx,%edx
call   1030 <kwrite@plt>
jmp    11fa <print_error+0xea>
mov    $0xf,%edi
lea    0xeba(%rip),%rsi
xor    %edx,%edx
call   1030 <kwrite@plt>
jmp    11fa <print_error+0xea>
mov    $0xf,%edi
lea    0xebb(%rip),%rsi
xor    %edx,%edx
call   1030 <kwrite@plt>
jmp    11fa <print_error+0xea>
mov    $0xf,%edi
lea    0xeb5(%rip),%rsi
xor    %edx,%edx
call   1030 <kwrite@plt>
jmp    11fa <print_error+0xea>
mov    $0xf,%edi
lea    0xeae(%rip),%rsi
xor    %edx,%edx
call   1030 <kwrite@plt>
jmp    11fa <print_error+0xea>
mov    $0xf,%edi
lea    0xea3(%rip),%rsi
xor    %edx,%edx
call   1030 <kwrite@plt>
jmp    11fa <print_error+0xea>
mov    $0xf,%edi
lea    0xe98(%rip),%rsi
xor    %edx,%edx
call   1030 <kwrite@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_error>:
push   %rbx
mov    %edi,%ebx
lea    0xee6(%rip),%rsi
mov    $0xf,%edi
xor    %edx,%edx
call   1030 <kwrite@plt>
cmp    $0xfffffff9,%ebx
jb     114c <print_error+0x3c>
add    $0x7,%ebx
movslq %ebx,%rax
lea    0xf4c(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    $0xf,%edi
xor    %edx,%edx
pop    %rbx
jmp    1030 <kwrite@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Error : \00"
@.str.1 = [16 x i8] c"No more memory\0A\00"
@.str.2 = [25 x i8] c"Operation not permitted\0A\00"
@.str.3 = [18 x i8] c"Invalid argument\0A\00"
@.str.4 = [17 x i8] c"No such process\0A\00"
@.str.5 = [13 x i8] c"Bad address\0A\00"
@.str.6 = [13 x i8] c"Bad message\0A\00"
@.str.7 = [18 x i8] c"Message too long\0A\00"
define void @print_error(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @kwrite(i32 15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 0)
%4 = load i32, i32* %2
switch i32 %4, label %19 [
i32 -1, label %5
i32 -2, label %7
i32 -3, label %9
i32 -4, label %11
i32 -5, label %13
i32 -6, label %15
i32 -7, label %17
]
5: ; preds = %1
%6 = call i32 @kwrite(i32 15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %19
7: ; preds = %1
%8 = call i32 @kwrite(i32 15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 0)
br label %19
9: ; preds = %1
%10 = call i32 @kwrite(i32 15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 0)
br label %19
11: ; preds = %1
%12 = call i32 @kwrite(i32 15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 0)
br label %19
13: ; preds = %1
%14 = call i32 @kwrite(i32 15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 0)
br label %19
15: ; preds = %1
%16 = call i32 @kwrite(i32 15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 0)
br label %19
17: ; preds = %1
%18 = call i32 @kwrite(i32 15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 0)
br label %19
19: ; preds = %1, %17, %15, %13, %11, %9, %7, %5
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"Error : \00"
@.str.1 = [16 x i8] c"No more memory\0A\00"
@.str.2 = [25 x i8] c"Operation not permitted\0A\00"
@.str.3 = [18 x i8] c"Invalid argument\0A\00"
@.str.4 = [17 x i8] c"No such process\0A\00"
@.str.5 = [13 x i8] c"Bad address\0A\00"
@.str.6 = [13 x i8] c"Bad message\0A\00"
@.str.7 = [18 x i8] c"Message too long\0A\00"
@reltable.print_error = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.7 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.print_error to i64)) to i32)]
define void @print_error(i32 %0) {
%2 = tail call i32 @kwrite(i32 15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 0)
%3 = icmp ugt i32 %0, -8
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = add i32 %0, 7
%6 = sext i32 %5 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.print_error to i8*), i64 %7)
%9 = tail call i32 @kwrite(i32 15, i8* %8, i32 0)
br label %10
10: ; preds = %1, %4
ret void
}