#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*/ printf(char *, ...);
void emmc_dump_block(unsigned char *buf) {
  int i;
  for (i = 0; i < 512; i++) {
    if (!(i % 32))
      printf("\n");
    printf("%x", buf[i] >> 4);
    printf("%x", buf[i] & 0xF);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<emmc_dump_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x200,-0xc(%rbp)
jge    119a <emmc_dump_block+0x8a>
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1152 <emmc_dump_block+0x42>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
sar    $0x4,%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
and    $0xf,%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <emmc_dump_block+0x13>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emmc_dump_block>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0xed1(%rip),%r14
xor    %ebx,%ebx
jmp    1171 <emmc_dump_block+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%r15,%rbx,1),%esi
shr    $0x4,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%r15,%rbx,1),%esi
and    $0xf,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x200,%rbx
je     1182 <emmc_dump_block+0x62>
test   $0x1f,%bl
jne    1140 <emmc_dump_block+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1140 <emmc_dump_block+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c"%x\00"
define void @emmc_dump_block(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %30, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 512
br i1 %6, label %7, label %33
7: ; preds = %4
%8 = load i32, i32* %3
%9 = srem i32 %8, 32
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = ashr i32 %19, 4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = and i32 %27, 15
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %13
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %4
33: ; preds = %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%x\00"
define void @emmc_dump_block(i8* nocapture %0) {
br label %2
2: ; preds = %1, %8
%3 = phi i64 [ 0, %1 ], [ %18, %8 ]
%4 = and i64 %3, 31
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @putchar(i32 10)
br label %8
8: ; preds = %6, %2
%9 = getelementptr inbounds i8, i8* %0, i64 %3
%10 = load i8, i8* %9
%11 = lshr i8 %10, 4
%12 = zext i8 %11 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i8, i8* %9
%15 = and i8 %14, 15
%16 = zext i8 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i64 %3, 1
%19 = icmp eq i64 %18, 512
br i1 %19, label %20, label %2
20: ; preds = %8
%21 = tail call i32 @putchar(i32 10)
ret void
}