#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) {
  unsigned device;
  print_debug("\n");
  for (device = 1; device < 0x80; device++) {
    int j;
    if (smbus_read_byte(device, 0) < 0)
      continue;
    print_debug("smbus: ");
    print_debug_hex8(device);
    for (j = 0; j < 256; j++) {
      int status;
      unsigned char byte;
      status = smbus_read_byte(device, j);
      if (status < 0) {
        break;
      }
      if ((j & 0xf) == 0) {
        print_debug("\n");
        print_debug_hex8(j);
        print_debug(": ");
      }
      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    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <print_debug@plt>
movl   $0x1,-0x4(%rbp)
cmpl   $0x80,-0x4(%rbp)
jae    1240 <dump_smbus_registers+0x100>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1040 <smbus_read_byte@plt>
cmp    $0x0,%eax
jge    1180 <dump_smbus_registers+0x40>
jmp    1232 <dump_smbus_registers+0xf2>
lea    0xe7b(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%eax
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1226 <dump_smbus_registers+0xe6>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11c8 <dump_smbus_registers+0x88>
jmp    1226 <dump_smbus_registers+0xe6>
mov    -0x8(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11fa <dump_smbus_registers+0xba>
lea    0xe22(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
lea    0xe12(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,-0xd(%rbp)
movzbl -0xd(%rbp),%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119e <dump_smbus_registers+0x5e>
lea    0xdd3(%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    $0x10,%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    0xeae(%rip),%r12
mov    %r12,%rdi
call   1050 <print_debug@plt>
mov    $0x1,%r13d
lea    0xe9b(%rip),%r14
lea    0xe99(%rip),%r15
jmp    1185 <dump_smbus_registers+0x45>
mov    %r12,%rdi
call   1050 <print_debug@plt>
add    $0x1,%r13d
cmp    $0x80,%r13d
je     11fd <dump_smbus_registers+0xbd>
mov    %r13d,%edi
xor    %esi,%esi
call   1040 <smbus_read_byte@plt>
test   %eax,%eax
js     1178 <dump_smbus_registers+0x38>
mov    %r14,%rdi
call   1050 <print_debug@plt>
movzbl %r13b,%edi
call   1030 <print_debug_hex8@plt>
xor    %ebx,%ebx
jmp    11ce <dump_smbus_registers+0x8e>
nopl   0x0(%rax,%rax,1)
movzbl %bpl,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
add    $0x1,%ebx
cmp    $0x100,%ebx
je     1170 <dump_smbus_registers+0x30>
mov    %r13d,%edi
mov    %ebx,%esi
call   1040 <smbus_read_byte@plt>
test   %eax,%eax
js     1170 <dump_smbus_registers+0x30>
mov    %eax,%ebp
test   $0xf,%bl
jne    11b0 <dump_smbus_registers+0x70>
mov    %r12,%rdi
call   1050 <print_debug@plt>
movzbl %bl,%edi
call   1030 <print_debug_hex8@plt>
mov    %r15,%rdi
call   1050 <print_debug@plt>
jmp    11b0 <dump_smbus_registers+0x70>
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"
define void @dump_smbus_registers() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = 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 %6
6: ; preds = %51, %0
%7 = load i32, i32* %1
%8 = icmp ult i32 %7, 128
br i1 %8, label %9, label %54
9: ; preds = %6
%10 = load i32, i32* %1
%11 = call i32 @smbus_read_byte(i32 %10, i32 0)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
br label %51
14: ; preds = %9
%15 = call i32 @print_debug(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %1
%17 = trunc i32 %16 to i8
%18 = call i32 @print_debug_hex8(i8 zeroext %17)
store i32 0, i32* %2
br label %19
19: ; preds = %46, %14
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 256
br i1 %21, label %22, label %49
22: ; preds = %19
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = call i32 @smbus_read_byte(i32 %23, i32 %24)
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %22
br label %49
29: ; preds = %22
%30 = load i32, i32* %2
%31 = and i32 %30, 15
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %29
%34 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%35 = load i32, i32* %2
%36 = trunc i32 %35 to i8
%37 = call i32 @print_debug_hex8(i8 zeroext %36)
%38 = call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %33, %29
%40 = load i32, i32* %3
%41 = and i32 %40, 255
%42 = trunc i32 %41 to i8
store i8 %42, i8* %4
%43 = load i8, i8* %4
%44 = call i32 @print_debug_hex8(i8 zeroext %43)
%45 = call i32 @print_debug_char(i8 signext 32)
br label %46
46: ; preds = %39
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %19
49: ; preds = %28, %19
%50 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %51
51: ; preds = %49, %13
%52 = load i32, i32* %1
%53 = add i32 %52, 1
store i32 %53, i32* %1
br label %6
54: ; preds = %6
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"
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, %30
%3 = phi i32 [ 1, %0 ], [ %31, %30 ]
%4 = tail call i32 @smbus_read_byte(i32 %3, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %30, label %6
6: ; preds = %2
%7 = tail call i32 @print_debug(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%8 = trunc i32 %3 to i8
%9 = tail call i32 @print_debug_hex8(i8 zeroext %8)
br label %10
10: ; preds = %6, %22
%11 = phi i32 [ 0, %6 ], [ %26, %22 ]
%12 = tail call i32 @smbus_read_byte(i32 %3, i32 %11)
%13 = icmp slt i32 %12, 0
br i1 %13, label %28, label %14
14: ; preds = %10
%15 = and i32 %11, 15
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = trunc i32 %11 to i8
%20 = tail call i32 @print_debug_hex8(i8 zeroext %19)
%21 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %14, %17
%23 = trunc i32 %12 to i8
%24 = tail call i32 @print_debug_hex8(i8 zeroext %23)
%25 = tail call i32 @print_debug_char(i8 signext 32)
%26 = add nuw nsw i32 %11, 1
%27 = icmp eq i32 %26, 256
br i1 %27, label %28, label %10
28: ; preds = %10, %22
%29 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %2, %28
%31 = add nuw nsw i32 %3, 1
%32 = icmp eq i32 %31, 128
br i1 %32, label %33, label %2
33: ; preds = %30
ret void
}