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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isprint(int const);
int /*<<< orphan*/ printf(char *, ...);
extern void print_hex_ascii_line(const u_char *payload, int len, int offset,
                                 FILE *fdata) {
  int i = 0;
  int gap = 0;
  const u_char *ch;
  printf("%05d   ", offset);
  fprintf(fdata, "%05d   ", offset);
  ch = payload;
  for (i = 0; i < len; i++) {
    printf("%02x ", *ch);
    ch++;
    if (i == 7)
      printf(" ");
  }
  if (len < 8)
    printf(" ");
  fprintf(fdata, " ");
  if (len < 16) {
    gap = 16 - len;
    for (i = 0; i < gap; i++) {
      printf("   ");
      fprintf(fdata, " ");
    }
  }
  printf("   ");
  ch = payload;
  for (i = 0; i < len; i++) {
    if (isprint(*ch)) {
      printf("%c", *ch);
      fprintf(fdata, "%c", *ch);
    } else {
      printf(".");
      fprintf(fdata, ".");
    }
    ch++;
  }
  printf("\n");
  fprintf(fdata, "\n");
  return;
}


x86 assembly (clang, -O0):
<print_hex_ascii_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11e0 <print_hex_ascii_line+0xb0>
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x7,-0x1c(%rbp)
jne    11cd <print_hex_ascii_line+0x9d>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <print_hex_ascii_line+0xa2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1189 <print_hex_ascii_line+0x59>
cmpl   $0x8,-0xc(%rbp)
jge    11f8 <print_hex_ascii_line+0xc8>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe03(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x10,-0xc(%rbp)
jge    1265 <print_hex_ascii_line+0x135>
mov    $0x10,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1260 <print_hex_ascii_line+0x130>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xdbb(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1226 <print_hex_ascii_line+0xf6>
jmp    1265 <print_hex_ascii_line+0x135>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    130e <print_hex_ascii_line+0x1de>
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     12d4 <print_hex_ascii_line+0x1a4>
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
lea    0xd46(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    12f4 <print_hex_ascii_line+0x1c4>
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xd24(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1282 <print_hex_ascii_line+0x152>
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xcec(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_hex_ascii_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%r13
lea    0xe93(%rip),%r12
mov    %r12,%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15d,%r12d
test   %r15d,%r15d
jle    11cf <print_hex_ascii_line+0x7f>
lea    0xe71(%rip),%rbp
xor    %ebx,%ebx
jmp    11a9 <print_hex_ascii_line+0x59>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %ebx,%r12d
je     11c9 <print_hex_ascii_line+0x79>
mov    0x0(%r13,%rbx,4),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x7,%ebx
jne    11a0 <print_hex_ascii_line+0x50>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11a0 <print_hex_ascii_line+0x50>
cmp    $0x7,%r12d
jg     11e8 <print_hex_ascii_line+0x98>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
jmp    11fb <print_hex_ascii_line+0xab>
mov    $0x20,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
cmp    $0xf,%r15d
ja     123c <print_hex_ascii_line+0xec>
mov    $0x10,%eax
sub    %r15d,%eax
cmp    $0x2,%eax
mov    $0x1,%ebx
cmovge %eax,%ebx
lea    0xdef(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
add    $0xffffffff,%ebx
jne    1220 <print_hex_ascii_line+0xd0>
lea    0xdc1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15d,%r15d
jle    12a2 <print_hex_ascii_line+0x152>
xor    %ebx,%ebx
jmp    1282 <print_hex_ascii_line+0x132>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2e,%ebp
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
add    $0x1,%rbx
cmp    %ebx,%r12d
je     12a2 <print_hex_ascii_line+0x152>
mov    0x0(%r13,%rbx,4),%edi
call   1070 <isprint@plt>
test   %rax,%rax
je     1260 <print_hex_ascii_line+0x110>
mov    0x0(%r13,%rbx,4),%edi
call   1030 <putchar@plt>
mov    0x0(%r13,%rbx,4),%ebp
jmp    126f <print_hex_ascii_line+0x11f>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fputc@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%05d \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 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c".\00"
@.str.6 = [2 x i8] c"\0A\00"
define void @print_hex_ascii_line(i32* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store i32 0, i32* %9
store i32 0, i32* %10
%12 = load i32, i32* %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32*, i32** %8
%15 = load i32, i32* %7
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %5
store i32* %17, i32** %11
store i32 0, i32* %9
br label %18
18: ; preds = %33, %4
%19 = load i32, i32* %9
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i32*, i32** %11
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32*, i32** %11
%27 = getelementptr inbounds i32, i32* %26, i32 1
store i32* %27, i32** %11
%28 = load i32, i32* %9
%29 = icmp eq i32 %28, 7
br i1 %29, label %30, label %32
30: ; preds = %22
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %22
br label %33
33: ; preds = %32
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %18
36: ; preds = %18
%37 = load i32, i32* %6
%38 = icmp slt i32 %37, 8
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %39, %36
%42 = load i32*, i32** %8
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%44 = load i32, i32* %6
%45 = icmp slt i32 %44, 16
br i1 %45, label %46, label %61
46: ; preds = %41
%47 = load i32, i32* %6
%48 = sub nsw i32 16, %47
store i32 %48, i32* %10
store i32 0, i32* %9
br label %49
49: ; preds = %57, %46
%50 = load i32, i32* %9
%51 = load i32, i32* %10
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %60
53: ; preds = %49
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%55 = load i32*, i32** %8
%56 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %57
57: ; preds = %53
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
br label %49
60: ; preds = %49
br label %61
61: ; preds = %60, %41
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%63 = load i32*, i32** %5
store i32* %63, i32** %11
store i32 0, i32* %9
br label %64
64: ; preds = %88, %61
%65 = load i32, i32* %9
%66 = load i32, i32* %6
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %91
68: ; preds = %64
%69 = load i32*, i32** %11
%70 = load i32, i32* %69
%71 = call i64 @isprint(i32 %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %81
73: ; preds = %68
%74 = load i32*, i32** %11
%75 = load i32, i32* %74
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %75)
%77 = load i32*, i32** %8
%78 = load i32*, i32** %11
%79 = load i32, i32* %78
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %79)
br label %85
81: ; preds = %68
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%83 = load i32*, i32** %8
%84 = call i32 (i32*, i8*, ...) @fprintf(i32* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %85
85: ; preds = %81, %73
%86 = load i32*, i32** %11
%87 = getelementptr inbounds i32, i32* %86, i32 1
store i32* %87, i32** %11
br label %88
88: ; preds = %85
%89 = load i32, i32* %9
%90 = add nsw i32 %89, 1
store i32 %90, i32* %9
br label %64
91: ; preds = %64
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%93 = load i32*, i32** %8
%94 = call i32 (i32*, i8*, ...) @fprintf(i32* %93, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%05d \00"
@.str.1 = [6 x i8] c"%02x \00"
@.str.3 = [4 x i8] c" \00"
define void @print_hex_ascii_line(i32* nocapture %0, i32 %1, i32 %2, i32* nocapture %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %2)
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %2)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %22
8: ; preds = %4, %17
%9 = phi i32* [ %13, %17 ], [ %0, %4 ]
%10 = phi i32 [ %18, %17 ], [ 0, %4 ]
%11 = load i32, i32* %9
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds i32, i32* %9, i64 1
%14 = icmp eq i32 %10, 7
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = tail call i32 @putchar(i32 32)
br label %17
17: ; preds = %8, %15
%18 = add nuw nsw i32 %10, 1
%19 = icmp eq i32 %18, %1
br i1 %19, label %20, label %8
20: ; preds = %17
%21 = icmp slt i32 %1, 8
br i1 %21, label %22, label %25
22: ; preds = %4, %20
%23 = tail call i32 @putchar(i32 32)
%24 = tail call i32 @fputc(i32 32, i32* %3)
br label %28
25: ; preds = %20
%26 = tail call i32 @fputc(i32 32, i32* %3)
%27 = icmp ult i32 %1, 16
br i1 %27, label %28, label %37
28: ; preds = %25, %22
%29 = sub i32 16, %1
%30 = call i32 @llvm.smax.i32(i32 %29, i32 1)
br label %31
31: ; preds = %28, %31
%32 = phi i32 [ %35, %31 ], [ 0, %28 ]
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%34 = tail call i32 @fputc(i32 32, i32* %3)
%35 = add nuw nsw i32 %32, 1
%36 = icmp eq i32 %35, %30
br i1 %36, label %37, label %31
37: ; preds = %31, %25
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br i1 %7, label %39, label %57
39: ; preds = %37, %51
%40 = phi i32* [ %54, %51 ], [ %0, %37 ]
%41 = phi i32 [ %55, %51 ], [ 0, %37 ]
%42 = load i32, i32* %40
%43 = tail call i64 @isprint(i32 %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %49, label %45
45: ; preds = %39
%46 = load i32, i32* %40
%47 = tail call i32 @putchar(i32 %46)
%48 = load i32, i32* %40
br label %51
49: ; preds = %39
%50 = tail call i32 @putchar(i32 46)
br label %51
51: ; preds = %49, %45
%52 = phi i32 [ 46, %49 ], [ %48, %45 ]
%53 = tail call i32 @fputc(i32 %52, i32* %3)
%54 = getelementptr inbounds i32, i32* %40, i64 1
%55 = add nuw nsw i32 %41, 1
%56 = icmp eq i32 %55, %1
br i1 %56, label %57, label %39
57: ; preds = %51, %37
%58 = tail call i32 @putchar(i32 10)
%59 = tail call i32 @fputc(i32 10, i32* %3)
ret void
}