#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 EOF;
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
void dump(FILE *f, const char *p) {
  int n;
  printf("static const unsigned char %s[]={\n", p);
  for (n = 1;; n++) {
    int c = getc(f);
    if (c == EOF)
      break;
    printf("%3u,", c);
    if (n == 20) {
      putchar('\n');
      n = 0;
    }
  }
  printf("\n};\n\n");
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%eax
jne    117c <dump+0x4c>
jmp    11bb <dump+0x8b>
mov    -0x18(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x14,-0x14(%rbp)
jne    11a8 <dump+0x78>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x14(%rbp)
jmp    11ad <dump+0x7d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <dump+0x29>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    0x2e81(%rip),%r15
cmp    (%r15),%eax
jne    1182 <dump+0x42>
lea    0xeb5(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
mov    $0x1,%ebp
lea    0xe95(%rip),%r14
jmp    11a0 <dump+0x60>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    (%r15),%eax
je     116c <dump+0x2c>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x14,%ebp
jne    1190 <dump+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
jmp    1190 <dump+0x50>

LLVM IR (-O0):
@.str = [35 x i8] c"static const unsigned char %s[]={\0A\00"
@EOF = global i32 0
@.str.1 = [5 x i8] c"%3u,\00"
@.str.2 = [6 x i8] c"\0A};\0A\0A\00"
define void @dump(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %7)
store i32 1, i32* %5
br label %9
9: ; preds = %24, %2
%10 = load i32*, i32** %3
%11 = call i32 @getc(i32* %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %9
br label %27
16: ; preds = %9
%17 = load i32, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 20
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %5
br label %23
23: ; preds = %21, %16
br label %24
24: ; preds = %23
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %9
27: ; preds = %15
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"static const unsigned char %s[]={\0A\00"
@EOF = global i32 0
@.str.1 = [5 x i8] c"%3u,\00"
@str = [5 x i8] c"\0A};\0A\00"
define void @dump(i32* nocapture %0, i8* %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %1)
%4 = tail call i32 @getc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %20, label %7
7: ; preds = %2, %14
%8 = phi i32 [ %17, %14 ], [ %4, %2 ]
%9 = phi i32 [ %16, %14 ], [ 1, %2 ]
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%11 = icmp eq i32 %9, 20
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @putchar(i8 signext 10)
br label %14
14: ; preds = %12, %7
%15 = phi i32 [ %9, %7 ], [ 0, %12 ]
%16 = add nsw i32 %15, 1
%17 = tail call i32 @getc(i32* %0)
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %7
20: ; preds = %14, %2
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret void
}