#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 */
scalar_t__ isprint(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void print_sector(char *message, unsigned char *data, int size) {
  int col;
  int row;
  printf("%s:\n", message);
  for (row = 0; row * 16 < size; row++) {
    printf("%03x  ", row * 16);
    for (col = 0; col < 16; col++)
      printf("%02x ", data[row * 16 + col]);
    for (col = 0; col < 16; col++) {
      if (isprint(data[row * 16 + col]))
        printf("%c", data[row * 16 + col]);
      else
        printf(".");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_sector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
cmp    -0x14(%rbp),%eax
jge    1248 <print_sector+0x128>
mov    -0x1c(%rbp),%esi
shl    $0x4,%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x10,-0x18(%rbp)
jge    11b0 <print_sector+0x90>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1176 <print_sector+0x56>
movl   $0x0,-0x18(%rbp)
cmpl   $0x10,-0x18(%rbp)
jge    122c <print_sector+0x10c>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%rax
je     120b <print_sector+0xeb>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x4,%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1219 <print_sector+0xf9>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121e <print_sector+0xfe>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11b7 <print_sector+0x97>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114c <print_sector+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_sector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%rsi
lea    0xeb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,0x4(%rsp)
test   %ebx,%ebx
jle    132e <print_sector+0x1fe>
lea    0xea8(%rip),%r12
xor    %r13d,%r13d
jmp    1189 <print_sector+0x59>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%r13d
cmp    0x4(%rsp),%r13d
jge    132e <print_sector+0x1fe>
mov    %r13d,%r14d
lea    (%r15,%r14,1),%rbp
lea    0xe6e(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%r15,%r14,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0x1,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0x2,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0x3,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0x4,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0x5,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0x6,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0x7,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0x8,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0x9,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0xa,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0xb,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0xc,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0xd,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     $0xe,%rax
movzbl (%r15,%rax,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
or     $0xf,%r14
movzbl (%r15,%r14,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebx,%ebx
jmp    1318 <print_sector+0x1e8>
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%rbp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x10,%rbx
je     1170 <print_sector+0x40>
movzbl 0x0(%rbp,%rbx,1),%edi
call   1050 <isprint@plt>
test   %rax,%rax
jne    1300 <print_sector+0x1d0>
mov    $0x2e,%edi
jmp    1305 <print_sector+0x1d5>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%s:\0A\00"
@.str.1 = [7 x i8] c"%03x \00"
@.str.2 = [6 x i8] c"%02x \00"
define void @print_sector(i8* %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %111
6: ; preds = %3, %105
%7 = phi i64 [ %107, %105 ], [ 0, %3 ]
%8 = phi i32 [ %109, %105 ], [ 0, %3 ]
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = zext i32 %8 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = or i64 %10, 1
%16 = getelementptr inbounds i8, i8* %1, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = or i64 %10, 2
%21 = getelementptr inbounds i8, i8* %1, i64 %20
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = or i64 %10, 3
%26 = getelementptr inbounds i8, i8* %1, i64 %25
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = or i64 %10, 4
%31 = getelementptr inbounds i8, i8* %1, i64 %30
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = or i64 %10, 5
%36 = getelementptr inbounds i8, i8* %1, i64 %35
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = or i64 %10, 6
%41 = getelementptr inbounds i8, i8* %1, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = or i64 %10, 7
%46 = getelementptr inbounds i8, i8* %1, i64 %45
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %48)
%50 = or i64 %10, 8
%51 = getelementptr inbounds i8, i8* %1, i64 %50
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %53)
%55 = or i64 %10, 9
%56 = getelementptr inbounds i8, i8* %1, i64 %55
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %58)
%60 = or i64 %10, 10
%61 = getelementptr inbounds i8, i8* %1, i64 %60
%62 = load i8, i8* %61
%63 = zext i8 %62 to i32
%64 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = or i64 %10, 11
%66 = getelementptr inbounds i8, i8* %1, i64 %65
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %68)
%70 = or i64 %10, 12
%71 = getelementptr inbounds i8, i8* %1, i64 %70
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %73)
%75 = or i64 %10, 13
%76 = getelementptr inbounds i8, i8* %1, i64 %75
%77 = load i8, i8* %76
%78 = zext i8 %77 to i32
%79 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %78)
%80 = or i64 %10, 14
%81 = getelementptr inbounds i8, i8* %1, i64 %80
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %83)
%85 = or i64 %10, 15
%86 = getelementptr inbounds i8, i8* %1, i64 %85
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %88)
br label %90
90: ; preds = %6, %100
%91 = phi i64 [ 0, %6 ], [ %103, %100 ]
%92 = add nuw nsw i64 %91, %10
%93 = getelementptr inbounds i8, i8* %1, i64 %92
%94 = load i8, i8* %93
%95 = tail call i64 @isprint(i8 zeroext %94)
%96 = icmp eq i64 %95, 0
br i1 %96, label %100, label %97
97: ; preds = %90
%98 = load i8, i8* %93
%99 = zext i8 %98 to i32
br label %100
100: ; preds = %90, %97
%101 = phi i32 [ %99, %97 ], [ 46, %90 ]
%102 = tail call i32 @putchar(i32 %101)
%103 = add nuw nsw i64 %91, 1
%104 = icmp eq i64 %103, 16
br i1 %104, label %105, label %90
105: ; preds = %100
%106 = tail call i32 @putchar(i32 10)
%107 = add nuw i64 %7, 1
%108 = trunc i64 %107 to i32
%109 = shl nsw i32 %108, 4
%110 = icmp slt i32 %109, %2
br i1 %110, label %6, label %111
111: ; preds = %105, %3
ret void
}