#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 EINVAL;
int ERANGE;
int /*<<< orphan*/ printf(char *, ...);
void dump_error(int err) {
  if (err == EINVAL)
    printf("error: EINVAL\n");
  else if (err == ERANGE)
    printf("error: ERANGE\n");
  else if (err != 0)
    printf("error: errno == %d\n", err);
}


x86 assembly (clang, -O0):
<dump_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eb3(%rip),%rcx
cmp    (%rcx),%eax
jne    1140 <dump_error+0x30>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118a <dump_error+0x7a>
mov    -0x4(%rbp),%eax
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%eax
jne    1165 <dump_error+0x55>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1185 <dump_error+0x75>
cmpl   $0x0,-0x4(%rbp)
je     1180 <dump_error+0x70>
mov    -0x4(%rbp),%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1185 <dump_error+0x75>
jmp    118a <dump_error+0x7a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_error>:
mov    0x2eb1(%rip),%rax
cmp    %edi,(%rax)
jne    1137 <dump_error+0x17>
lea    0xef0(%rip),%rdi
jmp    1030 <puts@plt>
mov    %edi,%esi
mov    0x2ea8(%rip),%rax
cmp    %edi,(%rax)
jne    1150 <dump_error+0x30>
lea    0xec9(%rip),%rdi
jmp    1030 <puts@plt>
test   %esi,%esi
je     1162 <dump_error+0x42>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
jmp    1040 <printf@plt>
ret

LLVM IR (-O0):
@EINVAL = global i32 0
@.str = [15 x i8] c"error: EINVAL\0A\00"
@ERANGE = global i32 0
@.str.1 = [15 x i8] c"error: ERANGE\0A\00"
@.str.2 = [20 x i8] c"error: errno == %d\0A\00"
define void @dump_error(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @EINVAL
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %22
8: ; preds = %1
%9 = load i32, i32* %2
%10 = load i32, i32* @ERANGE
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %21
14: ; preds = %8
%15 = load i32, i32* %2
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %14
br label %21
21: ; preds = %20, %12
br label %22
22: ; preds = %21, %6
ret void
}

LLVM IR (-O2):
@EINVAL = global i32 0
@ERANGE = global i32 0
@.str.2 = [20 x i8] c"error: errno == %d\0A\00"
@str = [14 x i8] c"error: ERANGE\00"
@str.3 = [14 x i8] c"error: EINVAL\00"
define void @dump_error(i32 %0) {
%2 = load i32, i32* @EINVAL
%3 = icmp eq i32 %2, %0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.3, i64 0, i64 0))
br label %15
6: ; preds = %1
%7 = load i32, i32* @ERANGE
%8 = icmp eq i32 %7, %0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %15
11: ; preds = %6
%12 = icmp eq i32 %0, 0
br i1 %12, label %15, label %13
13: ; preds = %11
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %15
15: ; preds = %9, %13, %11, %4
ret void
}