#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 print_hex_line(char *prefix, unsigned char *outbuf, int index) {
  int i;
  printf("\r%s", prefix);
  for (i = 0; i < index; i++) {
    if ((i % 4) == 0) {
      printf(" ");
    }
    printf("%02X", outbuf[i] & 0xFF);
  }
  printf("  ");
  for (i = index; i < 20; i++) {
    if ((i % 4) == 0) {
      printf(" ");
    }
    printf("  ");
  }
  for (i = 0; i < index; i++) {
    if (outbuf[i] < 30 || outbuf[i] > 126) {
      printf(".");
    } else {
      printf("%c", outbuf[i]);
    }
  }
}


x86 assembly (clang, -O0):
<print_hex_line>:
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    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1198 <print_hex_line+0x88>
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116a <print_hex_line+0x5a>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
and    $0xff,%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113c <print_hex_line+0x2c>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x14,-0x18(%rbp)
jge    11f4 <print_hex_line+0xe4>
mov    -0x18(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d8 <print_hex_line+0xc8>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ac <print_hex_line+0x9c>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1271 <print_hex_line+0x161>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x1e,%eax
jl     1231 <print_hex_line+0x121>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x7e,%eax
jle    1244 <print_hex_line+0x134>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125e <print_hex_line+0x14e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1263 <print_hex_line+0x153>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11fb <print_hex_line+0xeb>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_hex_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,%rsi
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%ebp
test   %r14d,%r14d
jle    11d9 <print_hex_line+0xb9>
lea    0xeb2(%rip),%r15
xor    %ebx,%ebx
jmp    1178 <print_hex_line+0x58>
cs nopw 0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1189 <print_hex_line+0x69>
test   $0x3,%bl
jne    1160 <print_hex_line+0x40>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1160 <print_hex_line+0x40>
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%ebx
cmp    $0x13,%r14d
jle    1206 <print_hex_line+0xe6>
test   %r14d,%r14d
jle    11d0 <print_hex_line+0xb0>
xor    %ebx,%ebx
mov    $0x2e,%r14d
nopl   (%rax)
movzbl (%r12,%rbx,1),%eax
lea    -0x7f(%rax),%ecx
cmp    $0x9f,%cl
cmovb  %r14d,%eax
movzbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11b0 <print_hex_line+0x90>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe29(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14d,%ebx
jmp    1206 <print_hex_line+0xe6>
nopl   0x0(%rax)
lea    0xe12(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0x14,%ebx
je     11a0 <print_hex_line+0x80>
test   $0x3,%bl
jne    11f0 <print_hex_line+0xd0>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11f0 <print_hex_line+0xd0>

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

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