#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_hex8(unsigned char);
int smbus_read_byte(unsigned int, int /*<<< orphan*/);
void dump_spd_registers2(void) {
  unsigned dev;
  print_debug("\r\n");
  for (dev = (0xa << 3); dev <= ((0xa << 3) + 1); dev += 1) {
    print_debug("dimm: ");
    print_debug_hex8(dev);
    int status;
    unsigned char byte;
    status = smbus_read_byte(dev, 0);
    if (status < 0) {
      print_debug("bad device\r\n");
      continue;
    }
    byte = status & 0xff;
    print_debug_hex8(byte);
    print_debug("\r\n");
  }
}


x86 assembly (clang, -O0):
<dump_spd_registers2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed2(%rip),%rdi
call   1050 <print_debug@plt>
movl   $0x50,-0x4(%rbp)
cmpl   $0x51,-0x4(%rbp)
ja     11c2 <dump_spd_registers2+0x92>
lea    0xea4(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%eax
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1194 <dump_spd_registers2+0x64>
lea    0xe7d(%rip),%rdi
call   1050 <print_debug@plt>
jmp    11b4 <dump_spd_registers2+0x84>
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%edi
call   1030 <print_debug_hex8@plt>
lea    0xe62(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114b <dump_spd_registers2+0x1b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_spd_registers2>:
push   %r14
push   %rbx
push   %rax
lea    0xed6(%rip),%r14
mov    %r14,%rdi
call   1050 <print_debug@plt>
lea    0xeb6(%rip),%rdi
call   1050 <print_debug@plt>
mov    $0x50,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x50,%edi
xor    %esi,%esi
call   1040 <smbus_read_byte@plt>
lea    0xe9b(%rip),%rbx
mov    %rbx,%rdi
test   %eax,%eax
js     117e <dump_spd_registers2+0x4e>
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
mov    %r14,%rdi
call   1050 <print_debug@plt>
lea    0xe76(%rip),%rdi
call   1050 <print_debug@plt>
mov    $0x51,%edi
call   1030 <print_debug_hex8@plt>
mov    $0x51,%edi
xor    %esi,%esi
call   1040 <smbus_read_byte@plt>
test   %eax,%eax
js     11b8 <dump_spd_registers2+0x88>
movzbl %al,%edi
call   1030 <print_debug_hex8@plt>
lea    0xe59(%rip),%rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = [13 x i8] c"bad device\0D\0A\00"
define void @dump_spd_registers2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 80, i32* %1
br label %5
5: ; preds = %26, %0
%6 = load i32, i32* %1
%7 = icmp ule i32 %6, 81
br i1 %7, label %8, label %29
8: ; preds = %5
%9 = call i32 @print_debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = trunc i32 %10 to i8
%12 = call i32 @print_debug_hex8(i8 zeroext %11)
%13 = load i32, i32* %1
%14 = call i32 @smbus_read_byte(i32 %13, i32 0)
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = call i32 @print_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %26
19: ; preds = %8
%20 = load i32, i32* %2
%21 = and i32 %20, 255
%22 = trunc i32 %21 to i8
store i8 %22, i8* %3
%23 = load i8, i8* %3
%24 = call i32 @print_debug_hex8(i8 zeroext %23)
%25 = call i32 @print_debug(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %19, %17
%27 = load i32, i32* %1
%28 = add i32 %27, 1
store i32 %28, i32* %1
br label %5
29: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [7 x i8] c"dimm: \00"
@.str.2 = [13 x i8] c"bad device\0D\0A\00"
define void @dump_spd_registers2() {
%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)
%4 = tail call i32 @smbus_read_byte(i32 80, i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = trunc i32 %4 to i8
%8 = tail call i32 @print_debug_hex8(i8 zeroext %7)
br label %9
9: ; preds = %0, %6
%10 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %6 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %0 ]
%11 = tail call i32 @print_debug(i8* %10)
%12 = tail call i32 @print_debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @print_debug_hex8(i8 zeroext 81)
%14 = tail call i32 @smbus_read_byte(i32 81, i32 0)
%15 = icmp slt i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %9
%17 = trunc i32 %14 to i8
%18 = tail call i32 @print_debug_hex8(i8 zeroext %17)
br label %19
19: ; preds = %9, %16
%20 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %16 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), %9 ]
%21 = tail call i32 @print_debug(i8* %20)
ret void
}