#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 mode_t;

/* Variables and functions */
int /*<<< orphan*/ O_CREAT;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWUSR;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ free(char **);
scalar_t__ ft_memalloc(int);
scalar_t__ ft_strlen(char *);
int /*<<< orphan*/ get_next_line(int, char **);
int open(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, char *);
int main(int argc, char **argv) {
  int i = 400;
  assert(argc > 0);
  char *path = *(argv + 1);
  mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
  int fd = open(path, O_CREAT, mode);
  if (fd == -1) {
    perror("open");
    return 1;
  }
  char **line = (char **)ft_memalloc(1);
  int j = 1;
  while (i--) {
    if (!line)
      line = (char **)ft_memalloc(1);
    get_next_line(fd, line);
    static size_t t;
    t += ft_strlen(*line);
    printf("Read Number %d: %s\n", j++, *line);
  }
  free(line);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x190,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2df7(%rip),%rax
mov    (%rax),%eax
mov    0x2e0e(%rip),%rcx
or     (%rcx),%eax
mov    0x2df5(%rip),%rcx
or     (%rcx),%eax
mov    0x2e04(%rip),%rcx
or     (%rcx),%eax
mov    0x2ddb(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
mov    -0x24(%rbp),%edx
call   1080 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1224 <main+0xa4>
lea    0xded(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12bf <main+0x13f>
mov    $0x1,%edi
call   1070 <ft_memalloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     12af <main+0x12f>
cmpq   $0x0,-0x30(%rbp)
jne    1266 <main+0xe6>
mov    $0x1,%edi
call   1070 <ft_memalloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   10a0 <get_next_line@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
call   1040 <ft_strlen@plt>
add    0x2dfb(%rip),%rax
mov    %rax,0x2df4(%rip)
mov    -0x34(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rdx
lea    0xd60(%rip),%rdi
call   1050 <printf@plt>
jmp    1239 <main+0xb9>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
xor    %eax,%eax
test   %edi,%edi
setg   %al
mov    %eax,%edi
call   1060 <assert@plt>
mov    0x2e18(%rip),%rax
mov    0x2e31(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x8(%rbx),%rdi
mov    0x2e12(%rip),%rax
or     (%rax),%edx
mov    0x2e21(%rip),%rax
or     (%rax),%edx
mov    0x2df8(%rip),%rax
or     (%rax),%edx
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     125d <main+0xdd>
mov    %eax,%r15d
mov    $0x1,%ebx
mov    $0x1,%edi
call   1070 <ft_memalloc@plt>
mov    %rax,%r12
lea    0xe08(%rip),%r14
jmp    1236 <main+0xb6>
nop
mov    %r15d,%edi
mov    %r12,%rsi
call   10a0 <get_next_line@plt>
mov    (%r12),%rdi
call   1040 <ft_strlen@plt>
add    %rax,0x2e65(%rip)
lea    0x1(%rbx),%ebp
mov    (%r12),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    %ebp,%ebx
cmp    $0x191,%ebp
je     124a <main+0xca>
test   %r12,%r12
jne    1200 <main+0x80>
mov    $0x1,%edi
call   1070 <ft_memalloc@plt>
mov    %rax,%r12
jmp    1200 <main+0x80>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd9c(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%eax
jmp    1254 <main+0xd4>

LLVM IR (-O0):
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@O_CREAT = global i32 0
@.str = [5 x i8] c"open\00"
@main.t = internal global i64 0
@.str.1 = [20 x i8] c"Read Number %d: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 400, i32* %6
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %7
%19 = load i32, i32* @S_IRUSR
%20 = load i32, i32* @S_IWUSR
%21 = or i32 %19, %20
%22 = load i32, i32* @S_IRGRP
%23 = or i32 %21, %22
%24 = load i32, i32* @S_IWGRP
%25 = or i32 %23, %24
%26 = load i32, i32* @S_IROTH
%27 = or i32 %25, %26
store i32 %27, i32* %8
%28 = load i8*, i8** %7
%29 = load i32, i32* @O_CREAT
%30 = load i32, i32* %8
%31 = call i32 @open(i8* %28, i32 %29, i32 %30)
store i32 %31, i32* %9
%32 = load i32, i32* %9
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %36
34: ; preds = %2
%35 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %66
36: ; preds = %2
%37 = call i64 @ft_memalloc(i32 1)
%38 = inttoptr i64 %37 to i8**
store i8** %38, i8*** %10
store i32 1, i32* %11
br label %39
39: ; preds = %49, %36
%40 = load i32, i32* %6
%41 = add nsw i32 %40, -1
store i32 %41, i32* %6
%42 = icmp ne i32 %40, 0
br i1 %42, label %43, label %63
43: ; preds = %39
%44 = load i8**, i8*** %10
%45 = icmp ne i8** %44, null
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = call i64 @ft_memalloc(i32 1)
%48 = inttoptr i64 %47 to i8**
store i8** %48, i8*** %10
br label %49
49: ; preds = %46, %43
%50 = load i32, i32* %9
%51 = load i8**, i8*** %10
%52 = call i32 @get_next_line(i32 %50, i8** %51)
%53 = load i8**, i8*** %10
%54 = load i8*, i8** %53
%55 = call i64 @ft_strlen(i8* %54)
%56 = load i64, i64* @main.t
%57 = add i64 %56, %55
store i64 %57, i64* @main.t
%58 = load i32, i32* %11
%59 = add nsw i32 %58, 1
store i32 %59, i32* %11
%60 = load i8**, i8*** %10
%61 = load i8*, i8** %60
%62 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %58, i8* %61)
br label %39
63: ; preds = %39
%64 = load i8**, i8*** %10
%65 = call i32 @free(i8** %64)
store i32 0, i32* %3
br label %66
66: ; preds = %63, %34
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IROTH = global i32 0
@O_CREAT = global i32 0
@.str = [5 x i8] c"open\00"
@main.t = internal unnamed_addr global i64 0
@.str.1 = [20 x i8] c"Read Number %d: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = load i32, i32* @S_IRUSR
%9 = load i32, i32* @S_IWUSR
%10 = or i32 %9, %8
%11 = load i32, i32* @S_IRGRP
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IWGRP
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IROTH
%16 = or i32 %14, %15
%17 = load i32, i32* @O_CREAT
%18 = tail call i32 @open(i8* %7, i32 %17, i32 %16)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %47
22: ; preds = %2
%23 = tail call i64 @ft_memalloc(i32 1)
%24 = inttoptr i64 %23 to i8**
br label %25
25: ; preds = %22, %33
%26 = phi i32 [ 399, %22 ], [ %43, %33 ]
%27 = phi i32 [ 1, %22 ], [ %40, %33 ]
%28 = phi i8** [ %24, %22 ], [ %34, %33 ]
%29 = icmp eq i8** %28, null
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = tail call i64 @ft_memalloc(i32 1)
%32 = inttoptr i64 %31 to i8**
br label %33
33: ; preds = %30, %25
%34 = phi i8** [ %28, %25 ], [ %32, %30 ]
%35 = tail call i32 @get_next_line(i32 %18, i8** %34)
%36 = load i8*, i8** %34
%37 = tail call i64 @ft_strlen(i8* %36)
%38 = load i64, i64* @main.t
%39 = add i64 %38, %37
store i64 %39, i64* @main.t
%40 = add nuw nsw i32 %27, 1
%41 = load i8*, i8** %34
%42 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %27, i8* %41)
%43 = add nsw i32 %26, -1
%44 = icmp eq i32 %26, 0
br i1 %44, label %45, label %25
45: ; preds = %33
%46 = tail call i32 @free(i8** %34)
br label %47
47: ; preds = %45, %20
%48 = phi i32 [ 1, %20 ], [ 0, %45 ]
ret i32 %48
}