#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 */
struct bc_read_stream {
  int dummy;
};

/* Variables and functions */
int bc_rs_get_error(struct bc_read_stream *);
int /*<<< orphan*/ printf(char *);
void check_error(struct bc_read_stream *s) {
  if (bc_rs_get_error(s)) {
    int err = bc_rs_get_error(s);
    printf("There were stream errors!\n");
    if (err & 0x1)
      printf("  Value too large.\n");
    if (err & 0x2)
      printf("  No such value.\n");
    if (err & 0x4)
      printf("  IO error.\n");
    if (err & 0x8)
      printf("  Corrupt input.\n");
    if (err & 0x10)
      printf("  Internal error.\n");
  }
}


x86 assembly (clang, -O0):
<check_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <bc_rs_get_error@plt>
cmp    $0x0,%eax
je     11e2 <check_error+0xc2>
mov    -0x8(%rbp),%rdi
call   1030 <bc_rs_get_error@plt>
mov    %eax,-0xc(%rbp)
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1171 <check_error+0x51>
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     118c <check_error+0x6c>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     11a7 <check_error+0x87>
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     11c2 <check_error+0xa2>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11dd <check_error+0xbd>
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
jmp    11e2 <check_error+0xc2>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_error>:
push   %rbx
mov    %rdi,%rbx
call   1030 <bc_rs_get_error@plt>
test   %eax,%eax
je     115c <check_error+0x3c>
mov    %rbx,%rdi
call   1030 <bc_rs_get_error@plt>
mov    %eax,%ebx
lea    0xec2(%rip),%rdi
call   1040 <puts@plt>
test   $0x1,%bl
jne    115e <check_error+0x3e>
test   $0x2,%bl
jne    116f <check_error+0x4f>
test   $0x4,%bl
jne    1180 <check_error+0x60>
test   $0x8,%bl
jne    1191 <check_error+0x71>
test   $0x10,%bl
jne    11a2 <check_error+0x82>
pop    %rbx
ret
lea    0xef5(%rip),%rdi
call   1040 <puts@plt>
test   $0x2,%bl
je     114d <check_error+0x2d>
lea    0xed3(%rip),%rdi
call   1040 <puts@plt>
test   $0x4,%bl
je     1152 <check_error+0x32>
lea    0xeb6(%rip),%rdi
call   1040 <puts@plt>
test   $0x8,%bl
je     1157 <check_error+0x37>
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
test   $0x10,%bl
je     115c <check_error+0x3c>
lea    0xe71(%rip),%rdi
pop    %rbx
jmp    1040 <puts@plt>

LLVM IR (-O0):
%struct.bc_read_stream = type { i32 }
@.str = [27 x i8] c"There were stream errors!\0A\00"
@.str.1 = [20 x i8] c" Value too large.\0A\00"
@.str.2 = [18 x i8] c" No such value.\0A\00"
@.str.3 = [13 x i8] c" IO error.\0A\00"
@.str.4 = [18 x i8] c" Corrupt input.\0A\00"
@.str.5 = [19 x i8] c" Internal error.\0A\00"
define void @check_error(%struct.bc_read_stream* %0) {
%2 = alloca %struct.bc_read_stream*
%3 = alloca i32
store %struct.bc_read_stream* %0, %struct.bc_read_stream** %2
%4 = load %struct.bc_read_stream*, %struct.bc_read_stream** %2
%5 = call i32 @bc_rs_get_error(%struct.bc_read_stream* %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %41
7: ; preds = %1
%8 = load %struct.bc_read_stream*, %struct.bc_read_stream** %2
%9 = call i32 @bc_rs_get_error(%struct.bc_read_stream* %8)
store i32 %9, i32* %3
%10 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %3
%12 = and i32 %11, 1
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %7
%17 = load i32, i32* %3
%18 = and i32 %17, 2
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = load i32, i32* %3
%24 = and i32 %23, 4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = load i32, i32* %3
%30 = and i32 %29, 8
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
%35 = load i32, i32* %3
%36 = and i32 %35, 16
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
br label %41
41: ; preds = %40, %1
ret void
}

LLVM IR (-O2):
%struct.bc_read_stream = type { i32 }
@str = [26 x i8] c"There were stream errors!\00"
@str.6 = [18 x i8] c" Internal error.\00"
@str.7 = [17 x i8] c" Corrupt input.\00"
@str.8 = [12 x i8] c" IO error.\00"
@str.9 = [17 x i8] c" No such value.\00"
@str.10 = [19 x i8] c" Value too large.\00"
define void @check_error(%struct.bc_read_stream* %0) {
%2 = tail call i32 @bc_rs_get_error(%struct.bc_read_stream* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %31, label %4
4: ; preds = %1
%5 = tail call i32 @bc_rs_get_error(%struct.bc_read_stream* %0)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%7 = and i32 %5, 1
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.10, i64 0, i64 0))
br label %11
11: ; preds = %9, %4
%12 = and i32 %5, 2
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = and i32 %5, 4
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.8, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
%22 = and i32 %5, 8
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = and i32 %5, 16
%28 = icmp eq i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
br label %31
31: ; preds = %26, %29, %1
ret void
}