#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_control0_reg(uint32_t *emmc) {
  uint32_t ctrl0 = (*(emmc + 0x28 / 4));
  printf("CONTROL0:--------------------------------------\n");
  printf("ALT_BOOT_EN:   %i\n", ((ctrl0 & (1 << 22)) != 0) ? 1 : 0);
  printf("BOOT_EN:       %i\n", ((ctrl0 & (1 << 21)) != 0) ? 1 : 0);
  printf("SPI_MODE:      %i\n", ((ctrl0 & (1 << 20)) != 0) ? 1 : 0);
  printf("GAP_IEN:       %i\n", ((ctrl0 & (1 << 19)) != 0) ? 1 : 0);
  printf("READWAIT_EN:   %i\n", ((ctrl0 & (1 << 18)) != 0) ? 1 : 0);
  printf("GAP_RESTART:   %i\n", ((ctrl0 & (1 << 17)) != 0) ? 1 : 0);
  printf("GAP_STOP:      %i\n", ((ctrl0 & (1 << 16)) != 0) ? 1 : 0);
  printf("HCTL_8BIT:     %i\n", ((ctrl0 & (1 << 5)) != 0) ? 1 : 0);
  printf("HCTL_HS_EN:    %i\n", ((ctrl0 & (1 << 2)) != 0) ? 1 : 0);
  printf("HCTL_DWIDTH:   %i\n", ((ctrl0 & (1 << 1)) != 0) ? 1 : 0);
}


x86 assembly (clang, -O0):
<print_control0_reg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x28(%rax),%eax
mov    %eax,-0xc(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x400000,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x200000,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x100000,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x80000,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x40000,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x20000,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x10000,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x20,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x4,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x2,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_control0_reg>:
push   %rbx
mov    0x28(%rdi),%ebx
lea    0xf93(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%esi
shr    $0x16,%esi
and    $0x1,%esi
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x15,%esi
and    $0x1,%esi
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x14,%esi
and    $0x1,%esi
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x13,%esi
and    $0x1,%esi
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x12,%esi
and    $0x1,%esi
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x11,%esi
and    $0x1,%esi
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x10,%esi
and    $0x1,%esi
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x5,%esi
and    $0x1,%esi
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x2,%esi
and    $0x1,%esi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
shr    %ebx
and    $0x1,%ebx
lea    0xea9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [49 x i8] c"CONTROL0:--------------------------------------\0A\00"
@.str.1 = [19 x i8] c"ALT_BOOT_EN: %i\0A\00"
@.str.2 = [19 x i8] c"BOOT_EN: %i\0A\00"
@.str.3 = [19 x i8] c"SPI_MODE: %i\0A\00"
@.str.4 = [19 x i8] c"GAP_IEN: %i\0A\00"
@.str.5 = [19 x i8] c"READWAIT_EN: %i\0A\00"
@.str.6 = [19 x i8] c"GAP_RESTART: %i\0A\00"
@.str.7 = [19 x i8] c"GAP_STOP: %i\0A\00"
@.str.8 = [19 x i8] c"HCTL_8BIT: %i\0A\00"
@.str.9 = [19 x i8] c"HCTL_HS_EN: %i\0A\00"
@.str.10 = [19 x i8] c"HCTL_DWIDTH: %i\0A\00"
define void @print_control0_reg(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = getelementptr inbounds i32, i32* %4, i64 10
%6 = load i32, i32* %5
store i32 %6, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %3
%9 = and i32 %8, 4194304
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i64
%12 = select i1 %10, i32 1, i32 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %3
%15 = and i32 %14, 2097152
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 1, i32 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %3
%21 = and i32 %20, 1048576
%22 = icmp ne i32 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i32 1, i32 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %3
%27 = and i32 %26, 524288
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i64
%30 = select i1 %28, i32 1, i32 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %3
%33 = and i32 %32, 262144
%34 = icmp ne i32 %33, 0
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 1, i32 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %3
%39 = and i32 %38, 131072
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i32 1, i32 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %3
%45 = and i32 %44, 65536
%46 = icmp ne i32 %45, 0
%47 = zext i1 %46 to i64
%48 = select i1 %46, i32 1, i32 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %3
%51 = and i32 %50, 32
%52 = icmp ne i32 %51, 0
%53 = zext i1 %52 to i64
%54 = select i1 %52, i32 1, i32 0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %3
%57 = and i32 %56, 4
%58 = icmp ne i32 %57, 0
%59 = zext i1 %58 to i64
%60 = select i1 %58, i32 1, i32 0
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %3
%63 = and i32 %62, 2
%64 = icmp ne i32 %63, 0
%65 = zext i1 %64 to i64
%66 = select i1 %64, i32 1, i32 0
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i32 %66)
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"ALT_BOOT_EN: %i\0A\00"
@.str.2 = [19 x i8] c"BOOT_EN: %i\0A\00"
@.str.3 = [19 x i8] c"SPI_MODE: %i\0A\00"
@.str.4 = [19 x i8] c"GAP_IEN: %i\0A\00"
@.str.5 = [19 x i8] c"READWAIT_EN: %i\0A\00"
@.str.6 = [19 x i8] c"GAP_RESTART: %i\0A\00"
@.str.7 = [19 x i8] c"GAP_STOP: %i\0A\00"
@.str.8 = [19 x i8] c"HCTL_8BIT: %i\0A\00"
@.str.9 = [19 x i8] c"HCTL_HS_EN: %i\0A\00"
@.str.10 = [19 x i8] c"HCTL_DWIDTH: %i\0A\00"
@str = [48 x i8] c"CONTROL0:--------------------------------------\00"
define void @print_control0_reg(i32* nocapture %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 10
%3 = load i32, i32* %2
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%5 = lshr i32 %3, 22
%6 = and i32 %5, 1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = lshr i32 %3, 21
%9 = and i32 %8, 1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = lshr i32 %3, 20
%12 = and i32 %11, 1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = lshr i32 %3, 19
%15 = and i32 %14, 1
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = lshr i32 %3, 18
%18 = and i32 %17, 1
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %18)
%20 = lshr i32 %3, 17
%21 = and i32 %20, 1
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %21)
%23 = lshr i32 %3, 16
%24 = and i32 %23, 1
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %24)
%26 = lshr i32 %3, 5
%27 = and i32 %26, 1
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %27)
%29 = lshr i32 %3, 2
%30 = and i32 %29, 1
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %30)
%32 = lshr i32 %3, 1
%33 = and i32 %32, 1
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i32 %33)
ret void
}