#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*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(void *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  char *line[7];
  char txt[15];
  int i;
  int n;
  if (argc == 1) {
    fprintf(stderr, "Input argument.\n");
    return -1;
  }
  fp = fopen(argv[1], "r");
  if (fp == NULL) {
    fprintf(stderr, "Cannot open file: %s\n", argv[1]);
    return -1;
  }
  for (i = 0; (fgets(txt, 15 - 1, fp) != NULL); i++) {
    line[i] = (char *)malloc(sizeof(char) * (strlen(txt) + 1));
    if (line[i] == NULL) {
      fprintf(stderr, "error!\n");
      return -1;
    }
    strcpy(line[i], txt);
    if (i == 7)
      break;
  }
  n = i;
  for (i = 0; i < n; i++) {
    printf("%s", line[i]);
    free((void *)line[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11c3 <main+0x43>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1311 <main+0x191>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1211 <main+0x91>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1311 <main+0x191>
movl   $0x0,-0x64(%rbp)
lea    -0x5f(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xe,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12c0 <main+0x140>
lea    -0x5f(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
movslq -0x64(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
movslq -0x64(%rbp),%rax
cmpq   $0x0,-0x50(%rbp,%rax,8)
jne    128c <main+0x10c>
mov    0x2d70(%rip),%rax
mov    (%rax),%edi
lea    0xdb0(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1311 <main+0x191>
movslq -0x64(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
lea    -0x5f(%rbp),%rsi
call   1040 <strcpy@plt>
cmpl   $0x7,-0x64(%rbp)
jne    12ad <main+0x12d>
jmp    12c0 <main+0x140>
jmp    12b2 <main+0x132>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1218 <main+0x98>
mov    -0x64(%rbp),%eax
mov    %eax,-0x68(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x68(%rbp),%eax
jge    130a <main+0x18a>
movslq -0x64(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
lea    0xd48(%rip),%rdi
call   1060 <printf@plt>
movslq -0x64(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
call   1030 <free@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    12cd <main+0x14d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
cmp    $0x1,%edi
jne    11b4 <main+0x34>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%r14d
jmp    12b1 <main+0x131>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe4f(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     123e <main+0xbe>
mov    %rax,%r14
lea    0x1(%rsp),%rdi
mov    $0xe,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1239 <main+0xb9>
xor    %r12d,%r12d
lea    0x1(%rsp),%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1090 <malloc@plt>
mov    %rax,0x10(%rsp,%r12,8)
test   %rax,%rax
je     1261 <main+0xe1>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
cmp    $0x7,%r12
je     1276 <main+0xf6>
add    $0x1,%r12
mov    %rbx,%rdi
mov    $0xe,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    11f0 <main+0x70>
test   %r12d,%r12d
jne    127c <main+0xfc>
xor    %r14d,%r14d
jmp    12b1 <main+0x131>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdc1(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%r14d
jmp    12b1 <main+0x131>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
lea    0xdb8(%rip),%rsi
jmp    11a2 <main+0x22>
mov    $0x7,%r12d
xor    %r14d,%r14d
lea    0xdab(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,8),%r13
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <printf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1290 <main+0x110>
mov    %r14d,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"Input argument.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"Cannot open file: %s\0A\00"
@.str.3 = [8 x i8] c"error!\0A\00"
@.str.4 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [7 x i8*]
%8 = alloca [15 x i8]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %90
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %29
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %27)
store i32 -1, i32* %3
br label %90
29: ; preds = %16
store i32 0, i32* %9
br label %30
30: ; preds = %66, %29
%31 = getelementptr inbounds [15 x i8], [15 x i8]* %8, i64 0, i64 0
%32 = load i32*, i32** %6
%33 = call i32* @fgets(i8* %31, i32 14, i32* %32)
%34 = icmp ne i32* %33, null
br i1 %34, label %35, label %69
35: ; preds = %30
%36 = getelementptr inbounds [15 x i8], [15 x i8]* %8, i64 0, i64 0
%37 = call i32 @strlen(i8* %36)
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = mul i64 1, %39
%41 = trunc i64 %40 to i32
%42 = call i64 @malloc(i32 %41)
%43 = inttoptr i64 %42 to i8*
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 %45
store i8* %43, i8** %46
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 %48
%50 = load i8*, i8** %49
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %55
52: ; preds = %35
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %90
55: ; preds = %35
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 %57
%59 = load i8*, i8** %58
%60 = getelementptr inbounds [15 x i8], [15 x i8]* %8, i64 0, i64 0
%61 = call i32 @strcpy(i8* %59, i8* %60)
%62 = load i32, i32* %9
%63 = icmp eq i32 %62, 7
br i1 %63, label %64, label %65
64: ; preds = %55
br label %69
65: ; preds = %55
br label %66
66: ; preds = %65
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %30
69: ; preds = %64, %30
%70 = load i32, i32* %9
store i32 %70, i32* %10
store i32 0, i32* %9
br label %71
71: ; preds = %86, %69
%72 = load i32, i32* %9
%73 = load i32, i32* %10
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %89
75: ; preds = %71
%76 = load i32, i32* %9
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 %77
%79 = load i8*, i8** %78
%80 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %79)
%81 = load i32, i32* %9
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 %82
%84 = load i8*, i8** %83
%85 = call i32 @free(i8* %84)
br label %86
86: ; preds = %75
%87 = load i32, i32* %9
%88 = add nsw i32 %87, 1
store i32 %88, i32* %9
br label %71
89: ; preds = %71
store i32 0, i32* %3
br label %90
90: ; preds = %89, %52, %23, %13
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"Input argument.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"Cannot open file: %s\0A\00"
@.str.3 = [8 x i8] c"error!\0A\00"
@.str.4 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [7 x i8*]
%4 = alloca [15 x i8]
%5 = bitcast [7 x i8*]* %3 to i8*
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 1
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %55
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = call i32* @fgets(i8* %6, i32 14, i32* %14)
%18 = icmp eq i32* %17, null
br i1 %18, label %55, label %23
19: ; preds = %11
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %12
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %21)
br label %55
23: ; preds = %16, %37
%24 = phi i64 [ %38, %37 ], [ 0, %16 ]
%25 = call i32 @strlen(i8* %6)
%26 = add nsw i32 %25, 1
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to i8*
%29 = getelementptr inbounds [7 x i8*], [7 x i8*]* %3, i64 0, i64 %24
store i8* %28, i8** %29
%30 = icmp eq i64 %27, 0
br i1 %30, label %31, label %34
31: ; preds = %23
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %55
34: ; preds = %23
%35 = call i32 @strcpy(i8* %28, i8* %6)
%36 = icmp eq i64 %24, 7
br i1 %36, label %44, label %37
37: ; preds = %34
%38 = add nuw nsw i64 %24, 1
%39 = call i32* @fgets(i8* %6, i32 14, i32* %14)
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %23
41: ; preds = %37
%42 = trunc i64 %38 to i32
%43 = icmp eq i32 %42, 0
br i1 %43, label %55, label %44
44: ; preds = %34, %41
%45 = phi i64 [ %38, %41 ], [ 7, %34 ]
%46 = and i64 %45, 4294967295
br label %47
47: ; preds = %44, %47
%48 = phi i64 [ 0, %44 ], [ %53, %47 ]
%49 = getelementptr inbounds [7 x i8*], [7 x i8*]* %3, i64 0, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %50)
%52 = call i32 @free(i8* %50)
%53 = add nuw nsw i64 %48, 1
%54 = icmp eq i64 %53, %46
br i1 %54, label %55, label %47
55: ; preds = %47, %16, %41, %31, %19, %8
%56 = phi i32 [ -1, %8 ], [ -1, %19 ], [ -1, %31 ], [ 0, %41 ], [ 0, %16 ], [ 0, %47 ]
ret i32 %56
}