#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 dram_register_range_print(int, int, char *, char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int sunxi_dram_clock_read(unsigned int *);
int sun8i_dram_regs_print(void) {
  unsigned int clock;
  int ret;
  ret = sunxi_dram_clock_read(&clock);
  if (ret)
    return ret;
  printf("DRAM Clock: %dMHz\n", clock);
  ret = dram_register_range_print(0x01C62000, 0x0300, "DRAM COM", "SDR_COM");
  if (ret)
    return ret;
  ret = dram_register_range_print(0x01C63000, 0x0400, "DRAM CTL", "SDR_CTL");
  if (ret)
    return ret;
  ret = dram_register_range_print(0x01C65000, 0x0400, "DRAM PHY", "SDR_PHY");
  if (ret)
    return ret;
  return 0;
}


x86 assembly (clang, -O0):
<sun8i_dram_regs_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
call   1030 <sunxi_dram_clock_read@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1159 <sun8i_dram_regs_print+0x29>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120e <sun8i_dram_regs_print+0xde>
mov    -0x8(%rbp),%esi
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1c62000,%edi
mov    $0x300,%esi
lea    0xe9a(%rip),%rdx
lea    0xe9c(%rip),%rcx
call   1050 <dram_register_range_print@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     119d <sun8i_dram_regs_print+0x6d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120e <sun8i_dram_regs_print+0xde>
mov    $0x1c63000,%edi
mov    $0x400,%esi
lea    0xe76(%rip),%rdx
lea    0xe78(%rip),%rcx
call   1050 <dram_register_range_print@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11d2 <sun8i_dram_regs_print+0xa2>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120e <sun8i_dram_regs_print+0xde>
mov    $0x1c65000,%edi
mov    $0x400,%esi
lea    0xe52(%rip),%rdx
lea    0xe54(%rip),%rcx
call   1050 <dram_register_range_print@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1207 <sun8i_dram_regs_print+0xd7>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120e <sun8i_dram_regs_print+0xde>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sun8i_dram_regs_print>:
push   %rax
lea    0x4(%rsp),%rdi
call   1030 <sunxi_dram_clock_read@plt>
test   %eax,%eax
je     1141 <sun8i_dram_regs_print+0x11>
pop    %rcx
ret
mov    0x4(%rsp),%esi
lea    0xeb4(%rip),%rdi
call   1040 <printf@plt>
lea    0xebb(%rip),%rdx
lea    0xebd(%rip),%rcx
mov    $0x1c62000,%edi
mov    $0x300,%esi
call   1050 <dram_register_range_print@plt>
test   %eax,%eax
jne    113f <sun8i_dram_regs_print+0xf>
lea    0xeab(%rip),%rdx
lea    0xead(%rip),%rcx
mov    $0x1c63000,%edi
mov    $0x400,%esi
call   1050 <dram_register_range_print@plt>
test   %eax,%eax
jne    113f <sun8i_dram_regs_print+0xf>
lea    0xe9b(%rip),%rdx
lea    0xe9d(%rip),%rcx
mov    $0x1c65000,%edi
mov    $0x400,%esi
call   1050 <dram_register_range_print@plt>
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"DRAM Clock: %dMHz\0A\00"
@.str.1 = [9 x i8] c"DRAM COM\00"
@.str.2 = [8 x i8] c"SDR_COM\00"
@.str.3 = [9 x i8] c"DRAM CTL\00"
@.str.4 = [8 x i8] c"SDR_CTL\00"
@.str.5 = [9 x i8] c"DRAM PHY\00"
@.str.6 = [8 x i8] c"SDR_PHY\00"
define i32 @sun8i_dram_regs_print() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @sunxi_dram_clock_read(i32* %2)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = load i32, i32* %3
store i32 %8, i32* %1
br label %30
9: ; preds = %0
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @dram_register_range_print(i32 29761536, i32 768, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = load i32, i32* %3
store i32 %16, i32* %1
br label %30
17: ; preds = %9
%18 = call i32 @dram_register_range_print(i32 29765632, i32 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32, i32* %3
store i32 %22, i32* %1
br label %30
23: ; preds = %17
%24 = call i32 @dram_register_range_print(i32 29773824, i32 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load i32, i32* %3
store i32 %28, i32* %1
br label %30
29: ; preds = %23
store i32 0, i32* %1
br label %30
30: ; preds = %29, %27, %21, %15, %7
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [19 x i8] c"DRAM Clock: %dMHz\0A\00"
@.str.1 = [9 x i8] c"DRAM COM\00"
@.str.2 = [8 x i8] c"SDR_COM\00"
@.str.3 = [9 x i8] c"DRAM CTL\00"
@.str.4 = [8 x i8] c"SDR_CTL\00"
@.str.5 = [9 x i8] c"DRAM PHY\00"
@.str.6 = [8 x i8] c"SDR_PHY\00"
define i32 @sun8i_dram_regs_print() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @sunxi_dram_clock_read(i32* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %0
%6 = load i32, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @dram_register_range_print(i32 29761536, i32 768, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = call i32 @dram_register_range_print(i32 29765632, i32 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @dram_register_range_print(i32 29773824, i32 1024, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %15
15: ; preds = %13, %10, %5, %0
%16 = phi i32 [ %3, %0 ], [ %8, %5 ], [ %11, %10 ], [ %14, %13 ]
ret i32 %16
}