#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 fat_dumpSectorHex(unsigned char *buf, int bufSize) {
  int i;
  char c;
  char line[17];
  line[16] = 0;
  for (i = 0; i < bufSize; i++) {
    c = buf[i];
    if (c < 32) {
      c = 32;
    }
    line[i % 16] = c;
    if (i % 16 == 0) {
      printf("%08X   ", i);
    }
    printf("%02X ", buf[i]);
    if (i % 16 == 15) {
      printf("  %s\n", line);
    }
  }
  if (i % 16 != 0) {
    line[i % 16] = 0;
    printf("  %s\n", line);
  }
}


x86 assembly (clang, -O0):
<fat_dumpSectorHex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movb   $0x0,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e2 <fat_dumpSectorHex+0xd2>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jge    1155 <fat_dumpSectorHex+0x45>
movb   $0x20,-0x11(%rbp)
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%eax
mov    $0x10,%esi
cltd
idiv   %esi
movslq %edx,%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118f <fat_dumpSectorHex+0x7f>
mov    -0x10(%rbp),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0xf,%edx
jne    11cf <fat_dumpSectorHex+0xbf>
lea    -0x30(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <fat_dumpSectorHex+0xc4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <fat_dumpSectorHex+0x1a>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     121b <fat_dumpSectorHex+0x10b>
mov    -0x10(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fat_dumpSectorHex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movb   $0x0,0x10(%rsp)
test   %esi,%esi
jle    11d6 <fat_dumpSectorHex+0xc6>
mov    %rdi,%rbx
mov    %rsi,0x20(%rsp)
mov    %esi,%r13d
lea    0xec3(%rip),%r15
lea    0xec4(%rip),%r12
xor    %ebp,%ebp
jmp    1173 <fat_dumpSectorHex+0x63>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movzbl (%rbx,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     11b6 <fat_dumpSectorHex+0xa6>
movzbl (%rbx,%rbp,1),%esi
cmp    $0x21,%sil
mov    $0x20,%eax
cmovge %esi,%eax
mov    %ebp,%r14d
and    $0xf,%r14d
mov    %al,(%rsp,%r14,1)
test   %r14,%r14
je     1150 <fat_dumpSectorHex+0x40>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0xf,%r14d
jne    116a <fat_dumpSectorHex+0x5a>
lea    0xe64(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    116a <fat_dumpSectorHex+0x5a>
mov    0x20(%rsp),%rax
and    $0xf,%rax
je     11d6 <fat_dumpSectorHex+0xc6>
movb   $0x0,(%rsp,%rax,1)
lea    0xe42(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%08X \00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [6 x i8] c" %s\0A\00"
define void @fat_dumpSectorHex(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca [17 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 16
store i8 0, i8* %8
store i32 0, i32* %5
br label %9
9: ; preds = %50, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %53
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
store i8 %18, i8* %6
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = icmp slt i32 %20, 32
br i1 %21, label %22, label %23
22: ; preds = %13
store i8 32, i8* %6
br label %23
23: ; preds = %22, %13
%24 = load i8, i8* %6
%25 = load i32, i32* %5
%26 = srem i32 %25, 16
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 %27
store i8 %24, i8* %28
%29 = load i32, i32* %5
%30 = srem i32 %29, 16
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %23
%33 = load i32, i32* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32, %23
%36 = load i8*, i8** %3
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %5
%44 = srem i32 %43, 16
%45 = icmp eq i32 %44, 15
br i1 %45, label %46, label %49
46: ; preds = %35
%47 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %46, %35
br label %50
50: ; preds = %49
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %9
53: ; preds = %9
%54 = load i32, i32* %5
%55 = srem i32 %54, 16
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %64
57: ; preds = %53
%58 = load i32, i32* %5
%59 = srem i32 %58, 16
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 %60
store i8 0, i8* %61
%62 = getelementptr inbounds [17 x i8], [17 x i8]* %7, i64 0, i64 0
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %62)
br label %64
64: ; preds = %57, %53
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%08X \00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [6 x i8] c" %s\0A\00"
define void @fat_dumpSectorHex(i8* nocapture %0, i32 %1) {
%3 = alloca [17 x i8]
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 16
store i8 0, i8* %5
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %41
7: ; preds = %2
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %31
%10 = phi i64 [ 0, %7 ], [ %32, %31 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp sgt i8 %12, 32
%14 = select i1 %13, i8 %12, i8 32
%15 = trunc i64 %10 to i32
%16 = and i32 %15, 15
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %17
store i8 %14, i8* %18
%19 = icmp eq i32 %16, 0
br i1 %19, label %20, label %25
20: ; preds = %9
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15)
%22 = load i8, i8* %11
%23 = zext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %31
25: ; preds = %9
%26 = zext i8 %12 to i32
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = icmp eq i32 %16, 15
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %31
31: ; preds = %20, %25, %29
%32 = add nuw nsw i64 %10, 1
%33 = icmp eq i64 %32, %8
br i1 %33, label %34, label %9
34: ; preds = %31
%35 = and i32 %1, 15
%36 = icmp eq i32 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %34
%38 = zext i32 %35 to i64
%39 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 %38
store i8 0, i8* %39
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %41
41: ; preds = %2, %37, %34
ret void
}