#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(unsigned char);
int smbus_read_byte(unsigned int, int);
void dump_smbus_registers(void) {
  int i;
  print_debug("\n");
  for (i = 1; i < 0x80; i++) {
    unsigned device;
    device = i;
    int j;
    print_debug("smbus: ");
    print_debug_hex8(device);
    for (j = 0; j < 256; j++) {
      int status;
      unsigned char byte;
      if ((j & 0xf) == 0) {
        print_debug("\n");
        print_debug_hex8(j);
        print_debug(": ");
      }
      status = smbus_read_byte(device, j);
      if (status < 0) {
        print_debug("bad device\n");
        break;
      }
      byte = status & 0xff;
      print_debug_hex8(byte);
      print_debug_char(' ');
    }
    print_debug("\n");
  }
}


x86 assembly (clang, -O0):
<dump_smbus_registers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec3(%rip),%rdi
call   1050 <print_debug@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0x80,-0x4(%rbp)
jge    123a <dump_smbus_registers+0xfa>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
lea    0xe8b(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jge    1220 <dump_smbus_registers+0xe0>
mov    -0xc(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11cb <dump_smbus_registers+0x8b>
lea    0xe63(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0xc(%rbp),%eax
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
lea    0xe3f(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11f4 <dump_smbus_registers+0xb4>
lea    0xe1e(%rip),%rdi
call   1050 <print_debug@plt>
jmp    1220 <dump_smbus_registers+0xe0>
mov    -0x10(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x11(%rbp)
movzbl -0x11(%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    118c <dump_smbus_registers+0x4c>
lea    0xdeb(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    115b <dump_smbus_registers+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_smbus_registers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xec0(%rip),%r13
mov    %r13,%rdi
call   1050 <print_debug@plt>
mov    $0x1,%ebp
lea    0xe9a(%rip),%r14
lea    0xe98(%rip),%r15
lea    0xe94(%rip),%r12
jmp    119b <dump_smbus_registers+0x5b>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <print_debug@plt>
mov    %r13,%rdi
call   1050 <print_debug@plt>
add    $0x1,%ebp
cmp    $0x80,%ebp
je     11f9 <dump_smbus_registers+0xb9>
mov    %r14,%rdi
call   1050 <print_debug@plt>
movzbl %bpl,%edi
call   1030 <print_debug_hex8@plt>
xor    %ebx,%ebx
xchg   %ax,%ax
test   $0xf,%bl
jne    11cd <dump_smbus_registers+0x8d>
mov    %r13,%rdi
call   1050 <print_debug@plt>
movzbl %bl,%edi
call   1030 <print_debug_hex8@plt>
mov    %r15,%rdi
call   1050 <print_debug@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <smbus_read_byte@plt>
test   %eax,%eax
js     1180 <dump_smbus_registers+0x40>
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
add    $0x1,%ebx
cmp    $0x100,%ebx
jne    11b0 <dump_smbus_registers+0x70>
jmp    1188 <dump_smbus_registers+0x48>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [8 x i8] c"smbus: \00"
@.str.2 = [3 x i8] c": \00"
@.str.3 = [12 x i8] c"bad device\0A\00"
define void @dump_smbus_registers() {
%1 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %27
%3 = phi i32 [ 1, %0 ], [ %29, %27 ]
%4 = tail call i32 @print_debug(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%5 = trunc i32 %3 to i8
%6 = tail call i32 @print_debug_hex8(i8 zeroext %5)
br label %7
7: ; preds = %2, %21
%8 = phi i32 [ 0, %2 ], [ %25, %21 ]
%9 = and i32 %8, 15
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = trunc i32 %8 to i8
%14 = tail call i32 @print_debug_hex8(i8 zeroext %13)
%15 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %11, %7
%17 = tail call i32 @smbus_read_byte(i32 %3, i32 %8)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @print_debug(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %27
21: ; preds = %16
%22 = trunc i32 %17 to i8
%23 = tail call i32 @print_debug_hex8(i8 zeroext %22)
%24 = tail call i32 @print_debug_char(i8 signext 32)
%25 = add nuw nsw i32 %8, 1
%26 = icmp eq i32 %25, 256
br i1 %26, label %27, label %7
27: ; preds = %21, %19
%28 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%29 = add nuw nsw i32 %3, 1
%30 = icmp eq i32 %29, 128
br i1 %30, label %31, label %2
31: ; preds = %27
ret void
}