#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 /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ split_field(char *, int);
char *strchr(char *, char);
char *strdup(char *);
void parse(FILE *in, FILE *out) {
  char *line = 0;
  char *readName, *tmp;
  size_t n;
  int pos;
  tmp = 0;
  while ((!feof(in)) && (getline(&line, &n, in) != -1)) {
    if (tmp) {
      free(tmp);
      tmp = 0;
    }
    tmp = strdup(line);
    char *found = strchr(line, '\t');
    pos = (found - line);
    split_field(tmp, pos);
    fputs(tmp, out);
  }
}


x86 assembly (clang, -O0):
<parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x41(%rbp)
jne    11c3 <parse+0x53>
mov    -0x8(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1080 <getline@plt>
cmp    $0xffffffff,%eax
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    11d3 <parse+0x63>
jmp    123a <parse+0xca>
cmpq   $0x0,-0x28(%rbp)
je     11ef <parse+0x7f>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1040 <split_field@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <fputs@plt>
jmp    1190 <parse+0x20>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r13
movq   $0x0,0x8(%rsp)
call   1070 <feof@plt>
test   %eax,%eax
je     11a5 <parse+0x35>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
jmp    1200 <parse+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1090 <strdup@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
sub    %ebp,%eax
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <split_field@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <fputs@plt>
mov    %r13,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    1196 <parse+0x26>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1080 <getline@plt>
cmp    $0xffffffff,%eax
je     1196 <parse+0x26>
test   %rbx,%rbx
je     11c0 <parse+0x50>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11c0 <parse+0x50>

LLVM IR (-O0):
define void @parse(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
store i32* %0, i32** %3
store i32* %1, i32** %4
store i8* null, i8** %5
store i8* null, i8** %7
br label %11
11: ; preds = %27, %2
%12 = load i32*, i32** %3
%13 = call i32 @feof(i32* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i32*, i32** %3
%17 = call i32 @getline(i8** %5, i64* %8, i32* %16)
%18 = icmp ne i32 %17, -1
br label %19
19: ; preds = %15, %11
%20 = phi i1 [ false, %11 ], [ %18, %15 ]
br i1 %20, label %21, label %44
21: ; preds = %19
%22 = load i8*, i8** %7
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i8*, i8** %7
%26 = call i32 @free(i8* %25)
store i8* null, i8** %7
br label %27
27: ; preds = %24, %21
%28 = load i8*, i8** %5
%29 = call i8* @strdup(i8* %28)
store i8* %29, i8** %7
%30 = load i8*, i8** %5
%31 = call i8* @strchr(i8* %30, i8 signext 9)
store i8* %31, i8** %10
%32 = load i8*, i8** %10
%33 = load i8*, i8** %5
%34 = ptrtoint i8* %32 to i64
%35 = ptrtoint i8* %33 to i64
%36 = sub i64 %34, %35
%37 = trunc i64 %36 to i32
store i32 %37, i32* %9
%38 = load i8*, i8** %7
%39 = load i32, i32* %9
%40 = call i32 @split_field(i8* %38, i32 %39)
%41 = load i8*, i8** %7
%42 = load i32*, i32** %4
%43 = call i32 @fputs(i8* %41, i32* %42)
br label %11
44: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @parse(i32* %0, i32* nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
%7 = call i32 @feof(i32* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %29
9: ; preds = %2, %17
%10 = phi i8* [ %19, %17 ], [ null, %2 ]
%11 = call i32 @getline(i8** %3, i64* %4, i32* %0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %29, label %13
13: ; preds = %9
%14 = icmp eq i8* %10, null
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = call i32 @free(i8* %10)
br label %17
17: ; preds = %15, %13
%18 = load i8*, i8** %3
%19 = call i8* @strdup(i8* %18)
%20 = call i8* @strchr(i8* dereferenceable(1) %18, i8 signext 9)
%21 = ptrtoint i8* %20 to i64
%22 = ptrtoint i8* %18 to i64
%23 = sub i64 %21, %22
%24 = trunc i64 %23 to i32
%25 = call i32 @split_field(i8* %19, i32 %24)
%26 = call i32 @fputs(i8* %19, i32* %1)
%27 = call i32 @feof(i32* %0)
%28 = icmp eq i32 %27, 0
br i1 %28, label %9, label %29
29: ; preds = %9, %17, %2
ret void
}