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


x86 assembly (clang, -O0):
<dump_spd_registers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x50,-0x4(%rbp)
lea    0xebb(%rip),%rdi
call   1050 <print_debug@plt>
cmpl   $0x57,-0x4(%rbp)
ja     1231 <dump_spd_registers+0xf1>
lea    0xe94(%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    1217 <dump_spd_registers+0xd7>
mov    -0x8(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11c2 <dump_spd_registers+0x82>
lea    0xe6b(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x8(%rbp),%eax
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
lea    0xe47(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11eb <dump_spd_registers+0xab>
lea    0xe26(%rip),%rdi
call   1050 <print_debug@plt>
jmp    1217 <dump_spd_registers+0xd7>
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    1183 <dump_spd_registers+0x43>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    0xdea(%rip),%rdi
call   1050 <print_debug@plt>
jmp    115b <dump_spd_registers+0x1b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_spd_registers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebf(%rip),%r13
mov    %r13,%rdi
call   1050 <print_debug@plt>
mov    $0x50,%ebp
lea    0xe9a(%rip),%r14
lea    0xe97(%rip),%r15
lea    0xe93(%rip),%r12
jmp    1198 <dump_spd_registers+0x58>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <print_debug@plt>
add    $0x1,%ebp
mov    %r13,%rdi
call   1050 <print_debug@plt>
cmp    $0x58,%ebp
je     11f9 <dump_spd_registers+0xb9>
mov    %r14,%rdi
call   1050 <print_debug@plt>
movzbl %bpl,%edi
call   1030 <print_debug_hex8@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
test   $0xf,%bl
jne    11cd <dump_spd_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_spd_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_spd_registers+0x70>
jmp    1188 <dump_spd_registers+0x48>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [7 x i8] c"dimm: \00"
@.str.2 = [3 x i8] c": \00"
@.str.3 = [13 x i8] c"bad device\0D\0A\00"
define void @dump_spd_registers() {
%1 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %27
%3 = phi i32 [ 80, %0 ], [ %28, %27 ]
%4 = tail call i32 @print_debug(i8* getelementptr inbounds ([7 x i8], [7 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 ([3 x i8], [3 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 ([13 x i8], [13 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 = add nuw nsw i32 %3, 1
%29 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i32 %28, 88
br i1 %30, label %31, label %2
31: ; preds = %27
ret void
}