#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(int);
int smbus_read_byte(unsigned int, int /*<<< orphan*/);
void show_dram_slots(void) {
  unsigned device;
  device = 0x50;
  while (device <= 0x57) {
    int status = 0;
    int i;
    print_debug("\n");
    print_debug("dimm ");
    print_debug_hex8(device);
    status = smbus_read_byte(device, 0);
    if (status < 0) {
      print_debug("bad device: ");
    } else {
      print_debug("present: ");
    }
    print_debug_hex8(status);
    print_debug("\n");
    device += 1;
    print_debug("\n");
  }
}


x86 assembly (clang, -O0):
<show_dram_slots>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x50,-0x4(%rbp)
cmpl   $0x57,-0x4(%rbp)
ja     11d2 <show_dram_slots+0xa2>
movl   $0x0,-0x8(%rbp)
lea    0xea9(%rip),%rdi
call   1050 <print_debug@plt>
lea    0xe9f(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%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    1198 <show_dram_slots+0x68>
lea    0xe7a(%rip),%rdi
call   1050 <print_debug@plt>
jmp    11a4 <show_dram_slots+0x74>
lea    0xe76(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x8(%rbp),%edi
call   1030 <print_debug_hex8@plt>
lea    0xe4d(%rip),%rdi
call   1050 <print_debug@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    0xe38(%rip),%rdi
call   1050 <print_debug@plt>
jmp    113f <show_dram_slots+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_dram_slots>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x50,%ebx
lea    0xeb9(%rip),%r14
lea    0xeb4(%rip),%r15
lea    0xeb3(%rip),%r12
lea    0xeb9(%rip),%r13
nopl   0x0(%rax)
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>
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <smbus_read_byte@plt>
mov    %eax,%ebp
test   %eax,%eax
mov    %r13,%rdi
cmovs  %r12,%rdi
call   1050 <print_debug@plt>
mov    %ebp,%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
jne    1160 <show_dram_slots+0x30>
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 = [13 x i8] c"bad device: \00"
@.str.3 = [10 x i8] c"present: \00"
define void @show_dram_slots() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 80, i32* %1
br label %4
4: ; preds = %20, %0
%5 = load i32, i32* %1
%6 = icmp ule i32 %5, 87
br i1 %6, label %7, label %27
7: ; preds = %4
store i32 0, i32* %2
%8 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @print_debug(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 @print_debug_hex8(i32 %10)
%12 = load i32, i32* %1
%13 = call i32 @smbus_read_byte(i32 %12, i32 0)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %7
%17 = call i32 @print_debug(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %20
18: ; preds = %7
%19 = call i32 @print_debug(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
%21 = load i32, i32* %2
%22 = call i32 @print_debug_hex8(i32 %21)
%23 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* %1
%25 = add i32 %24, 1
store i32 %25, i32* %1
%26 = call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %4
27: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [6 x i8] c"dimm \00"
@.str.2 = [13 x i8] c"bad device: \00"
@.str.3 = [10 x i8] c"present: \00"
define void @show_dram_slots() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 80, %0 ], [ %12, %1 ]
%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)
%6 = tail call i32 @smbus_read_byte(i32 %2, i32 0)
%7 = icmp slt i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
%9 = tail call i32 @print_debug(i8* %8)
%10 = tail call i32 @print_debug_hex8(i32 %6)
%11 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = add nuw nsw i32 %2, 1
%13 = tail call i32 @print_debug(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32 %12, 88
br i1 %14, label %15, label %1
15: ; preds = %1
ret void
}