#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*/ fprintf(int /*<<< orphan*/ *, char *, char *);
char *strtok(char *, char *);
int prep_pass1(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) {
    token = strtok(string, "\t\n");
    while (token != NULL) {
      fprintf(target, "%s\n", token);
      token = strtok(NULL, "\t\n");
    }
  }
  fclose(source);
  fclose(target);
}


x86 assembly (clang, -O0):
<prep_pass1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     120a <prep_pass1+0xba>
lea    -0x130(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x138(%rbp)
cmpq   $0x0,-0x138(%rbp)
je     1205 <prep_pass1+0xb5>
mov    -0x28(%rbp),%rdi
mov    -0x138(%rbp),%rdx
lea    0xe23(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe10(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x138(%rbp)
jmp    11c4 <prep_pass1+0x74>
jmp    118b <prep_pass1+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_pass1>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%rbx
lea    0xe96(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11ef <prep_pass1+0x9f>
lea    0xe64(%rip),%r15
mov    %rsp,%r12
lea    0xe5d(%rip),%r13
jmp    11c5 <prep_pass1+0x75>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11ef <prep_pass1+0x9f>
mov    %r12,%rdi
nopl   0x0(%rax,%rax,1)
mov    %r15,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     11b0 <prep_pass1+0x60>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
call   1050 <fprintf@plt>
xor    %edi,%edi
jmp    11d0 <prep_pass1+0x80>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %rbx,%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"
@.str.2 = [3 x i8] c"\09\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @prep_pass1(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*
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i8*, i8** %5
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %13, i32** %7
br label %14
14: ; preds = %30, %2
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%16 = load i32*, i32** %6
%17 = call i32* @fgets(i8* %15, i32 256, i32* %16)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %31
19: ; preds = %14
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%21 = call i8* @strtok(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %21, i8** %9
br label %22
22: ; preds = %25, %19
%23 = load i8*, i8** %9
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32*, i32** %7
%27 = load i8*, i8** %9
%28 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %29, i8** %9
br label %22
30: ; preds = %22
br label %14
31: ; preds = %14
%32 = load i32*, i32** %6
%33 = call i32 @fclose(i32* %32)
%34 = load i32*, i32** %7
%35 = call i32 @fclose(i32* %34)
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"\09\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @prep_pass1(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 %20, label %12
9: ; preds = %15, %12
%10 = call i32* @fgets(i8* %6, i32 256, i32* %4)
%11 = icmp eq i32* %10, null
br i1 %11, label %20, label %12
12: ; preds = %2, %9
%13 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %9, label %15
15: ; preds = %12, %15
%16 = phi i8* [ %18, %15 ], [ %13, %12 ]
%17 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %9, label %15
20: ; preds = %9, %2
%21 = call i32 @fclose(i32* %4)
%22 = call i32 @fclose(i32* %5)
ret i32 undef
}