#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*/ fatal(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int in_file(const char *filename, char **P) {
  char *buf, *save;
  FILE *fp, *fopen();
  int lines = 0;
  if ((fp = fopen(filename, "r")) == NULL) {
    fatal("cannot open file");
    return -4;
  }
  buf = (char *)malloc(256 * sizeof(char));
  if (buf == NULL)
    return -1;
  memset(buf, 0, 256);
  while (fgets(buf, 255, fp) != NULL) {
    if (lines >= 15000) {
      fatal("file is to large for diff");
      return -1;
    }
    save = (char *)malloc((strlen(buf) + 1) * sizeof(char));
    if (save == NULL) {
      fatal("not enough room to save the files");
      return -1;
    }
    P[lines++] = save;
    strcpy(save, buf);
  }
  fclose(fp);
  free(buf);
  return (lines);
}


x86 assembly (clang, -O0):
<in_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11dd <in_file+0x4d>
lea    0xe36(%rip),%rdi
call   10b0 <fatal@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    12d7 <in_file+0x147>
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1202 <in_file+0x72>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d7 <in_file+0x147>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0xff,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     12bf <in_file+0x12f>
cmpl   $0x3a98,-0x34(%rbp)
jl     1253 <in_file+0xc3>
lea    0xdd1(%rip),%rdi
call   10b0 <fatal@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d7 <in_file+0x147>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1293 <in_file+0x103>
lea    0xdab(%rip),%rdi
call   10b0 <fatal@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12d7 <in_file+0x147>
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x34(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1212 <in_file+0x82>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<in_file>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
lea    0xe5e(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     125b <in_file+0xcb>
mov    %rax,%r12
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
je     126d <in_file+0xdd>
mov    %rax,%rbx
xor    %ebp,%ebp
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1246 <in_file+0xb6>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
cmp    $0x3a98,%rbp
je     1279 <in_file+0xe9>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     1287 <in_file+0xf7>
mov    %rax,(%r15,%rbp,8)
add    $0x1,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    1200 <in_file+0x70>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%r14d
jmp    126d <in_file+0xdd>
lea    0xda0(%rip),%rdi
call   10b0 <fatal@plt>
mov    $0xfffffffc,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd93(%rip),%rdi
call   10b0 <fatal@plt>
jmp    126d <in_file+0xdd>
lea    0xd9f(%rip),%rdi
call   10b0 <fatal@plt>
jmp    126d <in_file+0xdd>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"cannot open file\00"
@.str.2 = [26 x i8] c"file is to large for diff\00"
@.str.3 = [34 x i8] c"not enough room to save the files\00"
define i32 @in_file(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 0, i32* %9
%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** %8
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @fatal(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 -4, i32* %3
br label %63
15: ; preds = %2
%16 = call i64 @malloc(i32 256)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %3
br label %63
21: ; preds = %15
%22 = load i8*, i8** %6
%23 = call i32 @memset(i8* %22, i32 0, i32 256)
br label %24
24: ; preds = %47, %21
%25 = load i8*, i8** %6
%26 = load i32*, i32** %8
%27 = call i32* @fgets(i8* %25, i32 255, i32* %26)
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %57
29: ; preds = %24
%30 = load i32, i32* %9
%31 = icmp sge i32 %30, 15000
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @fatal(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %63
34: ; preds = %29
%35 = load i8*, i8** %6
%36 = call i32 @strlen(i8* %35)
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = mul i64 %38, 1
%40 = trunc i64 %39 to i32
%41 = call i64 @malloc(i32 %40)
%42 = inttoptr i64 %41 to i8*
store i8* %42, i8** %7
%43 = load i8*, i8** %7
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %47
45: ; preds = %34
%46 = call i32 @fatal(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %63
47: ; preds = %34
%48 = load i8*, i8** %7
%49 = load i8**, i8*** %5
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds i8*, i8** %49, i64 %52
store i8* %48, i8** %53
%54 = load i8*, i8** %7
%55 = load i8*, i8** %6
%56 = call i32 @strcpy(i8* %54, i8* %55)
br label %24
57: ; preds = %24
%58 = load i32*, i32** %8
%59 = call i32 @fclose(i32* %58)
%60 = load i8*, i8** %6
%61 = call i32 @free(i8* %60)
%62 = load i32, i32* %9
store i32 %62, i32* %3
br label %63
63: ; preds = %57, %45, %32, %20, %13
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [17 x i8] c"cannot open file\00"
@.str.2 = [26 x i8] c"file is to large for diff\00"
@.str.3 = [34 x i8] c"not enough room to save the files\00"
define i32 @in_file(i8* nocapture %0, i8** nocapture writeonly %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @fatal(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %40
7: ; preds = %2
%8 = tail call i64 @malloc(i32 256)
%9 = inttoptr i64 %8 to i8*
%10 = icmp eq i64 %8, 0
br i1 %10, label %40, label %11
11: ; preds = %7
%12 = tail call i32 @memset(i8* %9, i32 0, i32 256)
%13 = tail call i32* @fgets(i8* %9, i32 255, i32* %3)
%14 = icmp eq i32* %13, null
br i1 %14, label %36, label %15
15: ; preds = %11, %28
%16 = phi i64 [ %29, %28 ], [ 0, %11 ]
%17 = icmp eq i64 %16, 15000
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @fatal(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %40
20: ; preds = %15
%21 = tail call i32 @strlen(i8* %9)
%22 = add nsw i32 %21, 1
%23 = tail call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i8*
%25 = icmp eq i64 %23, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = tail call i32 @fatal(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %40
28: ; preds = %20
%29 = add nuw nsw i64 %16, 1
%30 = getelementptr inbounds i8*, i8** %1, i64 %16
store i8* %24, i8** %30
%31 = tail call i32 @strcpy(i8* %24, i8* %9)
%32 = tail call i32* @fgets(i8* %9, i32 255, i32* %3)
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %15
34: ; preds = %28
%35 = trunc i64 %29 to i32
br label %36
36: ; preds = %34, %11
%37 = phi i32 [ 0, %11 ], [ %35, %34 ]
%38 = tail call i32 @fclose(i32* %3)
%39 = tail call i32 @free(i8* %9)
br label %40
40: ; preds = %7, %36, %26, %18, %5
%41 = phi i32 [ -4, %5 ], [ -1, %18 ], [ -1, %26 ], [ %37, %36 ], [ -1, %7 ]
ret i32 %41
}