#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
void hdr_print(char *title, unsigned char *block, int bytestoprint) {
  int i = 0;
  fprintf(stdout, "hdr_print %d bytes of '%s'=", bytestoprint, title);
  while (i < bytestoprint) {
    if (i % 8 == 0) {
      if (i + 7 >= bytestoprint - 1)
        fprintf(stdout, "\n[%2d-%2d]:  ", i + 1, bytestoprint);
      else
        fprintf(stdout, "\n[%2d-%2d]:  ", i + 1, i + 8);
    }
    fprintf(stdout, "%03u ", block[i++]);
    if (i % 4 == 0)
      fprintf(stdout, "| ");
  }
  fprintf(stdout, "\n");
  fprintf(stdout, "Exiting hdr_print, no return code\n");
}


x86 assembly (clang, -O0):
<hdr_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    0x2eaf(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rcx
lea    0xebf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1226 <hdr_print+0x116>
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c9 <hdr_print+0xb9>
mov    -0x18(%rbp),%eax
add    $0x7,%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     11a1 <hdr_print+0x91>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
add    $0x1,%edx
mov    -0x14(%rbp),%ecx
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11c4 <hdr_print+0xb4>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%ecx
add    $0x8,%ecx
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11c9 <hdr_print+0xb9>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe3b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1221 <hdr_print+0x111>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1148 <hdr_print+0x38>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hdr_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%rcx
mov    0x2eb3(%rip),%r15
mov    (%r15),%edi
lea    0xec9(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbp,0x10(%rsp)
test   %ebp,%ebp
jle    11ef <hdr_print+0xdf>
mov    0x10(%rsp),%rax
lea    -0x1(%rax),%ecx
mov    %ecx,0xc(%rsp)
mov    %eax,%r14d
lea    0xec9(%rip),%r12
xor    %ebp,%ebp
jmp    1178 <hdr_print+0x68>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rbp
cmp    %r14,%r13
je     11ef <hdr_print+0xdf>
test   $0x7,%bpl
je     1190 <hdr_print+0x80>
lea    0x1(%rbp),%r13
jmp    11c5 <hdr_print+0xb5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x7(%rbp),%eax
lea    0x1(%rbp),%r13
mov    (%r15),%edi
cmp    0xc(%rsp),%eax
jge    11af <hdr_print+0x9f>
lea    0x8(%rbp),%ecx
lea    0xe72(%rip),%rsi
mov    %r13d,%edx
jmp    11be <hdr_print+0xae>
lea    0xe66(%rip),%rsi
mov    %r13d,%edx
mov    0x10(%rsp),%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
movzbl (%rbx,%rbp,1),%edx
mov    %r12,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
test   $0x3,%r13b
jne    1170 <hdr_print+0x60>
mov    (%r15),%edi
lea    0xe4a(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    1170 <hdr_print+0x60>
mov    (%r15),%edi
lea    0xe5b(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xe29(%rip),%rsi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

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

LLVM IR (-O2):
@stdout = global i32 0
@.str = [28 x i8] c"hdr_print %d bytes of '%s'=\00"
@.str.1 = [14 x i8] c"\0A[%2d-%2d]: \00"
@.str.2 = [6 x i8] c"%03u \00"
@.str.3 = [3 x i8] c"| \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [35 x i8] c"Exiting hdr_print, no return code\0A\00"
define void @hdr_print(i8* %0, i8* nocapture %1, i32 %2) {
%4 = load i32, i32* @stdout
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %0)
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %46
7: ; preds = %3
%8 = add nsw i32 %2, -1
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %7, %44
%11 = phi i64 [ 0, %7 ], [ %33, %44 ]
%12 = trunc i64 %11 to i32
%13 = and i32 %12, 7
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = add nuw nsw i64 %11, 1
%17 = trunc i64 %16 to i32
br label %31
18: ; preds = %10
%19 = trunc i64 %11 to i32
%20 = add i32 %19, 7
%21 = icmp slt i32 %20, %8
%22 = load i32, i32* @stdout
%23 = add nuw nsw i64 %11, 1
br i1 %21, label %27, label %24
24: ; preds = %18
%25 = trunc i64 %23 to i32
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %2)
br label %31
27: ; preds = %18
%28 = add nuw nsw i32 %12, 8
%29 = trunc i64 %23 to i32
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %28)
br label %31
31: ; preds = %15, %24, %27
%32 = phi i32 [ %17, %15 ], [ %25, %24 ], [ %29, %27 ]
%33 = phi i64 [ %16, %15 ], [ %23, %24 ], [ %23, %27 ]
%34 = load i32, i32* @stdout
%35 = getelementptr inbounds i8, i8* %1, i64 %11
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = and i32 %32, 3
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %31
%42 = load i32, i32* @stdout
%43 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %41, %31
%45 = icmp eq i64 %33, %9
br i1 %45, label %46, label %10
46: ; preds = %44, %3
%47 = load i32, i32* @stdout
%48 = tail call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%49 = load i32, i32* @stdout
%50 = tail call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
ret void
}