#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*/ print_debug(char *);
int /*<<< orphan*/ print_debug_char(char);
int /*<<< orphan*/ print_debug_hex8(int);
int smbus_read_byte(unsigned int, int);
void dump_ipmi_registers(void) {
  unsigned device;
  device = 0x42;
  while (device <= 0x42) {
    int status = 0;
    int i;
    print_debug("\n");
    print_debug("ipmi ");
    print_debug_hex8(device);
    for (i = 0; (i < 8); i++) {
      status = smbus_read_byte(device, 2);
      if (status < 0) {
        print_debug("bad device: ");
        print_debug_hex8(-status);
        print_debug("\n");
        break;
      }
      print_debug_hex8(status);
      print_debug_char(' ');
    }
    device += 1;
    print_debug("\n");
  }
}


x86 assembly (clang, -O0):
<dump_ipmi_registers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x42,-0x4(%rbp)
cmpl   $0x42,-0x4(%rbp)
ja     120c <dump_ipmi_registers+0xcc>
movl   $0x0,-0x8(%rbp)
lea    0xe99(%rip),%rdi
call   1050 <print_debug@plt>
lea    0xe8f(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%edi
call   1030 <print_debug_hex8@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11f2 <dump_ipmi_registers+0xb2>
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11d2 <dump_ipmi_registers+0x92>
lea    0xe56(%rip),%rdi
call   1050 <print_debug@plt>
xor    %edi,%edi
sub    -0x8(%rbp),%edi
call   1030 <print_debug_hex8@plt>
lea    0xe38(%rip),%rdi
call   1050 <print_debug@plt>
jmp    11f2 <dump_ipmi_registers+0xb2>
mov    -0x8(%rbp),%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1187 <dump_ipmi_registers+0x47>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    0xdfe(%rip),%rdi
call   1050 <print_debug@plt>
jmp    114f <dump_ipmi_registers+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_ipmi_registers>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1050 <print_debug@plt>
lea    0xeae(%rip),%rdi
call   1050 <print_debug@plt>
mov    $0x42,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x42,%edi
mov    $0x2,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,%ebx
test   %eax,%eax
js     12a9 <dump_ipmi_registers+0x169>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
mov    $0x42,%edi
mov    $0x2,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,%ebx
test   %eax,%eax
js     12a9 <dump_ipmi_registers+0x169>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
mov    $0x42,%edi
mov    $0x2,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,%ebx
test   %eax,%eax
js     12a9 <dump_ipmi_registers+0x169>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
mov    $0x42,%edi
mov    $0x2,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,%ebx
test   %eax,%eax
js     12a9 <dump_ipmi_registers+0x169>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
mov    $0x42,%edi
mov    $0x2,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,%ebx
test   %eax,%eax
js     12a9 <dump_ipmi_registers+0x169>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
mov    $0x42,%edi
mov    $0x2,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,%ebx
test   %eax,%eax
js     12a9 <dump_ipmi_registers+0x169>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
mov    $0x42,%edi
mov    $0x2,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,%ebx
test   %eax,%eax
js     12a9 <dump_ipmi_registers+0x169>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
mov    $0x42,%edi
mov    $0x2,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,%ebx
test   %eax,%eax
js     12a9 <dump_ipmi_registers+0x169>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
jmp    12ca <dump_ipmi_registers+0x18a>
lea    0xd58(%rip),%rdi
call   1050 <print_debug@plt>
neg    %ebx
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
lea    0xd3b(%rip),%rdi
call   1050 <print_debug@plt>
lea    0xd2f(%rip),%rdi
pop    %rbx
jmp    1050 <print_debug@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [6 x i8] c"ipmi \00"
@.str.2 = [13 x i8] c"bad device: \00"
define void @dump_ipmi_registers() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 66, i32* %1
br label %4
4: ; preds = %33, %0
%5 = load i32, i32* %1
%6 = icmp ule i32 %5, 66
br i1 %6, label %7, label %37
7: ; preds = %4
store i32 0, i32* %2
%8 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @print_debug(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 @print_debug_hex8(i32 %10)
store i32 0, i32* %3
br label %12
12: ; preds = %30, %7
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %33
15: ; preds = %12
%16 = load i32, i32* %1
%17 = call i32 @smbus_read_byte(i32 %16, i32 2)
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = call i32 @print_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* %2
%23 = sub nsw i32 0, %22
%24 = call i32 @print_debug_hex8(i32 %23)
%25 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %33
26: ; preds = %15
%27 = load i32, i32* %2
%28 = call i32 @print_debug_hex8(i32 %27)
%29 = call i32 @print_debug_char(i8 signext 32)
br label %30
30: ; preds = %26
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %12
33: ; preds = %20, %12
%34 = load i32, i32* %1
%35 = add i32 %34, 1
store i32 %35, i32* %1
%36 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %4
37: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [6 x i8] c"ipmi \00"
@.str.2 = [13 x i8] c"bad device: \00"
define void @dump_ipmi_registers() {
%1 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @print_debug(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @print_debug_hex8(i32 66)
%4 = tail call i32 @smbus_read_byte(i32 66, i32 2)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %42, %37, %32, %27, %22, %17, %12, %0
%7 = phi i32 [ %4, %0 ], [ %15, %12 ], [ %20, %17 ], [ %25, %22 ], [ %30, %27 ], [ %35, %32 ], [ %40, %37 ], [ %45, %42 ]
%8 = tail call i32 @print_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%9 = sub nsw i32 0, %7
%10 = tail call i32 @print_debug_hex8(i32 %9)
%11 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %50
12: ; preds = %0
%13 = tail call i32 @print_debug_hex8(i32 %4)
%14 = tail call i32 @print_debug_char(i8 signext 32)
%15 = tail call i32 @smbus_read_byte(i32 66, i32 2)
%16 = icmp slt i32 %15, 0
br i1 %16, label %6, label %17
17: ; preds = %12
%18 = tail call i32 @print_debug_hex8(i32 %15)
%19 = tail call i32 @print_debug_char(i8 signext 32)
%20 = tail call i32 @smbus_read_byte(i32 66, i32 2)
%21 = icmp slt i32 %20, 0
br i1 %21, label %6, label %22
22: ; preds = %17
%23 = tail call i32 @print_debug_hex8(i32 %20)
%24 = tail call i32 @print_debug_char(i8 signext 32)
%25 = tail call i32 @smbus_read_byte(i32 66, i32 2)
%26 = icmp slt i32 %25, 0
br i1 %26, label %6, label %27
27: ; preds = %22
%28 = tail call i32 @print_debug_hex8(i32 %25)
%29 = tail call i32 @print_debug_char(i8 signext 32)
%30 = tail call i32 @smbus_read_byte(i32 66, i32 2)
%31 = icmp slt i32 %30, 0
br i1 %31, label %6, label %32
32: ; preds = %27
%33 = tail call i32 @print_debug_hex8(i32 %30)
%34 = tail call i32 @print_debug_char(i8 signext 32)
%35 = tail call i32 @smbus_read_byte(i32 66, i32 2)
%36 = icmp slt i32 %35, 0
br i1 %36, label %6, label %37
37: ; preds = %32
%38 = tail call i32 @print_debug_hex8(i32 %35)
%39 = tail call i32 @print_debug_char(i8 signext 32)
%40 = tail call i32 @smbus_read_byte(i32 66, i32 2)
%41 = icmp slt i32 %40, 0
br i1 %41, label %6, label %42
42: ; preds = %37
%43 = tail call i32 @print_debug_hex8(i32 %40)
%44 = tail call i32 @print_debug_char(i8 signext 32)
%45 = tail call i32 @smbus_read_byte(i32 66, i32 2)
%46 = icmp slt i32 %45, 0
br i1 %46, label %6, label %47
47: ; preds = %42
%48 = tail call i32 @print_debug_hex8(i32 %45)
%49 = tail call i32 @print_debug_char(i8 signext 32)
br label %50
50: ; preds = %47, %6
%51 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}