#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 *calloc(int, int);
int /*<<< orphan*/ display_message(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ sprintf(char *, char *, ...);
char *strerror(int /*<<< orphan*/);
void handle_error(int err) {
  char *errstr = calloc(500, sizeof(char));
  if (err & 0x00000100)
    sprintf(errstr, "e:ro");
  else if (err & 0x00000002)
    sprintf(errstr, "e:bi");
  else
    sprintf(errstr, "e");
  if (err & 0x10000000)
    sprintf(errstr, "%s: %s", errstr, strerror(errno));
  display_message(errstr);
}


x86 assembly (clang, -O0):
<handle_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x1f4,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     1186 <handle_error+0x46>
mov    -0x10(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    11c3 <handle_error+0x83>
mov    -0x4(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11ac <handle_error+0x6c>
mov    -0x10(%rbp),%rdi
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    11be <handle_error+0x7e>
mov    -0x10(%rbp),%rdi
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    11c3 <handle_error+0x83>
mov    -0x4(%rbp),%eax
and    $0x10000000,%eax
cmp    $0x0,%eax
je     120b <handle_error+0xcb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    %rax,%rcx
lea    0xe08(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <display_message@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_error>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x1f4,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
test   $0x100,%ebp
jne    1174 <handle_error+0x34>
test   $0x2,%bpl
jne    11b9 <handle_error+0x79>
movw   $0x65,(%rbx)
test   $0x10000000,%ebp
jne    1186 <handle_error+0x46>
jmp    11ab <handle_error+0x6b>
movb   $0x0,0x4(%rbx)
movl   $0x6f723a65,(%rbx)
test   $0x10000000,%ebp
je     11ab <handle_error+0x6b>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <display_message@plt>
movb   $0x0,0x4(%rbx)
movl   $0x69623a65,(%rbx)
test   $0x10000000,%ebp
jne    1186 <handle_error+0x46>
jmp    11ab <handle_error+0x6b>

LLVM IR (-O0):
@.str = [5 x i8] c"e:ro\00"
@.str.1 = [5 x i8] c"e:bi\00"
@.str.2 = [2 x i8] c"e\00"
@.str.3 = [7 x i8] c"%s: %s\00"
@errno = global i32 0
define void @handle_error(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = call i8* @calloc(i32 500, i32 1)
store i8* %4, i8** %3
%5 = load i32, i32* %2
%6 = and i32 %5, 256
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %22
11: ; preds = %1
%12 = load i32, i32* %2
%13 = and i32 %12, 2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %21
18: ; preds = %11
%19 = load i8*, i8** %3
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %18, %15
br label %22
22: ; preds = %21, %8
%23 = load i32, i32* %2
%24 = and i32 %23, 268435456
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i8*, i8** %3
%28 = load i8*, i8** %3
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %28, i8* %30)
br label %32
32: ; preds = %26, %22
%33 = load i8*, i8** %3
%34 = call i32 @display_message(i8* %33)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"e:ro\00"
@.str.1 = [5 x i8] c"e:bi\00"
@.str.3 = [7 x i8] c"%s: %s\00"
@errno = global i32 0
define void @handle_error(i32 %0) {
%2 = tail call dereferenceable_or_null(500) i8* @calloc(i32 500, i32 1)
%3 = and i32 %0, 256
%4 = icmp eq i32 %3, 0
br i1 %4, label %6, label %5
5: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) %2, i8* align 1 dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 5, i1 false)
br label %12
6: ; preds = %1
%7 = and i32 %0, 2
%8 = icmp eq i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %6
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) %2, i8* align 1 dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 5, i1 false)
br label %12
10: ; preds = %6
%11 = bitcast i8* %2 to i16*
store i16 101, i16* %11
br label %12
12: ; preds = %9, %10, %5
%13 = and i32 %0, 268435456
%14 = icmp eq i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* %17)
br label %19
19: ; preds = %15, %12
%20 = tail call i32 @display_message(i8* %2)
ret void
}