#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 /*<<< orphan*/ FILE;

/* Variables and functions */
long fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ isprint(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void hex_dump_fp(FILE *in_fp, FILE *out_fp, int do_raw) {
  unsigned char buf[(4 * 4)];
  long num_bytes_read;
  long num_bytes_total = 0;
  int byteno;
  while ((num_bytes_read = fread(buf, sizeof(unsigned char), (4 * 4), in_fp)) >
         0) {
    if (!do_raw) {
      printf("%08lx: ", num_bytes_total);
    }
    for (byteno = 0; byteno < num_bytes_read; byteno++) {
      unsigned int temp = buf[byteno];
      printf("%02x ", temp);
      if ((byteno % 4) == (4 - 1)) {
        if ((byteno > 0) && (byteno < (4 * 4) - 1))
          printf(" ");
      }
    }
    for (byteno = num_bytes_read; byteno < (4 * 4); byteno++) {
      printf("   ");
      if ((byteno % 4) == (4 - 1)) {
        if ((byteno > 0) && (byteno < (4 * 4) - 1))
          printf(" ");
      }
    }
    if (!do_raw) {
      printf("|");
      for (byteno = 0; byteno < num_bytes_read; byteno++) {
        unsigned char temp = buf[byteno];
        if (!isprint(temp))
          temp = '.';
        printf("%c", temp);
      }
      printf("|");
    }
    printf("\n");
    num_bytes_total += num_bytes_read;
  }
}


x86 assembly (clang, -O0):
<hex_dump_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1030 <fread@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jle    1314 <hex_dump_fp+0x1e4>
cmpl   $0x0,-0x14(%rbp)
jne    118c <hex_dump_fp+0x5c>
mov    -0x40(%rbp),%rsi
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x44(%rbp)
movslq -0x44(%rbp),%rax
cmp    -0x38(%rbp),%rax
jge    120c <hex_dump_fp+0xdc>
movslq -0x44(%rbp),%rax
movzbl -0x30(%rbp,%rax,1),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
jne    11f9 <hex_dump_fp+0xc9>
cmpl   $0x0,-0x44(%rbp)
jle    11f4 <hex_dump_fp+0xc4>
cmpl   $0xf,-0x44(%rbp)
jge    11f4 <hex_dump_fp+0xc4>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f9 <hex_dump_fp+0xc9>
jmp    11fe <hex_dump_fp+0xce>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1193 <hex_dump_fp+0x63>
mov    -0x38(%rbp),%rax
mov    %eax,-0x44(%rbp)
cmpl   $0x10,-0x44(%rbp)
jge    1279 <hex_dump_fp+0x149>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
jne    1266 <hex_dump_fp+0x136>
cmpl   $0x0,-0x44(%rbp)
jle    1261 <hex_dump_fp+0x131>
cmpl   $0xf,-0x44(%rbp)
jge    1261 <hex_dump_fp+0x131>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1266 <hex_dump_fp+0x136>
jmp    126b <hex_dump_fp+0x13b>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1213 <hex_dump_fp+0xe3>
cmpl   $0x0,-0x14(%rbp)
jne    12f5 <hex_dump_fp+0x1c5>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x44(%rbp)
movslq -0x44(%rbp),%rax
cmp    -0x38(%rbp),%rax
jge    12e7 <hex_dump_fp+0x1b7>
movslq -0x44(%rbp),%rax
mov    -0x30(%rbp,%rax,1),%al
mov    %al,-0x49(%rbp)
movzbl -0x49(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%eax
jne    12c7 <hex_dump_fp+0x197>
movb   $0x2e,-0x49(%rbp)
movzbl -0x49(%rbp),%esi
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1298 <hex_dump_fp+0x168>
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    114b <hex_dump_fp+0x1b>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_dump_fp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,%r14d
mov    %rdi,%rcx
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %rcx,0x28(%rsp)
call   1040 <fread@plt>
test   %rax,%rax
jle    12e9 <hex_dump_fp+0x1a9>
mov    %rax,%r15
lea    0xe88(%rip),%r12
lea    0xe87(%rip),%r13
xor    %ebx,%ebx
mov    %r14d,0xc(%rsp)
jmp    11d0 <hex_dump_fp+0x90>
test   %r14d,%r14d
je     1290 <hex_dump_fp+0x150>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x30(%rsp),%rbx
add    %r15,%rbx
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    0x28(%rsp),%rcx
call   1040 <fread@plt>
mov    %rax,%r15
test   %rax,%rax
jle    12e9 <hex_dump_fp+0x1a9>
test   %r14d,%r14d
jne    11e6 <hex_dump_fp+0xa6>
lea    0xe24(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %ebp,%ebp
jmp    11f9 <hex_dump_fp+0xb9>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r15
je     1230 <hex_dump_fp+0xf0>
movzbl 0x10(%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%eax
not    %eax
test   $0x3,%al
jne    11f0 <hex_dump_fp+0xb0>
lea    -0x1(%rbp),%eax
cmp    $0xd,%eax
ja     11f0 <hex_dump_fp+0xb0>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11f0 <hex_dump_fp+0xb0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,0x30(%rsp)
cmp    $0xf,%r15d
jg     1190 <hex_dump_fp+0x50>
mov    %r15d,%ebx
jmp    125c <hex_dump_fp+0x11c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebx
cmp    $0x10,%ebx
je     1190 <hex_dump_fp+0x50>
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x3(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
cmp    $0xf,%ebx
je     1250 <hex_dump_fp+0x110>
and    $0xfffffffc,%eax
mov    %ebx,%ecx
sub    %eax,%ecx
cmp    $0x3,%ecx
jne    1250 <hex_dump_fp+0x110>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1250 <hex_dump_fp+0x110>
nopl   0x0(%rax,%rax,1)
mov    $0x7c,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
mov    $0x2e,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x10(%rsp,%rbx,1),%r14d
mov    %r14d,%edi
call   1060 <isprint@plt>
test   %eax,%eax
cmove  %ebp,%r14d
mov    %r14d,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    12b0 <hex_dump_fp+0x170>
mov    $0x7c,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%r14d
jmp    1199 <hex_dump_fp+0x59>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"%08lx: \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.3 = [4 x i8] c" \00"
define void @hex_dump_fp(i32* nocapture %0, i32* nocapture readnone %1, i32 %2) {
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = call i64 @fread(i8* %5, i32 1, i32 16, i32* %0)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %69
8: ; preds = %3
%9 = icmp eq i32 %2, 0
br label %10
10: ; preds = %8, %64
%11 = phi i64 [ %6, %8 ], [ %67, %64 ]
%12 = phi i64 [ 0, %8 ], [ %66, %64 ]
br i1 %9, label %13, label %15
13: ; preds = %10
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 %12)
br label %15
15: ; preds = %10, %13
br label %16
16: ; preds = %15, %30
%17 = phi i64 [ %31, %30 ], [ 0, %15 ]
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = and i64 %17, 3
%23 = icmp eq i64 %22, 3
%24 = trunc i64 %17 to i32
%25 = add i32 %24, -1
%26 = icmp ult i32 %25, 14
%27 = select i1 %23, i1 %26, i1 false
br i1 %27, label %28, label %30
28: ; preds = %16
%29 = tail call i32 @putchar(i32 32)
br label %30
30: ; preds = %28, %16
%31 = add nuw nsw i64 %17, 1
%32 = icmp eq i64 %31, %11
br i1 %32, label %33, label %16
33: ; preds = %30
%34 = trunc i64 %11 to i32
%35 = icmp slt i32 %34, 16
br i1 %35, label %36, label %48
36: ; preds = %33, %45
%37 = phi i32 [ %46, %45 ], [ %34, %33 ]
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%39 = srem i32 %37, 4
%40 = icmp eq i32 %39, 3
%41 = icmp ne i32 %37, 15
%42 = and i1 %41, %40
br i1 %42, label %43, label %45
43: ; preds = %36
%44 = tail call i32 @putchar(i32 32)
br label %45
45: ; preds = %36, %43
%46 = add i32 %37, 1
%47 = icmp eq i32 %46, 16
br i1 %47, label %48, label %36
48: ; preds = %45, %33
br i1 %9, label %49, label %64
49: ; preds = %48
%50 = tail call i32 @putchar(i32 124)
br label %51
51: ; preds = %49, %51
%52 = phi i64 [ 0, %49 ], [ %60, %51 ]
%53 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = tail call i32 @isprint(i8 zeroext %54)
%56 = icmp eq i32 %55, 0
%57 = zext i8 %54 to i32
%58 = select i1 %56, i32 46, i32 %57
%59 = tail call i32 @putchar(i32 %58)
%60 = add nuw nsw i64 %52, 1
%61 = icmp eq i64 %60, %11
br i1 %61, label %62, label %51
62: ; preds = %51
%63 = tail call i32 @putchar(i32 124)
br label %64
64: ; preds = %62, %48
%65 = tail call i32 @putchar(i32 10)
%66 = add nsw i64 %11, %12
%67 = call i64 @fread(i8* %5, i32 1, i32 16, i32* %0)
%68 = icmp sgt i64 %67, 0
br i1 %68, label %10, label %69
69: ; preds = %64, %3
ret void
}