#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*/ isgraph(char);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void BufInfo(char *buf, unsigned int size) {
  unsigned int x;
  x = 0;
  while (1) {
    if (buf[x] == '\0')
      printf("'\\0'");
    else if ((!isgraph(buf[x]) && !isspace(buf[x])))
      printf("%.2X", buf[x]);
    else
      printf("'%c'", buf[x]);
    x++;
    if (x == size + 1)
      break;
    printf(",%*c", buf[x] == 0 ? 2 : 3, ' ');
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<BufInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    117d <BufInfo+0x3d>
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11eb <BufInfo+0xab>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1060 <isgraph@plt>
cmp    $0x0,%eax
jne    11cd <BufInfo+0x8d>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1050 <isspace@plt>
cmp    $0x0,%eax
jne    11cd <BufInfo+0x8d>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e6 <BufInfo+0xa6>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%esi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11eb <BufInfo+0xab>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    120a <BufInfo+0xca>
jmp    123d <BufInfo+0xfd>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
mov    $0x3,%esi
mov    $0x2,%eax
cmp    $0x0,%ecx
cmove  %eax,%esi
lea    0xde3(%rip),%rdi
mov    $0x20,%edx
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1156 <BufInfo+0x16>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BufInfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %esi,%ebp
neg    %rbp
mov    $0x1,%r12d
lea    0xeaf(%rip),%r15
lea    0xea3(%rip),%r13
nopw   0x0(%rax,%rax,1)
lea    (%r12,%rbp,1),%r14
movzbl -0x1(%rbx,%r12,1),%eax
test   %al,%al
je     11c0 <BufInfo+0x80>
movsbl %al,%edi
call   1060 <isgraph@plt>
test   %eax,%eax
jne    1199 <BufInfo+0x59>
movsbl -0x1(%rbx,%r12,1),%edi
call   1050 <isspace@plt>
test   %eax,%eax
je     11fb <BufInfo+0xbb>
movsbl -0x1(%rbx,%r12,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%r14
jne    11d4 <BufInfo+0x94>
jmp    120a <BufInfo+0xca>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe39(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%r14
je     120a <BufInfo+0xca>
mov    %r12d,%eax
cmpb   $0x1,(%rbx,%rax,1)
mov    $0x3,%esi
sbb    $0x0,%esi
mov    %r15,%rdi
mov    $0x20,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
jmp    1170 <BufInfo+0x30>
movsbl -0x1(%rbx,%r12,1),%esi
lea    0xdfd(%rip),%rdi
jmp    11a2 <BufInfo+0x62>
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"'\\0'\00"
@.str.1 = [5 x i8] c"%.2X\00"
@.str.2 = [5 x i8] c"'%c'\00"
@.str.3 = [5 x i8] c",%*c\00"
define void @BufInfo(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %2, %57
%7 = load i8*, i8** %3
%8 = load i32, i32* %5
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %49
16: ; preds = %6
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @isgraph(i8 signext %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %40, label %24
24: ; preds = %16
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @isspace(i8 signext %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %40, label %32
32: ; preds = %24
%33 = load i8*, i8** %3
%34 = load i32, i32* %5
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %48
40: ; preds = %24, %16
%41 = load i8*, i8** %3
%42 = load i32, i32* %5
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %40, %32
br label %49
49: ; preds = %48, %14
%50 = load i32, i32* %5
%51 = add i32 %50, 1
store i32 %51, i32* %5
%52 = load i32, i32* %5
%53 = load i32, i32* %4
%54 = add i32 %53, 1
%55 = icmp eq i32 %52, %54
br i1 %55, label %56, label %57
56: ; preds = %49
br label %68
57: ; preds = %49
%58 = load i8*, i8** %3
%59 = load i32, i32* %5
%60 = zext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 0
%65 = zext i1 %64 to i64
%66 = select i1 %64, i32 2, i32 3
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %66, i32 32)
br label %6
68: ; preds = %56
%69 = call i32 @putchar(i8 signext 10)
ret void
}

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