#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 dump_buffer(int size, int *buf) {
  int i;
  if (size == 0)
    return;
  for (i = 0; i < size; i++) {
    printf("%02X", buf[i]);
    if ((i + 1) % 2 == 0)
      printf(" ");
  }
  printf("\n");
  for (i = 0; i < size; i++) {
    if (buf[i] == ' ')
      printf(" !");
    else if (((' ') <= (buf[i]) && (buf[i]) <= ('~')))
      printf("%c ", buf[i]);
    else
      printf("  ");
    if ((i + 1) % 2 == 0)
      printf(" ");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dump_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    112e <dump_buffer+0x1e>
jmp    1277 <dump_buffer+0x167>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1192 <dump_buffer+0x82>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    117f <dump_buffer+0x6f>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1184 <dump_buffer+0x74>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1135 <dump_buffer+0x25>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1269 <dump_buffer+0x159>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x20,(%rax,%rcx,4)
jne    11d8 <dump_buffer+0xc8>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1231 <dump_buffer+0x121>
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    $0x20,%eax
cmp    (%rcx,%rdx,4),%eax
jg     121e <dump_buffer+0x10e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x7e,(%rax,%rcx,4)
jg     121e <dump_buffer+0x10e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122c <dump_buffer+0x11c>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1231 <dump_buffer+0x121>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1256 <dump_buffer+0x146>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125b <dump_buffer+0x14b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a7 <dump_buffer+0x97>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_buffer>:
test   %edi,%edi
je     123c <dump_buffer+0x11c>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
jle    123d <dump_buffer+0x11d>
mov    %rsi,%r12
mov    %edi,%r14d
mov    %edi,%r13d
mov    %r13,%rbp
neg    %rbp
mov    $0x1,%ebx
lea    0xeac(%rip),%r15
jmp    1172 <dump_buffer+0x52>
cs nopw 0x0(%rax,%rax,1)
lea    (%rbx,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
je     1192 <dump_buffer+0x72>
mov    -0x4(%r12,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bl
jne    1160 <dump_buffer+0x40>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1160 <dump_buffer+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    1247 <dump_buffer+0x127>
neg    %r13
mov    $0x1,%ebp
lea    0xe51(%rip),%r14
lea    0xe4d(%rip),%r15
lea    0xe4a(%rip),%rbx
jmp    11e5 <dump_buffer+0xc5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(,%rbp,1),%rax
add    %r13,%rax
add    $0x1,%rbp
cmp    $0x1,%rax
je     1247 <dump_buffer+0x127>
mov    -0x4(%r12,%rbp,4),%esi
cmp    $0x20,%esi
jne    1200 <dump_buffer+0xe0>
mov    %r14,%rdi
jmp    1223 <dump_buffer+0x103>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x20(%rsi),%eax
cmp    $0x5e,%eax
ja     1220 <dump_buffer+0x100>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bpl
jne    11d0 <dump_buffer+0xb0>
jmp    1230 <dump_buffer+0x110>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bpl
jne    11d0 <dump_buffer+0xb0>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11d0 <dump_buffer+0xb0>
ret
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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