#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*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ free(char *);
char *get_chrom(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *pick_file(char *);
char *strdup(char *);
void parse(FILE *in) {
  char *line = 0;
  char *tmp, *chrom;
  size_t n;
  FILE *outfile;
  tmp = 0;
  while (!(feof(in)) && (getline(&line, &n, in) != -1)) {
    if (tmp) {
      free(tmp);
      tmp = 0;
    }
    tmp = strdup(line);
    chrom = get_chrom(tmp);
    outfile = pick_file(chrom);
    if (!outfile)
      continue;
    fprintf(outfile, "%s", line);
  }
}


x86 assembly (clang, -O0):
<parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
jne    11bf <parse+0x4f>
mov    -0x8(%rbp),%rdx
lea    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11cf <parse+0x5f>
jmp    123b <parse+0xcb>
cmpq   $0x0,-0x18(%rbp)
je     11eb <parse+0x7b>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <get_chrom@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <pick_file@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1222 <parse+0xb2>
jmp    118c <parse+0x1c>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xdcf(%rip),%rsi
call   1040 <fprintf@plt>
jmp    118c <parse+0x1c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r12
movq   $0x0,0x8(%rsp)
call   1050 <feof@plt>
test   %eax,%eax
je     119c <parse+0x2c>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
xor    %ebx,%ebx
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%r15
jmp    11bc <parse+0x4c>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    1190 <parse+0x20>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     1190 <parse+0x20>
test   %rbx,%rbx
je     11dc <parse+0x6c>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <get_chrom@plt>
mov    %rax,%rdi
call   1090 <pick_file@plt>
test   %rax,%rax
je     11b0 <parse+0x40>
mov    0x8(%rsp),%rdi
mov    %rax,%rsi
call   1040 <fputs@plt>
jmp    11b0 <parse+0x40>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @parse(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32*
store i32* %0, i32** %2
store i8* null, i8** %3
store i8* null, i8** %4
br label %8
8: ; preds = %34, %33, %1
%9 = load i32*, i32** %2
%10 = call i32 @feof(i32* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i32*, i32** %2
%14 = call i32 @getline(i8** %3, i64* %6, i32* %13)
%15 = icmp ne i32 %14, -1
br label %16
16: ; preds = %12, %8
%17 = phi i1 [ false, %8 ], [ %15, %12 ]
br i1 %17, label %18, label %38
18: ; preds = %16
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %4
%23 = call i32 @free(i8* %22)
store i8* null, i8** %4
br label %24
24: ; preds = %21, %18
%25 = load i8*, i8** %3
%26 = call i8* @strdup(i8* %25)
store i8* %26, i8** %4
%27 = load i8*, i8** %4
%28 = call i8* @get_chrom(i8* %27)
store i8* %28, i8** %5
%29 = load i8*, i8** %5
%30 = call i32* @pick_file(i8* %29)
store i32* %30, i32** %7
%31 = load i32*, i32** %7
%32 = icmp ne i32* %31, null
br i1 %32, label %34, label %33
33: ; preds = %24
br label %8
34: ; preds = %24
%35 = load i32*, i32** %7
%36 = load i8*, i8** %3
%37 = call i32 @fprintf(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %36)
br label %8
38: ; preds = %16
ret void
}

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