#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*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ ltrim(char *);
char *save_realloc(char *, char *, int, char *, int);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int get_a_line(FILE *fp, char line[], int n) {
  static char *line0 = NULL;
  static int nalloc = 0;
  char *dum;
  if (n > nalloc) {
    nalloc = n;
    (line0) =
        save_realloc("line0",
                     "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/Chadi-akel/cere/refs/"
                     "heads/master/tests/test_07/strdb.c",
                     49, (line0), (nalloc + 1) * sizeof(*(line0)));
  }
  do {
    if (!fgets(line0, n + 1, fp)) {
      return 0;
    }
    dum = strchr(line0, '\n');
    if (dum)
      dum[0] = '\0';
    else if (strlen(line0) == n) {
      fprintf(stderr,
              "Warning: line length exceeds buffer length (%d), data might be "
              "corrupted\n",
              n);
      line0[n - 1] = '\0';
    } else
      fprintf(stderr,
              "Warning: file does not end with a newline, last line:\n%s\n",
              line0);
    dum = strchr(line0, ';');
    if (dum)
      dum[0] = '\0';
    strcpy(line, line0);
    dum = line0;
    ltrim(dum);
  } while (dum[0] == '\0');
  return 1;
}


x86 assembly (clang, -O0):
<get_a_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    0x2edc(%rip),%eax
jle    11d3 <get_a_line+0x63>
mov    -0x1c(%rbp),%eax
mov    %eax,0x2ecd(%rip)
mov    0x2ebe(%rip),%rcx
mov    0x2ec0(%rip),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%r8d
lea    0xe45(%rip),%rdi
lea    0xe44(%rip),%rsi
mov    $0x31,%edx
call   1060 <save_realloc@plt>
mov    %rax,0x2e8d(%rip)
jmp    11d8 <get_a_line+0x68>
mov    0x2e81(%rip),%rdi
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%rdx
call   1070 <fgets@plt>
cmp    $0x0,%eax
jne    1203 <get_a_line+0x93>
movl   $0x0,-0x4(%rbp)
jmp    12fc <get_a_line+0x18c>
mov    0x2e56(%rip),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     122f <get_a_line+0xbf>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
jmp    129a <get_a_line+0x12a>
mov    0x2e2a(%rip),%rdi
call   1040 <strlen@plt>
cmp    -0x1c(%rbp),%eax
jne    1277 <get_a_line+0x107>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2dfb(%rip),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1295 <get_a_line+0x125>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
mov    0x2dd9(%rip),%rdx
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    129a <get_a_line+0x12a>
mov    0x2dbf(%rip),%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12c1 <get_a_line+0x151>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    0x2d94(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x2d88(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <ltrim@plt>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d8 <get_a_line+0x68>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_a_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
cmp    %edx,0x2ede(%rip)
jge    11c2 <get_a_line+0x52>
mov    %r14d,0x2ed5(%rip)
mov    0x2ec6(%rip),%rcx
lea    0x1(%r14),%ebp
lea    0xe5b(%rip),%rdi
lea    0xe5a(%rip),%rsi
mov    $0x31,%edx
mov    %ebp,%r8d
call   1060 <save_realloc@plt>
mov    %rax,0x2ea0(%rip)
jmp    11c6 <get_a_line+0x56>
lea    0x1(%r14),%ebp
movslq %r14d,%rax
mov    %rax,(%rsp)
jmp    11f3 <get_a_line+0x83>
nop
mov    %r15,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    0x2e7e(%rip),%rbx
mov    %rbx,%rdi
call   1090 <ltrim@plt>
cmpb   $0x0,(%rbx)
jne    12ae <get_a_line+0x13e>
mov    0x2e66(%rip),%rdi
mov    %ebp,%esi
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %eax,%eax
je     12b5 <get_a_line+0x145>
mov    0x2e4d(%rip),%r13
mov    %r13,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1230 <get_a_line+0xc0>
movb   $0x0,(%rax)
jmp    1290 <get_a_line+0x120>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    0x2da1(%rip),%rcx
mov    (%rcx),%edi
cmp    %r14d,%eax
jne    126a <get_a_line+0xfa>
lea    0xe4b(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2e02(%rip),%r13
mov    (%rsp),%rax
movb   $0x0,-0x1(%r13,%rax,1)
jmp    1290 <get_a_line+0x120>
mov    0x2def(%rip),%rdx
lea    0xe6a(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2dda(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x3b,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     11d0 <get_a_line+0x60>
movb   $0x0,(%rax)
jmp    11d0 <get_a_line+0x60>
mov    $0x1,%eax
jmp    12b7 <get_a_line+0x147>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@get_a_line.line0 = internal global i8* null
@get_a_line.nalloc = internal global i32 0
@.str = [6 x i8] c"line0\00"
@.str.1 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Chadi-akel/cere/refs/heads/master/tests/test_07/strdb.c\00"
@stderr = global i32 0
@.str.2 = [74 x i8] c"Warning: line length exceeds buffer length (%d), data might be corrupted\0A\00"
@.str.3 = [58 x i8] c"Warning: file does not end with a newline, last line:\0A%s\0A\00"
define i32 @get_a_line(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i32, i32* %7
%10 = load i32, i32* @get_a_line.nalloc
%11 = icmp sgt i32 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %3
%13 = load i32, i32* %7
store i32 %13, i32* @get_a_line.nalloc
%14 = load i8*, i8** @get_a_line.line0
%15 = load i32, i32* @get_a_line.nalloc
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 1
%19 = trunc i64 %18 to i32
%20 = call i8* @save_realloc(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 49, i8* %14, i32 %19)
store i8* %20, i8** @get_a_line.line0
br label %21
21: ; preds = %12, %3
br label %22
22: ; preds = %72, %21
%23 = load i8*, i8** @get_a_line.line0
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
%26 = load i32*, i32** %5
%27 = call i32 @fgets(i8* %23, i32 %25, i32* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %22
store i32 0, i32* %4
br label %79
30: ; preds = %22
%31 = load i8*, i8** @get_a_line.line0
%32 = call i8* @strchr(i8* %31, i8 signext 10)
store i8* %32, i8** %8
%33 = load i8*, i8** %8
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = load i8*, i8** %8
%37 = getelementptr inbounds i8, i8* %36, i64 0
store i8 0, i8* %37
br label %57
38: ; preds = %30
%39 = load i8*, i8** @get_a_line.line0
%40 = call i32 @strlen(i8* %39)
%41 = load i32, i32* %7
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %52
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = load i32, i32* %7
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = load i8*, i8** @get_a_line.line0
%48 = load i32, i32* %7
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
store i8 0, i8* %51
br label %56
52: ; preds = %38
%53 = load i32, i32* @stderr
%54 = load i8*, i8** @get_a_line.line0
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %52, %43
br label %57
57: ; preds = %56, %35
%58 = load i8*, i8** @get_a_line.line0
%59 = call i8* @strchr(i8* %58, i8 signext 59)
store i8* %59, i8** %8
%60 = load i8*, i8** %8
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = load i8*, i8** %8
%64 = getelementptr inbounds i8, i8* %63, i64 0
store i8 0, i8* %64
br label %65
65: ; preds = %62, %57
%66 = load i8*, i8** %6
%67 = load i8*, i8** @get_a_line.line0
%68 = call i32 @strcpy(i8* %66, i8* %67)
%69 = load i8*, i8** @get_a_line.line0
store i8* %69, i8** %8
%70 = load i8*, i8** %8
%71 = call i32 @ltrim(i8* %70)
br label %72
72: ; preds = %65
%73 = load i8*, i8** %8
%74 = getelementptr inbounds i8, i8* %73, i64 0
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 0
br i1 %77, label %22, label %78
78: ; preds = %72
store i32 1, i32* %4
br label %79
79: ; preds = %78, %29
%80 = load i32, i32* %4
ret i32 %80
}

LLVM IR (-O2):
@get_a_line.line0 = internal unnamed_addr global i8* null
@get_a_line.nalloc = internal unnamed_addr global i32 0
@.str = [6 x i8] c"line0\00"
@.str.1 = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Chadi-akel/cere/refs/heads/master/tests/test_07/strdb.c\00"
@stderr = global i32 0
@.str.2 = [74 x i8] c"Warning: line length exceeds buffer length (%d), data might be corrupted\0A\00"
@.str.3 = [58 x i8] c"Warning: file does not end with a newline, last line:\0A%s\0A\00"
define i32 @get_a_line(i32* nocapture %0, i8* %1, i32 %2) {
%4 = load i32, i32* @get_a_line.nalloc
%5 = icmp slt i32 %4, %2
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = add nsw i32 %2, 1
br label %12
8: ; preds = %3
store i32 %2, i32* @get_a_line.nalloc
%9 = load i8*, i8** @get_a_line.line0
%10 = add nsw i32 %2, 1
%11 = tail call i8* @save_realloc(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i32 49, i8* %9, i32 %10)
store i8* %11, i8** @get_a_line.line0
br label %12
12: ; preds = %6, %8
%13 = phi i32 [ %7, %6 ], [ %10, %8 ]
%14 = add nsw i32 %2, -1
%15 = sext i32 %14 to i64
br label %16
16: ; preds = %42, %12
%17 = load i8*, i8** @get_a_line.line0
%18 = tail call i32 @fgets(i8* %17, i32 %13, i32* %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %48, label %20
20: ; preds = %16
%21 = load i8*, i8** @get_a_line.line0
%22 = tail call i8* @strchr(i8* dereferenceable(1) %21, i8 signext 10)
%23 = icmp eq i8* %22, null
br i1 %23, label %25, label %24
24: ; preds = %20
store i8 0, i8* %22
br label %37
25: ; preds = %20
%26 = tail call i32 @strlen(i8* %21)
%27 = icmp eq i32 %26, %2
%28 = load i32, i32* @stderr
br i1 %27, label %29, label %33
29: ; preds = %25
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%31 = load i8*, i8** @get_a_line.line0
%32 = getelementptr inbounds i8, i8* %31, i64 %15
store i8 0, i8* %32
br label %37
33: ; preds = %25
%34 = load i8*, i8** @get_a_line.line0
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** @get_a_line.line0
br label %37
37: ; preds = %29, %33, %24
%38 = phi i8* [ %31, %29 ], [ %36, %33 ], [ %21, %24 ]
%39 = tail call i8* @strchr(i8* dereferenceable(1) %38, i8 signext 59)
%40 = icmp eq i8* %39, null
br i1 %40, label %42, label %41
41: ; preds = %37
store i8 0, i8* %39
br label %42
42: ; preds = %41, %37
%43 = tail call i32 @strcpy(i8* %1, i8* %38)
%44 = load i8*, i8** @get_a_line.line0
%45 = tail call i32 @ltrim(i8* %44)
%46 = load i8, i8* %44
%47 = icmp eq i8 %46, 0
br i1 %47, label %16, label %48
48: ; preds = %42, %16
%49 = phi i32 [ 0, %16 ], [ 1, %42 ]
ret i32 %49
}