#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) + 1)) {
    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");
        continue;
      }
      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   $0x51,-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    1209 <dump_spd_registers+0xc9>
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   %rbx
push   %rax
lea    0xec3(%rip),%r14
mov    %r14,%rdi
call   1050 <print_debug@plt>
lea    0xea3(%rip),%rdi
call   1050 <print_debug@plt>
mov    $0x50,%edi
call   1030 <print_debug_hex8@plt>
xor    %ebp,%ebp
lea    0xe8f(%rip),%r15
lea    0xe8b(%rip),%rbx
jmp    119d <dump_spd_registers+0x5d>
xchg   %ax,%ax
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     11d6 <dump_spd_registers+0x96>
test   $0xf,%bpl
jne    11bc <dump_spd_registers+0x7c>
mov    %r14,%rdi
call   1050 <print_debug@plt>
movzbl %bpl,%edi
call   1030 <print_debug_hex8@plt>
mov    %r15,%rdi
call   1050 <print_debug@plt>
mov    $0x50,%edi
mov    %ebp,%esi
call   1040 <smbus_read_byte@plt>
test   %eax,%eax
jns    1180 <dump_spd_registers+0x40>
mov    %rbx,%rdi
call   1050 <print_debug@plt>
jmp    1192 <dump_spd_registers+0x52>
lea    0xe34(%rip),%r14
mov    %r14,%rdi
call   1050 <print_debug@plt>
lea    0xe14(%rip),%rdi
call   1050 <print_debug@plt>
mov    $0x51,%edi
call   1030 <print_debug_hex8@plt>
xor    %ebp,%ebp
lea    0xe00(%rip),%r15
lea    0xdfc(%rip),%rbx
jmp    1223 <dump_spd_registers+0xe3>
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <print_debug@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     1266 <dump_spd_registers+0x126>
test   $0xf,%bpl
jne    1242 <dump_spd_registers+0x102>
mov    %r14,%rdi
call   1050 <print_debug@plt>
movzbl %bpl,%edi
call   1030 <print_debug_hex8@plt>
mov    %r15,%rdi
call   1050 <print_debug@plt>
mov    $0x51,%edi
mov    %ebp,%esi
call   1040 <smbus_read_byte@plt>
test   %eax,%eax
js     1210 <dump_spd_registers+0xd0>
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
jmp    1218 <dump_spd_registers+0xd8>
lea    0xda4(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <print_debug@plt>

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, 81
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 %42
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, %33
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
br label %14
45: ; preds = %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))
%2 = tail call i32 @print_debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @print_debug_hex8(i8 zeroext 80)
br label %4
4: ; preds = %0, %22
%5 = phi i32 [ 0, %0 ], [ %23, %22 ]
%6 = and i32 %5, 15
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = trunc i32 %5 to i8
%11 = tail call i32 @print_debug_hex8(i8 zeroext %10)
%12 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %8, %4
%14 = tail call i32 @smbus_read_byte(i32 80, i32 %5)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @print_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %22
18: ; preds = %13
%19 = trunc i32 %14 to i8
%20 = tail call i32 @print_debug_hex8(i8 zeroext %19)
%21 = tail call i32 @print_debug_char(i8 signext 32)
br label %22
22: ; preds = %18, %16
%23 = add nuw nsw i32 %5, 1
%24 = icmp eq i32 %23, 256
br i1 %24, label %25, label %4
25: ; preds = %22
%26 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%27 = tail call i32 @print_debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%28 = tail call i32 @print_debug_hex8(i8 zeroext 81)
br label %29
29: ; preds = %47, %25
%30 = phi i32 [ 0, %25 ], [ %48, %47 ]
%31 = and i32 %30, 15
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%35 = trunc i32 %30 to i8
%36 = tail call i32 @print_debug_hex8(i8 zeroext %35)
%37 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %33, %29
%39 = tail call i32 @smbus_read_byte(i32 81, i32 %30)
%40 = icmp slt i32 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %38
%42 = trunc i32 %39 to i8
%43 = tail call i32 @print_debug_hex8(i8 zeroext %42)
%44 = tail call i32 @print_debug_char(i8 signext 32)
br label %47
45: ; preds = %38
%46 = tail call i32 @print_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %45, %41
%48 = add nuw nsw i32 %30, 1
%49 = icmp eq i32 %48, 256
br i1 %49, label %50, label %29
50: ; preds = %47
%51 = tail call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
ret void
}