#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*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
size_t fread(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ realloc(char *, size_t);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fputs("Error - wrong number of argumets", stderr);
    exit(1);
  }
  char *name = argv[1];
  char *buffer = NULL;
  FILE *fp = fopen(name, "r");
  int i, flag = 1;
  if (fp == NULL) {
    fputs("Can't open input file \n", stderr);
    exit(1);
  }
  fseek(fp, 0, SEEK_SET);
  size_t chunk = 25, bytesRead, pos = 0, bufSize = 1;
  do {
    buffer = (char *)realloc(buffer, bufSize);
    bufSize += chunk;
    if (buffer == NULL) {
      fputs("Reading allocating memory\n", stderr);
      exit(1);
    }
    bytesRead = fread(buffer + pos, sizeof(char), chunk, fp);
    for (i = pos; i < bytesRead + pos; ++i) {
      if (buffer[i] == '\n') {
        flag = 0;
        pos = i;
        break;
      }
    }
    if (flag)
      pos += bytesRead;
  } while (flag);
  buffer[pos] = '\0';
  printf("%s\n", buffer);
  free(buffer);
  fclose(fp);
  puts("Done ;)\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11df <main+0x3f>
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
lea    0xe30(%rip),%rdi
call   1080 <fputs@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe23(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1238 <main+0x98>
mov    0x2dc0(%rip),%rax
mov    (%rax),%esi
lea    0xdfa(%rip),%rdi
call   1080 <fputs@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x28(%rbp),%rdi
mov    0x2d95(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
movq   $0x19,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x1,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   10a0 <realloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12ab <main+0x10b>
mov    0x2d4d(%rip),%rax
mov    (%rax),%esi
lea    0xd9f(%rip),%rdi
call   1080 <fputs@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x20(%rbp),%rdi
add    -0x48(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rax
mov    %eax,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
mov    -0x40(%rbp),%rcx
add    -0x48(%rbp),%rcx
cmp    %rcx,%rax
jae    1321 <main+0x181>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    130e <main+0x16e>
movl   $0x0,-0x30(%rbp)
movslq -0x2c(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1321 <main+0x181>
jmp    1313 <main+0x173>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12d0 <main+0x130>
cmpl   $0x0,-0x30(%rbp)
je     1337 <main+0x197>
mov    -0x40(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    133c <main+0x19c>
cmpl   $0x0,-0x30(%rbp)
jne    1264 <main+0xc4>
mov    -0x20(%rbp),%rax
mov    -0x48(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rsi
lea    0xcf9(%rip),%rdi
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fclose@plt>
lea    0xcdf(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    $0x2,%edi
jne    12b0 <main+0x110>
mov    0x8(%rsi),%rdi
lea    0xe64(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12c2 <main+0x122>
mov    %rax,%r14
mov    0x2e03(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    $0x1,%esi
xor    %edi,%edi
call   10a0 <realloc@plt>
test   %rax,%rax
je     129e <main+0xfe>
mov    %rax,%r12
mov    $0x1a,%r15d
xor    %ebx,%ebx
jmp    1227 <main+0x87>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    %r15,%rsi
call   10a0 <realloc@plt>
mov    %rax,%r12
add    $0x19,%r15
test   %rax,%rax
je     129e <main+0xfe>
mov    %rbx,%r13
lea    (%r12,%rbx,1),%rdi
mov    $0x19,%edx
mov    $0x1,%esi
mov    %r14,%rcx
call   1050 <fread@plt>
mov    %rax,%rbx
add    %r13,%rbx
movslq %r13d,%rax
cmp    %rax,%rbx
jbe    1210 <main+0x70>
xchg   %ax,%ax
cmpb   $0xa,(%r12,%rax,1)
je     1262 <main+0xc2>
add    $0x1,%rax
cmp    %rax,%rbx
ja     1250 <main+0xb0>
jmp    1210 <main+0x70>
movb   $0x0,(%r12,%rax,1)
lea    0xde8(%rip),%rdi
mov    %r12,%rsi
call   1070 <printf@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
lea    0xdcd(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    0x2d3b(%rip),%rax
mov    (%rax),%esi
lea    0xd8d(%rip),%rdi
jmp    12d2 <main+0x132>
mov    0x2d29(%rip),%rax
mov    (%rax),%esi
lea    0xd40(%rip),%rdi
jmp    12d2 <main+0x132>
mov    0x2d17(%rip),%rax
mov    (%rax),%esi
lea    0xd51(%rip),%rdi
call   1080 <fputs@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"Error - wrong number of argumets\00"
@stderr = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"Can't open input file \0A\00"
@SEEK_SET = global i32 0
@.str.3 = [27 x i8] c"Reading allocating memory\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [9 x i8] c"Done ;)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %6
store i8* null, i8** %7
%25 = load i8*, i8** %6
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %8
store i32 1, i32* %10
%27 = load i32*, i32** %8
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %33
29: ; preds = %21
%30 = load i32, i32* @stderr
%31 = call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %21
%34 = load i32*, i32** %8
%35 = load i32, i32* @SEEK_SET
%36 = call i32 @fseek(i32* %34, i32 0, i32 %35)
store i64 25, i64* %11
store i64 0, i64* %13
store i64 1, i64* %14
br label %37
37: ; preds = %90, %33
%38 = load i8*, i8** %7
%39 = load i64, i64* %14
%40 = call i64 @realloc(i8* %38, i64 %39)
%41 = inttoptr i64 %40 to i8*
store i8* %41, i8** %7
%42 = load i64, i64* %11
%43 = load i64, i64* %14
%44 = add i64 %43, %42
store i64 %44, i64* %14
%45 = load i8*, i8** %7
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %51
47: ; preds = %37
%48 = load i32, i32* @stderr
%49 = call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %37
%52 = load i8*, i8** %7
%53 = load i64, i64* %13
%54 = getelementptr inbounds i8, i8* %52, i64 %53
%55 = load i64, i64* %11
%56 = load i32*, i32** %8
%57 = call i64 @fread(i8* %54, i32 1, i64 %55, i32* %56)
store i64 %57, i64* %12
%58 = load i64, i64* %13
%59 = trunc i64 %58 to i32
store i32 %59, i32* %9
br label %60
60: ; preds = %79, %51
%61 = load i32, i32* %9
%62 = sext i32 %61 to i64
%63 = load i64, i64* %12
%64 = load i64, i64* %13
%65 = add i64 %63, %64
%66 = icmp ult i64 %62, %65
br i1 %66, label %67, label %82
67: ; preds = %60
%68 = load i8*, i8** %7
%69 = load i32, i32* %9
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 10
br i1 %74, label %75, label %78
75: ; preds = %67
store i32 0, i32* %10
%76 = load i32, i32* %9
%77 = sext i32 %76 to i64
store i64 %77, i64* %13
br label %82
78: ; preds = %67
br label %79
79: ; preds = %78
%80 = load i32, i32* %9
%81 = add nsw i32 %80, 1
store i32 %81, i32* %9
br label %60
82: ; preds = %75, %60
%83 = load i32, i32* %10
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %82
%86 = load i64, i64* %12
%87 = load i64, i64* %13
%88 = add i64 %87, %86
store i64 %88, i64* %13
br label %89
89: ; preds = %85, %82
br label %90
90: ; preds = %89
%91 = load i32, i32* %10
%92 = icmp ne i32 %91, 0
br i1 %92, label %37, label %93
93: ; preds = %90
%94 = load i8*, i8** %7
%95 = load i64, i64* %13
%96 = getelementptr inbounds i8, i8* %94, i64 %95
store i8 0, i8* %96
%97 = load i8*, i8** %7
%98 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %97)
%99 = load i8*, i8** %7
%100 = call i32 @free(i8* %99)
%101 = load i32*, i32** %8
%102 = call i32 @fclose(i32* %101)
%103 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Error - wrong number of argumets\00"
@stderr = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [24 x i8] c"Can't open input file \0A\00"
@SEEK_SET = global i32 0
@.str.3 = [27 x i8] c"Reading allocating memory\0A\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [9 x i8] c"Done ;)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = tail call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %8
%18 = load i32, i32* @SEEK_SET
%19 = tail call i32 @fseek(i32* %11, i32 0, i32 %18)
%20 = tail call i64 @realloc(i8* null, i64 1)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %45, %17
%23 = load i32, i32* @stderr
%24 = tail call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %17, %45
%27 = phi i64 [ %47, %45 ], [ 26, %17 ]
%28 = phi i64 [ %46, %45 ], [ %20, %17 ]
%29 = phi i64 [ %33, %45 ], [ 0, %17 ]
%30 = inttoptr i64 %28 to i8*
%31 = getelementptr inbounds i8, i8* %30, i64 %29
%32 = tail call i64 @fread(i8* %31, i32 1, i64 25, i32* %11)
%33 = add i64 %32, %29
%34 = shl i64 %29, 32
%35 = ashr exact i64 %34, 32
%36 = icmp ugt i64 %33, %35
br i1 %36, label %39, label %45
37: ; preds = %39
%38 = icmp ugt i64 %33, %44
br i1 %38, label %39, label %45
39: ; preds = %26, %37
%40 = phi i64 [ %44, %37 ], [ %35, %26 ]
%41 = getelementptr inbounds i8, i8* %30, i64 %40
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 10
%44 = add i64 %40, 1
br i1 %43, label %49, label %37
45: ; preds = %37, %26
%46 = tail call i64 @realloc(i8* %30, i64 %27)
%47 = add i64 %27, 25
%48 = icmp eq i64 %46, 0
br i1 %48, label %22, label %26
49: ; preds = %39
%50 = inttoptr i64 %28 to i8*
%51 = getelementptr inbounds i8, i8* %50, i64 %40
store i8 0, i8* %51
%52 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %50)
%53 = tail call i32 @free(i8* %50)
%54 = tail call i32 @fclose(i32* %11)
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}