#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(int, int);
void dump_spd_registers1(void) {
  int i;
  print_debug("dimm: ");
  print_debug_hex8((0xa << 3));
  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((0xa << 3), i);
    if (status < 0) {
      print_debug("bad device\r\n");
      break;
    }
    byte = status & 0xff;
    print_debug_hex8(byte);
    print_debug_char(' ');
  }
  print_debug("\r\n");
}


x86 assembly (clang, -O0):
<dump_spd_registers1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <print_debug@plt>
mov    $0x50,%edi
call   1030 <print_debug_hex8@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x100,-0x4(%rbp)
jge    11fb <dump_spd_registers1+0xbb>
mov    -0x4(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11a4 <dump_spd_registers1+0x64>
lea    0xe89(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%eax
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
lea    0xe65(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%esi
mov    $0x50,%edi
call   1040 <smbus_read_byte@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11cf <dump_spd_registers1+0x8f>
lea    0xe42(%rip),%rdi
call   1050 <print_debug@plt>
jmp    11fb <dump_spd_registers1+0xbb>
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%edi
call   1030 <print_debug_hex8@plt>
mov    $0x20,%edi
call   1060 <print_debug_char@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1165 <dump_spd_registers1+0x25>
lea    0xe0f(%rip),%rdi
call   1050 <print_debug@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_spd_registers1>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%rdi
call   1050 <print_debug@plt>
mov    $0x50,%edi
call   1030 <print_debug_hex8@plt>
xor    %ebx,%ebx
lea    0xead(%rip),%r14
lea    0xe99(%rip),%r15
nopl   0x0(%rax,%rax,1)
test   $0xf,%bl
jne    118d <dump_spd_registers1+0x4d>
mov    %r14,%rdi
call   1050 <print_debug@plt>
movzbl %bl,%edi
call   1030 <print_debug_hex8@plt>
mov    %r15,%rdi
call   1050 <print_debug@plt>
mov    $0x50,%edi
mov    %ebx,%esi
call   1040 <smbus_read_byte@plt>
test   %eax,%eax
js     11bc <dump_spd_registers1+0x7c>
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    1170 <dump_spd_registers1+0x30>
jmp    11c8 <dump_spd_registers1+0x88>
lea    0xe44(%rip),%rdi
call   1050 <print_debug@plt>
lea    0xe42(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <print_debug@plt>

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

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