#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 */
#define EOF 128
char *do_nofail(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ free(char *);
int getc_unlocked(int /*<<< orphan*/ *);
int /*<<< orphan*/ malloc(int);
int /*<<< orphan*/ realloc(char *, int);
char *getline_wrapped(FILE *file, unsigned int *linenum) {
  int size = 256;
  int i = 0;
  char *buf = do_nofail(
      (malloc(size)),
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/Distrotech/module-init-tools/refs/heads/"
      "master/usermode/module-init-tools-3.12/util.c",
      26, "malloc(size)");
  for (;;) {
    int ch = getc_unlocked(file);
    switch (ch) {
    case EOF:
      if (i == 0) {
        free(buf);
        return NULL;
      }
    case '\n':
      if (linenum)
        (*linenum)++;
      if (i == size)
        buf = do_nofail(
            (realloc(buf, size + 1)),
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/Distrotech/module-init-tools/refs/heads/"
            "master/usermode/module-init-tools-3.12/util.c",
            42, "realloc(buf, size + 1)");
      buf[i] = '\0';
      return buf;
    case '\\':
      ch = getc_unlocked(file);
      if (ch == '\n') {
        if (linenum)
          (*linenum)++;
        continue;
      }
    default:
      buf[i++] = ch;
      if (i == size) {
        size *= 2;
        buf = do_nofail(
            (realloc(buf, size)),
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/Distrotech/module-init-tools/refs/heads/"
            "master/usermode/module-init-tools-3.12/util.c",
            61, "realloc(buf, size)");
      }
    }
  }
}


x86 assembly (clang, -O0):
<getline_wrapped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x100,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <malloc@plt>
mov    %eax,%edi
lea    0xe81(%rip),%rsi
mov    $0x1a,%edx
lea    0xf25(%rip),%rcx
call   1070 <do_nofail@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <getc_unlocked@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0xa,%eax
je     11fd <getline_wrapped+0xad>
jmp    11b4 <getline_wrapped+0x64>
mov    -0x30(%rbp),%eax
sub    $0x5c,%eax
je     1265 <getline_wrapped+0x115>
jmp    11c5 <getline_wrapped+0x75>
mov    -0x30(%rbp),%eax
sub    $0x80,%eax
jne    129b <getline_wrapped+0x14b>
jmp    11d8 <getline_wrapped+0x88>
cmpl   $0x0,-0x20(%rbp)
jne    11f8 <getline_wrapped+0xa8>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    12fe <getline_wrapped+0x1ae>
jmp    11fd <getline_wrapped+0xad>
cmpq   $0x0,-0x18(%rbp)
je     1213 <getline_wrapped+0xc3>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    124c <getline_wrapped+0xfc>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
call   1060 <realloc@plt>
mov    %eax,%edi
lea    0xdc9(%rip),%rsi
mov    $0x2a,%edx
lea    0xe7a(%rip),%rcx
call   1070 <do_nofail@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12fe <getline_wrapped+0x1ae>
mov    -0x10(%rbp),%rdi
call   1040 <getc_unlocked@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xa,-0x2c(%rbp)
jne    1296 <getline_wrapped+0x146>
cmpq   $0x0,-0x18(%rbp)
je     1291 <getline_wrapped+0x141>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1194 <getline_wrapped+0x44>
jmp    129b <getline_wrapped+0x14b>
mov    -0x2c(%rbp),%eax
mov    %al,%dl
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x20(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    12f4 <getline_wrapped+0x1a4>
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <realloc@plt>
mov    %eax,%edi
lea    0xd21(%rip),%rsi
mov    $0x3d,%edx
lea    0xde9(%rip),%rcx
call   1070 <do_nofail@plt>
mov    %rax,-0x28(%rbp)
jmp    12f9 <getline_wrapped+0x1a9>
jmp    1194 <getline_wrapped+0x44>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getline_wrapped>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x100,%ebp
mov    $0x100,%edi
call   1050 <malloc@plt>
lea    0xe89(%rip),%rsi
lea    0xf32(%rip),%rcx
mov    %eax,%edi
mov    $0x1a,%edx
call   1070 <do_nofail@plt>
mov    %rax,%r14
xor    %r12d,%r12d
mov    %r12d,%r13d
mov    %ebp,%r12d
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <getc_unlocked@plt>
cmp    $0x5c,%eax
jne    11c5 <getline_wrapped+0x75>
mov    %rbx,%rdi
call   1040 <getc_unlocked@plt>
cmp    $0xa,%eax
jne    11d1 <getline_wrapped+0x81>
test   %r15,%r15
je     11a0 <getline_wrapped+0x50>
addl   $0x1,(%r15)
jmp    11a0 <getline_wrapped+0x50>
cmp    $0xa,%eax
je     1213 <getline_wrapped+0xc3>
cmp    $0x80,%eax
je     120e <getline_wrapped+0xbe>
movslq %r13d,%rcx
add    $0x1,%r13d
mov    %al,(%r14,%rcx,1)
cmp    %r12d,%r13d
jne    11a0 <getline_wrapped+0x50>
lea    (%r12,%r12,1),%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1060 <realloc@plt>
mov    %eax,%edi
lea    0xe08(%rip),%rsi
mov    $0x3d,%edx
lea    0xed0(%rip),%rcx
call   1070 <do_nofail@plt>
mov    %rax,%r14
jmp    1190 <getline_wrapped+0x40>
test   %r13d,%r13d
je     1267 <getline_wrapped+0x117>
test   %r15,%r15
je     121c <getline_wrapped+0xcc>
addl   $0x1,(%r15)
cmp    %r12d,%r13d
jne    124d <getline_wrapped+0xfd>
or     $0x1,%r12d
mov    %r14,%rdi
mov    %r12d,%esi
call   1060 <realloc@plt>
lea    0xdc9(%rip),%rsi
lea    0xe7f(%rip),%rcx
mov    %eax,%edi
mov    $0x2a,%edx
call   1070 <do_nofail@plt>
mov    %rax,%r14
movslq %r13d,%rax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
call   1030 <free@plt>
xor    %r14d,%r14d
jmp    1255 <getline_wrapped+0x105>

LLVM IR (-O0):
@.str = [176 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Distrotech/module-init-tools/refs/heads/master/usermode/module-init-tools-3.12/util.c\00"
@.str.1 = [13 x i8] c"malloc(size)\00"
@.str.2 = [23 x i8] c"realloc(buf, size + 1)\00"
@.str.3 = [19 x i8] c"realloc(buf, size)\00"
define i8* @getline_wrapped(i32* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 256, i32* %6
store i32 0, i32* %7
%10 = load i32, i32* %6
%11 = call i32 @malloc(i32 %10)
%12 = call i8* @do_nofail(i32 %11, i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i8* %12, i8** %8
br label %13
13: ; preds = %80, %59, %2
%14 = load i32*, i32** %4
%15 = call i32 @getc_unlocked(i32* %14)
store i32 %15, i32* %9
%16 = load i32, i32* %9
switch i32 %16, label %61 [
i32 128, label %17
i32 10, label %24
i32 92, label %47
]
17: ; preds = %13
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i8*, i8** %8
%22 = call i32 @free(i8* %21)
store i8* null, i8** %3
br label %81
23: ; preds = %17
br label %24
24: ; preds = %13, %23
%25 = load i32*, i32** %5
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32*, i32** %5
%29 = load i32, i32* %28
%30 = add i32 %29, 1
store i32 %30, i32* %28
br label %31
31: ; preds = %27, %24
%32 = load i32, i32* %7
%33 = load i32, i32* %6
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = load i8*, i8** %8
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
%39 = call i32 @realloc(i8* %36, i32 %38)
%40 = call i8* @do_nofail(i32 %39, i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i8* %40, i8** %8
br label %41
41: ; preds = %35, %31
%42 = load i8*, i8** %8
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 0, i8* %45
%46 = load i8*, i8** %8
store i8* %46, i8** %3
br label %81
47: ; preds = %13
%48 = load i32*, i32** %4
%49 = call i32 @getc_unlocked(i32* %48)
store i32 %49, i32* %9
%50 = load i32, i32* %9
%51 = icmp eq i32 %50, 10
br i1 %51, label %52, label %60
52: ; preds = %47
%53 = load i32*, i32** %5
%54 = icmp ne i32* %53, null
br i1 %54, label %55, label %59
55: ; preds = %52
%56 = load i32*, i32** %5
%57 = load i32, i32* %56
%58 = add i32 %57, 1
store i32 %58, i32* %56
br label %59
59: ; preds = %55, %52
br label %13
60: ; preds = %47
br label %61
61: ; preds = %13, %60
%62 = load i32, i32* %9
%63 = trunc i32 %62 to i8
%64 = load i8*, i8** %8
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
%67 = sext i32 %65 to i64
%68 = getelementptr inbounds i8, i8* %64, i64 %67
store i8 %63, i8* %68
%69 = load i32, i32* %7
%70 = load i32, i32* %6
%71 = icmp eq i32 %69, %70
br i1 %71, label %72, label %79
72: ; preds = %61
%73 = load i32, i32* %6
%74 = mul nsw i32 %73, 2
store i32 %74, i32* %6
%75 = load i8*, i8** %8
%76 = load i32, i32* %6
%77 = call i32 @realloc(i8* %75, i32 %76)
%78 = call i8* @do_nofail(i32 %77, i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 61, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
store i8* %78, i8** %8
br label %79
79: ; preds = %72, %61
br label %80
80: ; preds = %79
br label %13
81: ; preds = %41, %20
%82 = load i8*, i8** %3
ret i8* %82
}

LLVM IR (-O2):
@.str = [176 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Distrotech/module-init-tools/refs/heads/master/usermode/module-init-tools-3.12/util.c\00"
@.str.1 = [13 x i8] c"malloc(size)\00"
@.str.2 = [23 x i8] c"realloc(buf, size + 1)\00"
@.str.3 = [19 x i8] c"realloc(buf, size)\00"
define i8* @getline_wrapped(i32* nocapture %0, i32* %1) {
%3 = tail call i32 @malloc(i32 256)
%4 = tail call i8* @do_nofail(i32 %3, i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %1, null
br label %6
6: ; preds = %47, %2
%7 = phi i32 [ %48, %47 ], [ 256, %2 ]
%8 = phi i32 [ %7, %47 ], [ 0, %2 ]
%9 = phi i8* [ %50, %47 ], [ %4, %2 ]
br label %10
10: ; preds = %6, %40
%11 = phi i32 [ %8, %6 ], [ %43, %40 ]
br label %12
12: ; preds = %36, %10
%13 = tail call i32 @getc_unlocked(i32* %0)
switch i32 %13, label %40 [
i32 128, label %14
i32 10, label %18
i32 92, label %32
]
14: ; preds = %12
%15 = icmp eq i32 %11, 0
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 @free(i8* %9)
br label %51
18: ; preds = %12, %14
br i1 %5, label %22, label %19
19: ; preds = %18
%20 = load i32, i32* %1
%21 = add i32 %20, 1
store i32 %21, i32* %1
br label %22
22: ; preds = %19, %18
%23 = icmp eq i32 %11, %7
br i1 %23, label %24, label %28
24: ; preds = %22
%25 = or i32 %7, 1
%26 = tail call i32 @realloc(i8* %9, i32 %25)
%27 = tail call i8* @do_nofail(i32 %26, i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %24, %22
%29 = phi i8* [ %27, %24 ], [ %9, %22 ]
%30 = sext i32 %11 to i64
%31 = getelementptr inbounds i8, i8* %29, i64 %30
store i8 0, i8* %31
br label %51
32: ; preds = %12
%33 = tail call i32 @getc_unlocked(i32* %0)
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %40
35: ; preds = %32
br i1 %5, label %36, label %37
36: ; preds = %35, %37
br label %12
37: ; preds = %35
%38 = load i32, i32* %1
%39 = add i32 %38, 1
store i32 %39, i32* %1
br label %36
40: ; preds = %32, %12
%41 = phi i32 [ %13, %12 ], [ %33, %32 ]
%42 = trunc i32 %41 to i8
%43 = add nsw i32 %11, 1
%44 = sext i32 %11 to i64
%45 = getelementptr inbounds i8, i8* %9, i64 %44
store i8 %42, i8* %45
%46 = icmp eq i32 %43, %7
br i1 %46, label %47, label %10
47: ; preds = %40
%48 = shl nsw i32 %7, 1
%49 = tail call i32 @realloc(i8* %9, i32 %48)
%50 = tail call i8* @do_nofail(i32 %49, i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 61, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %6
51: ; preds = %28, %16
%52 = phi i8* [ null, %16 ], [ %29, %28 ]
ret i8* %52
}