#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++) {
      unsigned char byte;
      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
%4 = alloca i8
store i32 66, i32* %1
br label %5
5: ; preds = %34, %0
%6 = load i32, i32* %1
%7 = icmp ule i32 %6, 66
br i1 %7, label %8, label %38
8: ; preds = %5
store i32 0, i32* %2
%9 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @print_debug(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = call i32 @print_debug_hex8(i32 %11)
store i32 0, i32* %3
br label %13
13: ; preds = %31, %8
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 8
br i1 %15, label %16, label %34
16: ; preds = %13
%17 = load i32, i32* %1
%18 = call i32 @smbus_read_byte(i32 %17, i32 2)
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %16
%22 = call i32 @print_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* %2
%24 = sub nsw i32 0, %23
%25 = call i32 @print_debug_hex8(i32 %24)
%26 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %34
27: ; preds = %16
%28 = load i32, i32* %2
%29 = call i32 @print_debug_hex8(i32 %28)
%30 = call i32 @print_debug_char(i8 signext 32)
br label %31
31: ; preds = %27
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %13
34: ; preds = %21, %13
%35 = load i32, i32* %1
%36 = add i32 %35, 1
store i32 %36, i32* %1
%37 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %5
38: ; preds = %5
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
}