#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 */
scalar_t__ isgraph(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void printf_buf_ascii_32fx(unsigned char *buf, int size, char *header) {
  int i;
  if (header)
    printf("%s", header);
  for (i = 0; i < size; i++) {
    if (!(i % 32))
      printf("\n");
    if (isgraph(buf[i]))
      printf("%c", buf[i]);
    else
      printf("[%02X]", buf[i]);
  }
  printf("\n");
  return;
}


x86 assembly (clang, -O0):
<printf_buf_ascii_32fx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1150 <printf_buf_ascii_32fx+0x30>
mov    -0x18(%rbp),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ec <printf_buf_ascii_32fx+0xcc>
mov    -0x1c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1185 <printf_buf_ascii_32fx+0x65>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1040 <isgraph@plt>
cmp    $0x0,%rax
je     11bf <printf_buf_ascii_32fx+0x9f>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <printf_buf_ascii_32fx+0xb9>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <printf_buf_ascii_32fx+0xbe>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1157 <printf_buf_ascii_32fx+0x37>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf_buf_ascii_32fx>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
test   %rdx,%rdx
je     1152 <printf_buf_ascii_32fx+0x22>
lea    0xeb8(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11ae <printf_buf_ascii_32fx+0x7e>
mov    %ebp,%r15d
lea    0xea3(%rip),%r14
xor    %ebp,%ebp
jmp    1183 <printf_buf_ascii_32fx+0x53>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     11ae <printf_buf_ascii_32fx+0x7e>
test   $0x1f,%bpl
jne    1193 <printf_buf_ascii_32fx+0x63>
mov    $0xa,%edi
call   1030 <putchar@plt>
movzbl (%rbx,%rbp,1),%edi
call   1050 <isgraph@plt>
movzbl (%rbx,%rbp,1),%esi
test   %rax,%rax
je     1170 <printf_buf_ascii_32fx+0x40>
mov    %esi,%edi
call   1030 <putchar@plt>
jmp    117a <printf_buf_ascii_32fx+0x4a>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [7 x i8] c"[%02X]\00"
define void @printf_buf_ascii_32fx(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i8*, i8** %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %3
store i32 0, i32* %7
br label %14
14: ; preds = %49, %13
%15 = load i32, i32* %7
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %52
18: ; preds = %14
%19 = load i32, i32* %7
%20 = srem i32 %19, 32
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
%25 = load i8*, i8** %4
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = call i64 @isgraph(i8 zeroext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %40
32: ; preds = %24
%33 = load i8*, i8** %4
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %48
40: ; preds = %24
%41 = load i8*, i8** %4
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %40, %32
br label %49
49: ; preds = %48
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %14
52: ; preds = %14
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.3 = [7 x i8] c"[%02X]\00"
define void @printf_buf_ascii_32fx(i8* nocapture %0, i32 %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %7, label %5
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %7
7: ; preds = %5, %3
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %31
9: ; preds = %7
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %9, %28
%12 = phi i64 [ 0, %9 ], [ %29, %28 ]
%13 = and i64 %12, 31
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = tail call i32 @putchar(i32 10)
br label %17
17: ; preds = %15, %11
%18 = getelementptr inbounds i8, i8* %0, i64 %12
%19 = load i8, i8* %18
%20 = tail call i64 @isgraph(i8 zeroext %19)
%21 = icmp eq i64 %20, 0
%22 = load i8, i8* %18
%23 = zext i8 %22 to i32
br i1 %21, label %26, label %24
24: ; preds = %17
%25 = tail call i32 @putchar(i32 %23)
br label %28
26: ; preds = %17
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %28
28: ; preds = %24, %26
%29 = add nuw nsw i64 %12, 1
%30 = icmp eq i64 %29, %10
br i1 %30, label %31, label %11
31: ; preds = %28, %7
%32 = tail call i32 @putchar(i32 10)
ret void
}