#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
void getPuzzle(char *puzzle) {
  int c;
  int i, j;
  FILE *file;
  i = j = 0;
  file = fopen("puzzle.txt", "r");
  while ((c = getc(file)) != EOF) {
    if (c == '\t' || c == ' ') {
      continue;
    } else if (c == '\n') {
      ++j;
      i = 0;
    } else {
      puzzle[j * 50 + i] = c;
      i++;
    }
  }
  fclose(file);
}


x86 assembly (clang, -O0):
<getPuzzle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeaf(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e74(%rip),%rcx
cmp    (%rcx),%eax
je     11dd <getPuzzle+0xad>
cmpl   $0x9,-0xc(%rbp)
je     1190 <getPuzzle+0x60>
cmpl   $0x20,-0xc(%rbp)
jne    1195 <getPuzzle+0x65>
jmp    1161 <getPuzzle+0x31>
cmpl   $0xa,-0xc(%rbp)
jne    11b4 <getPuzzle+0x84>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    11d3 <getPuzzle+0xa3>
mov    -0xc(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
imul   $0x32,-0x14(%rbp),%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d8 <getPuzzle+0xa8>
jmp    1161 <getPuzzle+0x31>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getPuzzle>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
lea    0xebe(%rip),%rdi
lea    0xec2(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <getc@plt>
mov    0x2e88(%rip),%r15
cmp    (%r15),%eax
jne    1175 <getPuzzle+0x45>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    119d <getPuzzle+0x6d>
imul   $0x32,%r12d,%ecx
add    %ebp,%ecx
movslq %ecx,%rcx
mov    %al,(%r14,%rcx,1)
add    $0x1,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <getc@plt>
cmp    (%r15),%eax
je     1165 <getPuzzle+0x35>
cmp    $0x9,%eax
je     1190 <getPuzzle+0x60>
cmp    $0x20,%eax
je     1190 <getPuzzle+0x60>
cmp    $0xa,%eax
jne    117c <getPuzzle+0x4c>
add    $0x1,%r12d
xor    %ebp,%ebp
jmp    1190 <getPuzzle+0x60>

LLVM IR (-O0):
@.str = [11 x i8] c"puzzle.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
define void @getPuzzle(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i8* %0, i8** %2
store i32 0, i32* %5
store i32 0, i32* %4
%7 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
br label %8
8: ; preds = %39, %19, %1
%9 = load i32*, i32** %6
%10 = call i32 @getc(i32* %9)
store i32 %10, i32* %3
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %40
13: ; preds = %8
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 9
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 32
br i1 %18, label %19, label %20
19: ; preds = %16, %13
br label %8
20: ; preds = %16
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
store i32 0, i32* %4
br label %38
26: ; preds = %20
%27 = load i32, i32* %3
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %2
%30 = load i32, i32* %5
%31 = mul nsw i32 %30, 50
%32 = load i32, i32* %4
%33 = add nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %29, i64 %34
store i8 %28, i8* %35
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %38
38: ; preds = %26, %23
br label %39
39: ; preds = %38
br label %8
40: ; preds = %8
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"puzzle.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
define void @getPuzzle(i8* nocapture writeonly %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @getc(i32* %2)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %31, label %6
6: ; preds = %1, %25
%7 = phi i32 [ %28, %25 ], [ %3, %1 ]
%8 = phi i32 [ %27, %25 ], [ 0, %1 ]
%9 = phi i32 [ %26, %25 ], [ 0, %1 ]
br label %10
10: ; preds = %6, %12
%11 = phi i32 [ %7, %6 ], [ %13, %12 ]
switch i32 %11, label %18 [
i32 32, label %12
i32 9, label %12
i32 10, label %16
]
12: ; preds = %10, %10
%13 = tail call i32 @getc(i32* %2)
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %31, label %10
16: ; preds = %10
%17 = add nsw i32 %9, 1
br label %25
18: ; preds = %10
%19 = trunc i32 %11 to i8
%20 = mul nsw i32 %9, 50
%21 = add nsw i32 %20, %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %0, i64 %22
store i8 %19, i8* %23
%24 = add nsw i32 %8, 1
br label %25
25: ; preds = %16, %18
%26 = phi i32 [ %17, %16 ], [ %9, %18 ]
%27 = phi i32 [ 0, %16 ], [ %24, %18 ]
%28 = tail call i32 @getc(i32* %2)
%29 = load i32, i32* @EOF
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %6
31: ; preds = %25, %12, %1
%32 = tail call i32 @fclose(i32* %2)
ret void
}