#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*/ EXIT_FAILURE;
int /*<<< orphan*/ assert(size_t *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
scalar_t__ isspace(int);
scalar_t__ malloc(int);
scalar_t__ realloc(char *, int);
int /*<<< orphan*/ stderr;
char *readline(FILE *in, size_t *level) {
  assert(level);
  *level = 0UL;
  int c;
  char *p = NULL;
  size_t len = 0UL;
  if (feof(in))
    return NULL;
  p = (char *)malloc(sizeof(char));
  if (p == NULL)
    do {
      fprintf(stderr, "%s: %d : OUT_OF_MEMORY.\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/lindenb/makefile2graph/refs/heads/"
              "master/make2graph.c",
              201);
      exit(EXIT_FAILURE);
    } while (0);
  while ((c = fgetc(in)) != -1 && c != '\n') {
    p = (char *)realloc((char *)p, sizeof(char) * (len + 2));
    if (p == NULL)
      do {
        fprintf(stderr, "%s: %d : OUT_OF_MEMORY.\n",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/lindenb/makefile2graph/refs/"
                "heads/master/make2graph.c",
                205);
        exit(EXIT_FAILURE);
      } while (0);
    if (!(len == 0 && isspace(c))) {
      p[len++] = c;
    } else {
      (*level)++;
    }
  }
  p[len] = 0;
  return p;
}


x86 assembly (clang, -O0):
<readline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     11d4 <readline+0x54>
movq   $0x0,-0x8(%rbp)
jmp    131a <readline+0x19a>
mov    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1221 <readline+0xa1>
jmp    11f2 <readline+0x72>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
lea    0xdfe(%rip),%rsi
lea    0xe10(%rip),%rdx
mov    $0xc9,%ecx
call   1060 <fprintf@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    1226 <readline+0xa6>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x31(%rbp)
je     124c <readline+0xcc>
cmpl   $0xa,-0x1c(%rbp)
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    125c <readline+0xdc>
jmp    1306 <readline+0x186>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rax
add    $0x2,%rax
shl    $0x0,%rax
mov    %eax,%esi
call   1090 <realloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12b6 <readline+0x136>
jmp    1287 <readline+0x107>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xd69(%rip),%rsi
lea    0xd7b(%rip),%rdx
mov    $0xcd,%ecx
call   1060 <fprintf@plt>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
cmpq   $0x0,-0x30(%rbp)
jne    12d3 <readline+0x153>
mov    -0x1c(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
jne    12f3 <readline+0x173>
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x30(%rbp)
mov    %dl,(%rax,%rcx,1)
jmp    1301 <readline+0x181>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1226 <readline+0xa6>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readline>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1050 <assert@plt>
movq   $0x0,(%r14)
mov    %r15,%rdi
call   1070 <feof@plt>
test   %rax,%rax
je     11ae <readline+0x2e>
xor    %ebx,%ebx
jmp    121d <readline+0x9d>
mov    $0x1,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     1258 <readline+0xd8>
mov    %rax,%rbx
xor    %r12d,%r12d
jmp    11d8 <readline+0x58>
nopl   0x0(%rax)
mov    %bpl,(%rbx,%r12,1)
add    $0x1,%r12
mov    %r15,%rdi
call   1030 <fgetc@plt>
cmp    $0xffffffff,%eax
je     1218 <readline+0x98>
mov    %eax,%ebp
cmp    $0xa,%eax
je     1218 <readline+0x98>
lea    0x2(%r12),%esi
mov    %rbx,%rdi
call   1090 <realloc@plt>
test   %rax,%rax
je     1229 <readline+0xa9>
mov    %rax,%rbx
test   %r12,%r12
jne    11d0 <readline+0x50>
mov    %ebp,%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     11d0 <readline+0x50>
addq   $0x1,(%r14)
jmp    11c4 <readline+0x44>
movb   $0x0,(%rbx,%r12,1)
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xdc7(%rip),%rsi
lea    0xdd9(%rip),%rdx
mov    $0xcd,%ecx
call   1060 <fprintf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
lea    0xd98(%rip),%rsi
lea    0xdaa(%rip),%rdx
mov    $0xc9,%ecx
jmp    1245 <readline+0xc5>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"%s: %d : OUT_OF_MEMORY.\0A\00"
@.str.1 = [144 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lindenb/makefile2graph/refs/heads/master/make2graph.c\00"
@EXIT_FAILURE = global i32 0
define i8* @readline(i32* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i32* %0, i32** %4
store i64* %1, i64** %5
%9 = load i64*, i64** %5
%10 = call i32 @assert(i64* %9)
%11 = load i64*, i64** %5
store i64 0, i64* %11
store i8* null, i8** %7
store i64 0, i64* %8
%12 = load i32*, i32** %4
%13 = call i64 @feof(i32* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %2
store i8* null, i8** %3
br label %79
16: ; preds = %2
%17 = call i64 @malloc(i32 1)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %28
21: ; preds = %16
br label %22
22: ; preds = %21
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.1, i64 0, i64 0), i32 201)
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; No predecessors!
br label %28
28: ; preds = %27, %16
br label %29
29: ; preds = %73, %28
%30 = load i32*, i32** %4
%31 = call i32 @fgetc(i32* %30)
store i32 %31, i32* %6
%32 = icmp ne i32 %31, -1
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* %6
%35 = icmp ne i32 %34, 10
br label %36
36: ; preds = %33, %29
%37 = phi i1 [ false, %29 ], [ %35, %33 ]
br i1 %37, label %38, label %74
38: ; preds = %36
%39 = load i8*, i8** %7
%40 = load i64, i64* %8
%41 = add i64 %40, 2
%42 = mul i64 1, %41
%43 = trunc i64 %42 to i32
%44 = call i64 @realloc(i8* %39, i32 %43)
%45 = inttoptr i64 %44 to i8*
store i8* %45, i8** %7
%46 = load i8*, i8** %7
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %55
48: ; preds = %38
br label %49
49: ; preds = %48
%50 = load i32, i32* @stderr
%51 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.1, i64 0, i64 0), i32 205)
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; No predecessors!
br label %55
55: ; preds = %54, %38
%56 = load i64, i64* %8
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = load i32, i32* %6
%60 = call i64 @isspace(i32 %59)
%61 = icmp ne i64 %60, 0
br i1 %61, label %69, label %62
62: ; preds = %58, %55
%63 = load i32, i32* %6
%64 = trunc i32 %63 to i8
%65 = load i8*, i8** %7
%66 = load i64, i64* %8
%67 = add i64 %66, 1
store i64 %67, i64* %8
%68 = getelementptr inbounds i8, i8* %65, i64 %66
store i8 %64, i8* %68
br label %73
69: ; preds = %58
%70 = load i64*, i64** %5
%71 = load i64, i64* %70
%72 = add i64 %71, 1
store i64 %72, i64* %70
br label %73
73: ; preds = %69, %62
br label %29
74: ; preds = %36
%75 = load i8*, i8** %7
%76 = load i64, i64* %8
%77 = getelementptr inbounds i8, i8* %75, i64 %76
store i8 0, i8* %77
%78 = load i8*, i8** %7
store i8* %78, i8** %3
br label %79
79: ; preds = %74, %15
%80 = load i8*, i8** %3
ret i8* %80
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"%s: %d : OUT_OF_MEMORY.\0A\00"
@.str.1 = [144 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lindenb/makefile2graph/refs/heads/master/make2graph.c\00"
@EXIT_FAILURE = global i32 0
define i8* @readline(i32* nocapture %0, i64* %1) {
%3 = tail call i32 @assert(i64* %1)
store i64 0, i64* %1
%4 = tail call i64 @feof(i32* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %47
6: ; preds = %2
%7 = tail call i64 @malloc(i32 1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = inttoptr i64 %7 to i8*
br label %16
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.1, i64 0, i64 0), i32 201)
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %43, %9
%17 = phi i8* [ %10, %9 ], [ %24, %43 ]
%18 = phi i64 [ 0, %9 ], [ %44, %43 ]
%19 = tail call i32 @fgetc(i32* %0)
switch i32 %19, label %20 [
i32 -1, label %45
i32 10, label %45
]
20: ; preds = %16
%21 = trunc i64 %18 to i32
%22 = add i32 %21, 2
%23 = tail call i64 @realloc(i8* %17, i32 %22)
%24 = inttoptr i64 %23 to i8*
%25 = icmp eq i64 %23, 0
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([144 x i8], [144 x i8]* @.str.1, i64 0, i64 0), i32 205)
%29 = load i32, i32* @EXIT_FAILURE
%30 = tail call i32 @exit(i32 %29)
unreachable
31: ; preds = %20
%32 = icmp eq i64 %18, 0
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = tail call i64 @isspace(i32 %19)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33, %31
%37 = trunc i32 %19 to i8
%38 = add i64 %18, 1
%39 = getelementptr inbounds i8, i8* %24, i64 %18
store i8 %37, i8* %39
br label %43
40: ; preds = %33
%41 = load i64, i64* %1
%42 = add i64 %41, 1
store i64 %42, i64* %1
br label %43
43: ; preds = %40, %36
%44 = phi i64 [ 0, %40 ], [ %38, %36 ]
br label %16
45: ; preds = %16, %16
%46 = getelementptr inbounds i8, i8* %17, i64 %18
store i8 0, i8* %46
br label %47
47: ; preds = %2, %45
%48 = phi i8* [ %17, %45 ], [ null, %2 ]
ret i8* %48
}