#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_spd_registers(void) {
  unsigned device;
  device = 0x50;
  while (device <= 0x57) {
    int status = 0;
    int i;
    print_debug("\n");
    print_debug("dimm ");
    print_debug_hex8(device);
    for (i = 0; (i < 256); i++) {
      unsigned char byte;
      if ((i % 16) == 0) {
        print_debug("\n");
        print_debug_hex8(i);
        print_debug(": ");
      }
      status = smbus_read_byte(device, i);
      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_spd_registers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x50,-0x4(%rbp)
cmpl   $0x57,-0x4(%rbp)
ja     1241 <dump_spd_registers+0x101>
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   $0x100,-0xc(%rbp)
jge    1227 <dump_spd_registers+0xe7>
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c8 <dump_spd_registers+0x88>
lea    0xe51(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0xc(%rbp),%edi
call   1030 <print_debug_hex8@plt>
lea    0xe4f(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1207 <dump_spd_registers+0xc7>
lea    0xe21(%rip),%rdi
call   1050 <print_debug@plt>
xor    %edi,%edi
sub    -0x8(%rbp),%edi
call   1030 <print_debug_hex8@plt>
lea    0xe03(%rip),%rdi
call   1050 <print_debug@plt>
jmp    1227 <dump_spd_registers+0xe7>
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_spd_registers+0x47>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    0xdc9(%rip),%rdi
call   1050 <print_debug@plt>
jmp    114f <dump_spd_registers+0xf>
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
mov    $0x50,%ebx
lea    0xea9(%rip),%r14
lea    0xea4(%rip),%r15
lea    0xead(%rip),%r12
jmp    119f <dump_spd_registers+0x5f>
nopw   0x0(%rax,%rax,1)
lea    0xe91(%rip),%rdi
call   1050 <print_debug@plt>
neg    %r13d
mov    %r13d,%edi
call   1030 <print_debug_hex8@plt>
mov    %r14,%rdi
call   1050 <print_debug@plt>
add    $0x1,%ebx
mov    %r14,%rdi
call   1050 <print_debug@plt>
cmp    $0x58,%ebx
je     120c <dump_spd_registers+0xcc>
mov    %r14,%rdi
call   1050 <print_debug@plt>
mov    %r15,%rdi
call   1050 <print_debug@plt>
mov    %ebx,%edi
call   1030 <print_debug_hex8@plt>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
test   $0xf,%bpl
jne    11dd <dump_spd_registers+0x9d>
mov    %r14,%rdi
call   1050 <print_debug@plt>
mov    %ebp,%edi
call   1030 <print_debug_hex8@plt>
mov    %r12,%rdi
call   1050 <print_debug@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,%r13d
test   %eax,%eax
js     1170 <dump_spd_registers+0x30>
mov    %r13d,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    11c0 <dump_spd_registers+0x80>
jmp    118f <dump_spd_registers+0x4f>
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 = [6 x i8] c"dimm \00"
@.str.2 = [3 x i8] c": \00"
@.str.3 = [13 x i8] c"bad device: \00"
define void @dump_spd_registers() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 80, i32* %1
br label %5
5: ; preds = %44, %0
%6 = load i32, i32* %1
%7 = icmp ule i32 %6, 87
br i1 %7, label %8, label %48
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 = %41, %8
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 256
br i1 %15, label %16, label %44
16: ; preds = %13
%17 = load i32, i32* %3
%18 = srem i32 %17, 16
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* %3
%23 = call i32 @print_debug_hex8(i32 %22)
%24 = call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %20, %16
%26 = load i32, i32* %1
%27 = load i32, i32* %3
%28 = call i32 @smbus_read_byte(i32 %26, i32 %27)
store i32 %28, i32* %2
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %25
%32 = call i32 @print_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%33 = load i32, i32* %2
%34 = sub nsw i32 0, %33
%35 = call i32 @print_debug_hex8(i32 %34)
%36 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %44
37: ; preds = %25
%38 = load i32, i32* %2
%39 = call i32 @print_debug_hex8(i32 %38)
%40 = call i32 @print_debug_char(i8 signext 32)
br label %41
41: ; preds = %37
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %13
44: ; preds = %31, %13
%45 = load i32, i32* %1
%46 = add i32 %45, 1
store i32 %46, i32* %1
%47 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %5
48: ; preds = %5
ret void
}

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