#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ my_putstr(char *);
int /*<<< orphan*/ printf(char *);
void print_fatal_error(int err) {
  fflush(0);
  printf("\33[2K\r");
  fflush(0);
  if (err == 1)
    my_putstr("Bad base\n");
  else if (err == 2)
    my_putstr("Bad expr len\n");
  else if (err == 3)
    my_putstr("could not alloc\n");
  else if (err == 4)
    my_putstr("could not read\n");
  else if (err == 5)
    my_putstr("Bad ops\n");
  else if (err == 6)
    my_putstr("syntax error\n");
  else if (err == 7)
    my_putstr("division by zero\n");
  else if (err == 8)
    my_putstr("mod by zero\n");
  exit(err);
}


x86 assembly (clang, -O0):
<print_fatal_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
xor    %edi,%edi
call   1050 <fflush@plt>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <fflush@plt>
cmpl   $0x1,-0x4(%rbp)
jne    1180 <print_fatal_error+0x40>
lea    0xe90(%rip),%rdi
call   1040 <my_putstr@plt>
jmp    125b <print_fatal_error+0x11b>
cmpl   $0x2,-0x4(%rbp)
jne    119b <print_fatal_error+0x5b>
lea    0xe7f(%rip),%rdi
call   1040 <my_putstr@plt>
jmp    1256 <print_fatal_error+0x116>
cmpl   $0x3,-0x4(%rbp)
jne    11b6 <print_fatal_error+0x76>
lea    0xe72(%rip),%rdi
call   1040 <my_putstr@plt>
jmp    1251 <print_fatal_error+0x111>
cmpl   $0x4,-0x4(%rbp)
jne    11d1 <print_fatal_error+0x91>
lea    0xe68(%rip),%rdi
call   1040 <my_putstr@plt>
jmp    124c <print_fatal_error+0x10c>
cmpl   $0x5,-0x4(%rbp)
jne    11ec <print_fatal_error+0xac>
lea    0xe5d(%rip),%rdi
call   1040 <my_putstr@plt>
jmp    1247 <print_fatal_error+0x107>
cmpl   $0x6,-0x4(%rbp)
jne    1207 <print_fatal_error+0xc7>
lea    0xe4b(%rip),%rdi
call   1040 <my_putstr@plt>
jmp    1242 <print_fatal_error+0x102>
cmpl   $0x7,-0x4(%rbp)
jne    1222 <print_fatal_error+0xe2>
lea    0xe3e(%rip),%rdi
call   1040 <my_putstr@plt>
jmp    123d <print_fatal_error+0xfd>
cmpl   $0x8,-0x4(%rbp)
jne    1238 <print_fatal_error+0xf8>
lea    0xe35(%rip),%rdi
call   1040 <my_putstr@plt>
jmp    123d <print_fatal_error+0xfd>
jmp    1242 <print_fatal_error+0x102>
jmp    1247 <print_fatal_error+0x107>
jmp    124c <print_fatal_error+0x10c>
jmp    1251 <print_fatal_error+0x111>
jmp    1256 <print_fatal_error+0x116>
jmp    125b <print_fatal_error+0x11b>
mov    -0x4(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<print_fatal_error>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
call   1050 <fflush@plt>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <fflush@plt>
lea    -0x1(%rbx),%eax
cmp    $0x7,%eax
ja     117a <print_fatal_error+0x3a>
cltq
lea    0xf0a(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1040 <my_putstr@plt>
mov    %ebx,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\1B[2K\0D\00"
@.str.1 = [10 x i8] c"Bad base\0A\00"
@.str.2 = [14 x i8] c"Bad expr len\0A\00"
@.str.3 = [17 x i8] c"could not alloc\0A\00"
@.str.4 = [16 x i8] c"could not read\0A\00"
@.str.5 = [9 x i8] c"Bad ops\0A\00"
@.str.6 = [14 x i8] c"syntax error\0A\00"
@.str.7 = [18 x i8] c"division by zero\0A\00"
@.str.8 = [13 x i8] c"mod by zero\0A\00"
define void @print_fatal_error(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @fflush(i32 0)
%4 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @fflush(i32 0)
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @my_putstr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %52
10: ; preds = %1
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @my_putstr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %51
15: ; preds = %10
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @my_putstr(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %50
20: ; preds = %15
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 4
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 @my_putstr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %49
25: ; preds = %20
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 5
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @my_putstr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %48
30: ; preds = %25
%31 = load i32, i32* %2
%32 = icmp eq i32 %31, 6
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 @my_putstr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %47
35: ; preds = %30
%36 = load i32, i32* %2
%37 = icmp eq i32 %36, 7
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @my_putstr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %46
40: ; preds = %35
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, 8
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @my_putstr(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %45
45: ; preds = %43, %40
br label %46
46: ; preds = %45, %38
br label %47
47: ; preds = %46, %33
br label %48
48: ; preds = %47, %28
br label %49
49: ; preds = %48, %23
br label %50
50: ; preds = %49, %18
br label %51
51: ; preds = %50, %13
br label %52
52: ; preds = %51, %8
%53 = load i32, i32* %2
%54 = call i32 @exit(i32 %53)
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"\1B[2K\0D\00"
@.str.1 = [10 x i8] c"Bad base\0A\00"
@.str.2 = [14 x i8] c"Bad expr len\0A\00"
@.str.3 = [17 x i8] c"could not alloc\0A\00"
@.str.4 = [16 x i8] c"could not read\0A\00"
@.str.5 = [9 x i8] c"Bad ops\0A\00"
@.str.6 = [14 x i8] c"syntax error\0A\00"
@.str.7 = [18 x i8] c"division by zero\0A\00"
@.str.8 = [13 x i8] c"mod by zero\0A\00"
@reltable.print_fatal_error = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.print_fatal_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.print_fatal_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.print_fatal_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.print_fatal_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.print_fatal_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.print_fatal_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.print_fatal_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.8 to i64), i64 ptrtoint ([8 x i32]* @reltable.print_fatal_error to i64)) to i32)]
define void @print_fatal_error(i32 %0) {
%2 = tail call i32 @fflush(i32 0)
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @fflush(i32 0)
%5 = add i32 %0, -1
%6 = icmp ult i32 %5, 8
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.print_fatal_error to i8*), i64 %9)
%11 = tail call i32 @my_putstr(i8* %10)
br label %12
12: ; preds = %1, %7
%13 = tail call i32 @exit(i32 %0)
unreachable
}