#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*/ exit(int);
int /*<<< orphan*/ printf(char *, char *, char *);
void fatal(int code) {
  char *message;
  switch (code) {
  case 3:
    message = "%s[fatal error] error on reallocate memory%s\n";
    break;
  case 2:
    message = "%s[fatal error] error on allocate memory%s\n";
    break;
  case 4:
    message = "%s[fatal error] uninitialized test%s\n";
    break;
  default:
    message = "%s[fatal error] unknow error%s\n";
  }
  printf(message, "\x1b[31m", "\x1b[0m");
  exit(code);
}


x86 assembly (clang, -O0):
<fatal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x2,%eax
je     1171 <fatal+0x51>
jmp    113f <fatal+0x1f>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     1161 <fatal+0x41>
jmp    1150 <fatal+0x30>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
je     1181 <fatal+0x61>
jmp    1191 <fatal+0x71>
lea    0xe98(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    119c <fatal+0x7c>
lea    0xeb6(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    119c <fatal+0x7c>
lea    0xed2(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    119c <fatal+0x7c>
lea    0xee8(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xef9(%rip),%rsi
lea    0xef8(%rip),%rdx
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<fatal>:
push   %rbx
mov    %edi,%ebx
lea    -0x2(%rbx),%eax
cmp    $0x2,%eax
ja     113d <fatal+0x1d>
cltq
lea    0xf78(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1144 <fatal+0x24>
lea    0xf3c(%rip),%rdi
lea    0xf55(%rip),%rsi
lea    0xf54(%rip),%rdx
call   1030 <printf@plt>
mov    %ebx,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"%s[fatal error] error on reallocate memory%s\0A\00"
@.str.1 = [44 x i8] c"%s[fatal error] error on allocate memory%s\0A\00"
@.str.2 = [38 x i8] c"%s[fatal error] uninitialized test%s\0A\00"
@.str.3 = [32 x i8] c"%s[fatal error] unknow error%s\0A\00"
@.str.4 = [6 x i8] c"\1B[31m\00"
@.str.5 = [5 x i8] c"\1B[0m\00"
define void @fatal(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
switch i32 %4, label %8 [
i32 3, label %5
i32 2, label %6
i32 4, label %7
]
5: ; preds = %1
store i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8** %3
br label %9
6: ; preds = %1
store i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %9
7: ; preds = %1
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %9
8: ; preds = %1
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %9
9: ; preds = %8, %7, %6, %5
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = call i32 @exit(i32 %12)
unreachable
}

LLVM IR (-O2):
@.str = [46 x i8] c"%s[fatal error] error on reallocate memory%s\0A\00"
@.str.1 = [44 x i8] c"%s[fatal error] error on allocate memory%s\0A\00"
@.str.2 = [38 x i8] c"%s[fatal error] uninitialized test%s\0A\00"
@.str.3 = [32 x i8] c"%s[fatal error] unknow error%s\0A\00"
@.str.4 = [6 x i8] c"\1B[31m\00"
@.str.5 = [5 x i8] c"\1B[0m\00"
@reltable.fatal = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([44 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.fatal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([46 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.fatal to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([38 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.fatal to i64)) to i32)]
define void @fatal(i32 %0) {
%2 = add i32 %0, -2
%3 = icmp ult i32 %2, 3
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.fatal to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), %1 ]
%10 = tail call i32 @printf(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%11 = tail call i32 @exit(i32 %0)
unreachable
}