#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_control2_reg(uint32_t *emmc) {
  uint32_t ctrl2 = (*(emmc + 0x2C / 4));
  printf("CONTROL2:--------------------------------------\n");
  printf("TUNED:         %i\n", ((ctrl2 & (1 << 23)) != 0) ? 1 : 0);
  printf("TUNEON:        %i\n", ((ctrl2 & (1 << 22)) != 0) ? 1 : 0);
  printf("UHSMODE:       %i%i%i\n", ((ctrl2 & (1 << 18)) != 0) ? 1 : 0,
         ((ctrl2 & (1 << 17)) != 0) ? 1 : 0,
         ((ctrl2 & (1 << 16)) != 0) ? 1 : 0);
  printf("NOTC12_ERR :   %i\n", ((ctrl2 & (1 << 7)) != 0) ? 1 : 0);
  printf("ACBAD_ERR:     %i\n", ((ctrl2 & (1 << 4)) != 0) ? 1 : 0);
  printf("ACEND_ERR:     %i\n", ((ctrl2 & (1 << 3)) != 0) ? 1 : 0);
  printf("ACCRC_ERR      %i\n", ((ctrl2 & (1 << 2)) != 0) ? 1 : 0);
  printf("ACTO_ERR:      %i\n", ((ctrl2 & (1 << 1)) != 0) ? 1 : 0);
  printf("ACNOX_ERR:     %i\n", ((ctrl2 & (1 << 0)) != 0) ? 1 : 0);
}


x86 assembly (clang, -O0):
<print_control2_reg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2c(%rax),%eax
mov    %eax,-0xc(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x800000,%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    $0x400000,%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    $0x40000,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
mov    -0xc(%rbp),%ecx
and    $0x20000,%ecx
xor    %edx,%edx
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0xc(%rbp),%edi
and    $0x10000,%edi
xor    %ecx,%ecx
mov    $0x1,%eax
cmp    $0x0,%edi
cmovne %eax,%ecx
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x80,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x10,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x8,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe69(%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    0xe5b(%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    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
and    $0x1,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_control2_reg>:
push   %rbx
mov    0x2c(%rdi),%ebx
lea    0xf84(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%esi
shr    $0x17,%esi
and    $0x1,%esi
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x16,%esi
and    $0x1,%esi
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x12,%esi
and    $0x1,%esi
mov    %ebx,%edx
shr    $0x11,%edx
and    $0x1,%edx
mov    %ebx,%ecx
shr    $0x10,%ecx
and    $0x1,%ecx
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x7,%esi
and    $0x1,%esi
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x4,%esi
and    $0x1,%esi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x3,%esi
and    $0x1,%esi
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x2,%esi
and    $0x1,%esi
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    %esi
and    $0x1,%esi
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
and    $0x1,%ebx
lea    0xea3(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [49 x i8] c"CONTROL2:--------------------------------------\0A\00"
@.str.1 = [19 x i8] c"TUNED: %i\0A\00"
@.str.2 = [19 x i8] c"TUNEON: %i\0A\00"
@.str.3 = [23 x i8] c"UHSMODE: %i%i%i\0A\00"
@.str.4 = [19 x i8] c"NOTC12_ERR : %i\0A\00"
@.str.5 = [19 x i8] c"ACBAD_ERR: %i\0A\00"
@.str.6 = [19 x i8] c"ACEND_ERR: %i\0A\00"
@.str.7 = [19 x i8] c"ACCRC_ERR %i\0A\00"
@.str.8 = [19 x i8] c"ACTO_ERR: %i\0A\00"
@.str.9 = [19 x i8] c"ACNOX_ERR: %i\0A\00"
define void @print_control2_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 11
%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, 8388608
%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, 4194304
%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, 262144
%22 = icmp ne i32 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i32 1, i32 0
%25 = load i32, i32* %3
%26 = and i32 %25, 131072
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i64
%29 = select i1 %27, i32 1, i32 0
%30 = load i32, i32* %3
%31 = and i32 %30, 65536
%32 = icmp ne i32 %31, 0
%33 = zext i1 %32 to i64
%34 = select i1 %32, i32 1, i32 0
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %29, i32 %34)
%36 = load i32, i32* %3
%37 = and i32 %36, 128
%38 = icmp ne i32 %37, 0
%39 = zext i1 %38 to i64
%40 = select i1 %38, i32 1, i32 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %3
%43 = and i32 %42, 16
%44 = icmp ne i32 %43, 0
%45 = zext i1 %44 to i64
%46 = select i1 %44, i32 1, i32 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %3
%49 = and i32 %48, 8
%50 = icmp ne i32 %49, 0
%51 = zext i1 %50 to i64
%52 = select i1 %50, i32 1, i32 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %3
%55 = and i32 %54, 4
%56 = icmp ne i32 %55, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, i32 1, i32 0
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %3
%61 = and i32 %60, 2
%62 = icmp ne i32 %61, 0
%63 = zext i1 %62 to i64
%64 = select i1 %62, i32 1, i32 0
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %64)
%66 = load i32, i32* %3
%67 = and i32 %66, 1
%68 = icmp ne i32 %67, 0
%69 = zext i1 %68 to i64
%70 = select i1 %68, i32 1, i32 0
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %70)
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"TUNED: %i\0A\00"
@.str.2 = [19 x i8] c"TUNEON: %i\0A\00"
@.str.3 = [23 x i8] c"UHSMODE: %i%i%i\0A\00"
@.str.4 = [19 x i8] c"NOTC12_ERR : %i\0A\00"
@.str.5 = [19 x i8] c"ACBAD_ERR: %i\0A\00"
@.str.6 = [19 x i8] c"ACEND_ERR: %i\0A\00"
@.str.7 = [19 x i8] c"ACCRC_ERR %i\0A\00"
@.str.8 = [19 x i8] c"ACTO_ERR: %i\0A\00"
@.str.9 = [19 x i8] c"ACNOX_ERR: %i\0A\00"
@str = [48 x i8] c"CONTROL2:--------------------------------------\00"
define void @print_control2_reg(i32* nocapture %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 11
%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, 23
%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, 22
%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, 18
%12 = and i32 %11, 1
%13 = lshr i32 %3, 17
%14 = and i32 %13, 1
%15 = lshr i32 %3, 16
%16 = and i32 %15, 1
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 %14, i32 %16)
%18 = lshr i32 %3, 7
%19 = and i32 %18, 1
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = lshr i32 %3, 4
%22 = and i32 %21, 1
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = lshr i32 %3, 3
%25 = and i32 %24, 1
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %25)
%27 = lshr i32 %3, 2
%28 = and i32 %27, 1
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %28)
%30 = lshr i32 %3, 1
%31 = and i32 %30, 1
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %31)
%33 = and i32 %3, 1
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i32 %33)
ret void
}