#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
scalar_t__ isalnum(char);
int fill_buf(FILE *f, char data, int flush) {
  static char buf[12];
  static unsigned int cnt = 0;
  unsigned int i, j;
  if (!flush)
    buf[cnt++] = data;
  if ((cnt >= 12) || flush) {
    fprintf(f, "    ");
    for (i = 0; i < cnt; i++)
      fprintf(f, "%02X ", 0xff & buf[i]);
    if (flush)
      for (j = i; j < 12; j++)
        fprintf(f, "   ");
    fprintf(f, "| ");
    for (i = 0; i < cnt; i++)
      fprintf(f, "%c", isalnum(buf[i]) ? buf[i] : '.');
    fprintf(f, "\n");
    cnt = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<fill_buf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1161 <fill_buf+0x41>
mov    -0x9(%rbp),%dl
mov    0x2ef8(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2eed(%rip)
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2ed6(%rip),%rax
mov    %dl,(%rax,%rcx,1)
cmpl   $0xc,0x2ed8(%rip)
jae    1178 <fill_buf+0x58>
cmpl   $0x0,-0x10(%rbp)
je     12c8 <fill_buf+0x1a8>
mov    -0x8(%rbp),%rdi
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    0x2ea6(%rip),%eax
jae    11d6 <fill_buf+0xb6>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
lea    0x2e84(%rip),%rax
movsbl (%rax,%rcx,1),%edx
and    $0xff,%edx
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1191 <fill_buf+0x71>
cmpl   $0x0,-0x10(%rbp)
je     1215 <fill_buf+0xf5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xc,-0x18(%rbp)
jae    1210 <fill_buf+0xf0>
mov    -0x8(%rbp),%rdi
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e6 <fill_buf+0xc6>
jmp    1215 <fill_buf+0xf5>
mov    -0x8(%rbp),%rdi
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    0x2e09(%rip),%eax
jae    12ac <fill_buf+0x18c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
lea    0x2de3(%rip),%rax
movsbl (%rax,%rcx,1),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
je     127c <fill_buf+0x15c>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
lea    0x2dc4(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x24(%rbp)
jmp    1289 <fill_buf+0x169>
mov    $0x2e,%eax
mov    %eax,-0x24(%rbp)
jmp    1289 <fill_buf+0x169>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xd77(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    122e <fill_buf+0x10e>
mov    -0x8(%rbp),%rdi
lea    0xd5a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,0x2d78(%rip)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_buf>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rdi,%rbx
test   %edx,%edx
jne    1175 <fill_buf+0x35>
mov    0x2ef8(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2eef(%rip)
lea    0x2edc(%rip),%rdx
mov    %sil,(%rax,%rdx,1)
cmp    $0xc,%ecx
jb     128b <fill_buf+0x14b>
lea    0xe84(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
cmpl   $0x0,0x2ebb(%rip)
je     11d9 <fill_buf+0x99>
lea    0x2ea6(%rip),%r12
lea    0xe60(%rip),%r15
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movzbl 0x0(%rbp,%r12,1),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%rbp
mov    0x2e83(%rip),%eax
cmp    %rax,%rbp
jb     11b0 <fill_buf+0x70>
test   %r14d,%r14d
jne    11e0 <fill_buf+0xa0>
jmp    1209 <fill_buf+0xc9>
xor    %ebp,%ebp
test   %r14d,%r14d
je     1209 <fill_buf+0xc9>
cmp    $0xb,%ebp
ja     1209 <fill_buf+0xc9>
add    $0xfffffff4,%ebp
lea    0xe12(%rip),%r14
nop
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <fwrite@plt>
inc    %ebp
jne    11f0 <fill_buf+0xb0>
lea    0xdfb(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
cmpl   $0x0,0x2e27(%rip)
je     1274 <fill_buf+0x134>
xor    %ebp,%ebp
lea    0x2e10(%rip),%r14
jmp    125d <fill_buf+0x11d>
cs nopw 0x0(%rax,%rax,1)
movsbl 0x0(%rbp,%r14,1),%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbp
mov    0x2df8(%rip),%eax
cmp    %rax,%rbp
jae    1274 <fill_buf+0x134>
movsbl 0x0(%rbp,%r14,1),%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1240 <fill_buf+0x100>
mov    $0x2e,%edi
jmp    1246 <fill_buf+0x106>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
movl   $0x0,0x2dc5(%rip)
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@fill_buf.buf = internal unnamed_addr global [12 x i8] zeroinitializer
@fill_buf.cnt = internal unnamed_addr global i32 0
@.str = [5 x i8] c" \00"
@.str.1 = [6 x i8] c"%02X \00"
@.str.2 = [4 x i8] c" \00"
@.str.3 = [3 x i8] c"| \00"
define i32 @fill_buf(i32* nocapture %0, i8 signext %1, i32 %2) {
%4 = icmp ne i32 %2, 0
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = load i32, i32* @fill_buf.cnt
%7 = add i32 %6, 1
store i32 %7, i32* @fill_buf.cnt
%8 = zext i32 %6 to i64
%9 = getelementptr inbounds [12 x i8], [12 x i8]* @fill_buf.buf, i64 0, i64 %8
store i8 %1, i8* %9
%10 = icmp ugt i32 %7, 11
br i1 %10, label %11, label %58
11: ; preds = %3, %5
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 4, i64 1, i32* %0)
%13 = load i32, i32* @fill_buf.cnt
%14 = icmp eq i32 %13, 0
br i1 %14, label %27, label %15
15: ; preds = %11, %15
%16 = phi i64 [ %21, %15 ], [ 0, %11 ]
%17 = getelementptr inbounds [12 x i8], [12 x i8]* @fill_buf.buf, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %16, 1
%22 = load i32, i32* @fill_buf.cnt
%23 = zext i32 %22 to i64
%24 = icmp ult i64 %21, %23
br i1 %24, label %15, label %25
25: ; preds = %15
%26 = trunc i64 %21 to i32
br label %27
27: ; preds = %25, %11
%28 = phi i32 [ 0, %11 ], [ %26, %25 ]
%29 = icmp ult i32 %28, 12
%30 = select i1 %4, i1 %29, i1 false
br i1 %30, label %31, label %36
31: ; preds = %27, %31
%32 = phi i32 [ %34, %31 ], [ %28, %27 ]
%33 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 3, i64 1, i32* %0)
%34 = add i32 %32, 1
%35 = icmp eq i32 %34, 12
br i1 %35, label %36, label %31
36: ; preds = %31, %27
%37 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 2, i64 1, i32* %0)
%38 = load i32, i32* @fill_buf.cnt
%39 = icmp eq i32 %38, 0
br i1 %39, label %56, label %40
40: ; preds = %36, %49
%41 = phi i64 [ %52, %49 ], [ 0, %36 ]
%42 = getelementptr inbounds [12 x i8], [12 x i8]* @fill_buf.buf, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = tail call i64 @isalnum(i8 signext %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %40
%47 = load i8, i8* %42
%48 = sext i8 %47 to i32
br label %49
49: ; preds = %40, %46
%50 = phi i32 [ %48, %46 ], [ 46, %40 ]
%51 = tail call i32 @fputc(i32 %50, i32* %0)
%52 = add nuw nsw i64 %41, 1
%53 = load i32, i32* @fill_buf.cnt
%54 = zext i32 %53 to i64
%55 = icmp ult i64 %52, %54
br i1 %55, label %40, label %56
56: ; preds = %49, %36
%57 = tail call i32 @fputc(i32 10, i32* %0)
store i32 0, i32* @fill_buf.cnt
br label %58
58: ; preds = %5, %56
ret i32 0
}