#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 */
char *calloc(long, int);
size_t fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int getAsciiArt(FILE *fp, long bufsize) {
  long base, count;
  int i, j, k;
  char *buf = calloc(bufsize + 1, sizeof(char));
  size_t newLen = fread(buf, sizeof(char), bufsize, fp);
  buf[++newLen] = '\0';
  count = 0;
  for (i = 0; i < 11; i++) {
    for (j = 0; j < 67; j++) {
      base = (j * 11 * (20 + 1)) + i * (20 + 1);
      for (k = 0; k < 20; k++) {
        printf("0x%02X, ", buf[base++]);
        count++;
        if (count % 20 == 0) {
          printf("\n");
          count = 0;
        }
      }
    }
    printf("0x0A, ");
    count++;
  }
  printf("0x0");
  free(buf);
  return 0;
}


x86 assembly (clang, -O0):
<getAsciiArt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x40(%rbp)
movb   $0x0,0x1(%rax,%rcx,1)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xb,-0x24(%rbp)
jge    1293 <getAsciiArt+0x153>
movl   $0x0,-0x28(%rbp)
cmpl   $0x43,-0x28(%rbp)
jge    126b <getAsciiArt+0x12b>
imul   $0xb,-0x28(%rbp),%eax
imul   $0x15,%eax,%eax
imul   $0x15,-0x24(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x14,-0x2c(%rbp)
jge    1258 <getAsciiArt+0x118>
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
movsbl (%rax,%rcx,1),%esi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    $0x14,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1245 <getAsciiArt+0x105>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x20(%rbp)
jmp    124a <getAsciiArt+0x10a>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11dc <getAsciiArt+0x9c>
jmp    125d <getAsciiArt+0x11d>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b8 <getAsciiArt+0x78>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a7 <getAsciiArt+0x67>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getAsciiArt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0x1(%rsi),%rdi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1050 <fread@plt>
movb   $0x0,0x1(%rax,%r14,1)
lea    0xe6b(%rip),%r13
movabs $0x1999999999999998,%rbx
99 99 19
movabs $0xccccccccccccccc,%rbp
cc cc 0c
mov    %r14,0x8(%rsp)
xor    %eax,%eax
xor    %r15d,%r15d
jmp    11ea <getAsciiArt+0x9a>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r15
mov    0x10(%rsp),%rax
add    $0x1,%rax
mov    0x18(%rsp),%r14
add    $0x15,%r14
cmp    $0xb,%rax
je     1269 <getAsciiArt+0x119>
mov    %rax,0x10(%rsp)
mov    %r14,0x18(%rsp)
xor    %eax,%eax
jmp    1216 <getAsciiArt+0xc6>
nopl   0x0(%rax,%rax,1)
mov    0x20(%rsp),%rax
add    $0x1,%rax
add    $0xe7,%r14
cmp    $0x43,%rax
je     11c0 <getAsciiArt+0x70>
mov    %rax,0x20(%rsp)
xor    %r12d,%r12d
jmp    122a <getAsciiArt+0xda>
add    $0x1,%r12
cmp    $0x14,%r12
je     1200 <getAsciiArt+0xb0>
movsbl (%r14,%r12,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r15
mov    %r15,%rax
movabs $0xcccccccccccccccd,%rcx
cc cc cc
imul   %rcx,%rax
add    %rbx,%rax
ror    $0x2,%rax
cmp    %rbp,%rax
ja     1220 <getAsciiArt+0xd0>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %r15d,%r15d
jmp    1220 <getAsciiArt+0xd0>
lea    0xda0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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