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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int prep_pass2(char *input, char *output) {
  FILE *source = fopen(input, "r");
  FILE *target = fopen(output, "w");
  char string[256];
  char *token;
  while (fgets(string, sizeof(string), source) != NULL) {
    int c = 0;
    int loop = 0;
    while (loop == 0) {
      if (string[c] == ' ') {
        c++;
      } else {
        while (string[c] != '\0') {
          fputc(string[c], target);
          c++;
        }
        loop++;
      }
    }
  }
  fclose(source);
  fclose(target);
}


x86 assembly (clang, -O0):
<prep_pass2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     124b <prep_pass2+0x10b>
movl   $0x0,-0x13c(%rbp)
movl   $0x0,-0x140(%rbp)
cmpl   $0x0,-0x140(%rbp)
jne    1246 <prep_pass2+0x106>
movslq -0x13c(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    11e7 <prep_pass2+0xa7>
mov    -0x13c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13c(%rbp)
jmp    1241 <prep_pass2+0x101>
jmp    11ec <prep_pass2+0xac>
movslq -0x13c(%rbp),%rax
movsbl -0x130(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1232 <prep_pass2+0xf2>
movslq -0x13c(%rbp),%rax
mov    -0x130(%rbp,%rax,1),%al
mov    -0x28(%rbp),%rsi
movsbl %al,%edi
call   1040 <fputc@plt>
mov    -0x13c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13c(%rbp)
jmp    11ec <prep_pass2+0xac>
mov    -0x140(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x140(%rbp)
jmp    11ae <prep_pass2+0x6e>
jmp    117b <prep_pass2+0x3b>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prep_pass2>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
lea    0xea6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%r13
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11e8 <prep_pass2+0xa8>
xor    %ecx,%ecx
lea    0x1(%rsp),%r12
mov    %rsp,%r15
jmp    11ba <prep_pass2+0x7a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
mov    $0x0,%ecx
test   %rax,%rax
je     11e8 <prep_pass2+0xa8>
mov    %ecx,%ebx
mov    (%rsp,%rbx,1),%al
test   %al,%al
je     11a0 <prep_pass2+0x60>
add    $0x1,%ecx
cmp    $0x20,%al
je     11ba <prep_pass2+0x7a>
add    %r12,%rbx
nopl   (%rax)
movsbl %al,%edi
mov    %r13,%rsi
call   1040 <fputc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11d0 <prep_pass2+0x90>
jmp    11a0 <prep_pass2+0x60>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @prep_pass2(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [256 x i8]
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%12 = load i8*, i8** %4
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %6
%14 = load i8*, i8** %5
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %7
br label %16
16: ; preds = %56, %2
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%18 = load i32*, i32** %6
%19 = call i32* @fgets(i8* %17, i32 256, i32* %18)
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %57
21: ; preds = %16
store i32 0, i32* %10
store i32 0, i32* %11
br label %22
22: ; preds = %55, %21
%23 = load i32, i32* %11
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %56
25: ; preds = %22
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 32
br i1 %31, label %32, label %35
32: ; preds = %25
%33 = load i32, i32* %10
%34 = add nsw i32 %33, 1
store i32 %34, i32* %10
br label %55
35: ; preds = %25
br label %36
36: ; preds = %43, %35
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %52
43: ; preds = %36
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = load i32*, i32** %7
%49 = call i32 @fputc(i8 signext %47, i32* %48)
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
store i32 %51, i32* %10
br label %36
52: ; preds = %36
%53 = load i32, i32* %11
%54 = add nsw i32 %53, 1
store i32 %54, i32* %11
br label %55
55: ; preds = %52, %32
br label %22
56: ; preds = %22
br label %16
57: ; preds = %16
%58 = load i32*, i32** %6
%59 = call i32 @fclose(i32* %58)
%60 = load i32*, i32** %7
%61 = call i32 @fclose(i32* %60)
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
define i32 @prep_pass2(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [256 x i8]
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = call i32* @fgets(i8* %6, i32 256, i32* %4)
%8 = icmp eq i32* %7, null
br i1 %8, label %28, label %14
9: ; preds = %20, %14
%10 = call i32* @fgets(i8* %6, i32 256, i32* %4)
%11 = icmp eq i32* %10, null
br i1 %11, label %28, label %12
12: ; preds = %9, %14
%13 = phi i32 [ %19, %14 ], [ 0, %9 ]
br label %14
14: ; preds = %2, %12
%15 = phi i32 [ %13, %12 ], [ 0, %2 ]
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = add nuw nsw i32 %15, 1
switch i8 %18, label %20 [
i8 32, label %12
i8 0, label %9
]
20: ; preds = %14, %20
%21 = phi i64 [ %24, %20 ], [ %16, %14 ]
%22 = phi i8 [ %26, %20 ], [ %18, %14 ]
%23 = call i32 @fputc(i8 signext %22, i32* %5)
%24 = add i64 %21, 1
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %9, label %20
28: ; preds = %9, %2
%29 = call i32 @fclose(i32* %4)
%30 = call i32 @fclose(i32* %5)
ret i32 undef
}