#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 EXIT_SUCCESS;
int atol(char const *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ fstrings(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ strcmp(char const *, char *);
int main(int argc, char const *argv[]) {
  int size = 10;
  FILE *file = stdin;
  if (argc > 4) {
    fprintf(stderr, "%s: too many arguments\n", argv[0]);
    return 1;
  }
  for (int i = 1; i < argc; i++) {
    if (!strcmp(argv[i], "-n")) {
      if (i + 1 < argc) {
        size = atol(argv[++i]);
        if (size < 1) {
          fprintf(stderr, "%s: -n cannot less than 1\n", argv[0]);
          return 1;
        }
      } else {
        fprintf(stderr, "%s: missing argument for -n\n", argv[0]);
        return 1;
      }
    } else {
      file = fopen(argv[i], "r");
      if (!file) {
        fprintf(stderr, "%s: failed to open %s\n", argv[0], argv[i]);
        return 1;
      }
    }
  }
  fstrings(file, size);
  fclose(file);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xa,-0x14(%rbp)
mov    0x2e64(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    11bf <main+0x5f>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131c <main+0x1bc>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12fb <main+0x19b>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe33(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1286 <main+0x126>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    1257 <main+0xf7>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <atol@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    1252 <main+0xf2>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131c <main+0x1bc>
jmp    1281 <main+0x121>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131c <main+0x1bc>
jmp    12e8 <main+0x188>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdba(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12e3 <main+0x183>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xd85(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131c <main+0x1bc>
jmp    12e8 <main+0x188>
jmp    12ed <main+0x18d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c6 <main+0x66>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <fstrings@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
cmp    $0x5,%edi
jl     119b <main+0x3b>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xe76(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
jmp    127e <main+0x11e>
mov    %edi,%ebx
mov    0x2e44(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
cmp    $0x2,%edi
jl     1254 <main+0xf4>
movl   $0xa,0xc(%rsp)
mov    $0x1,%r12d
jmp    11f9 <main+0x99>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
mov    %r15,%rbp
je     128d <main+0x12d>
add    $0x1,%r12d
cmp    %ebx,%r12d
jge    125c <main+0xfc>
movslq %r12d,%r14
mov    %rbp,%r15
mov    0x0(%rbp,%r14,8),%r13
mov    %r13,%rdi
lea    0xe0a(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11d0 <main+0x70>
add    $0x1,%r12d
cmp    %ebx,%r12d
jge    12b4 <main+0x154>
movslq %r12d,%rax
mov    %r15,%rbp
mov    (%r15,%rax,8),%rdi
call   1070 <atol@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
jg     11f0 <main+0x90>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xdcc(%rip),%rsi
jmp    118a <main+0x2a>
movl   $0xa,0xc(%rsp)
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    0xc(%rsp),%esi
call   1040 <fstrings@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d44(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
mov    0x0(%rbp,%r14,8),%rcx
lea    0xdaf(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%eax
jmp    127e <main+0x11e>
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xd6f(%rip),%rsi
jmp    118a <main+0x2a>

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

LLVM IR (-O2):
@stdin = global i32* null
@stderr = global i32 0
@.str = [24 x i8] c"%s: too many arguments\0A\00"
@.str.1 = [3 x i8] c"-n\00"
@.str.2 = [27 x i8] c"%s: -n cannot less than 1\0A\00"
@.str.3 = [29 x i8] c"%s: missing argument for -n\0A\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [23 x i8] c"%s: failed to open %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 4
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %58
8: ; preds = %2
%9 = load i32*, i32** @stdin
%10 = icmp sgt i32 %0, 1
br i1 %10, label %11, label %52
11: ; preds = %8, %46
%12 = phi i32 [ %50, %46 ], [ 1, %8 ]
%13 = phi i32* [ %48, %46 ], [ %9, %8 ]
%14 = phi i32 [ %47, %46 ], [ 10, %8 ]
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %37
20: ; preds = %11
%21 = add nsw i32 %12, 1
%22 = icmp slt i32 %21, %0
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = sext i32 %21 to i64
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = tail call i32 @atol(i8* %26)
%28 = icmp slt i32 %27, 1
br i1 %28, label %29, label %46
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %1
%32 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %58
33: ; preds = %20
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %1
%36 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %58
37: ; preds = %11
%38 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = getelementptr inbounds i8*, i8** %1, i64 %15
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %1
%44 = load i8*, i8** %41
%45 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %43, i8* %44)
br label %58
46: ; preds = %23, %37
%47 = phi i32 [ %14, %37 ], [ %27, %23 ]
%48 = phi i32* [ %38, %37 ], [ %13, %23 ]
%49 = phi i32 [ %12, %37 ], [ %21, %23 ]
%50 = add nsw i32 %49, 1
%51 = icmp slt i32 %50, %0
br i1 %51, label %11, label %52
52: ; preds = %46, %8
%53 = phi i32 [ 10, %8 ], [ %47, %46 ]
%54 = phi i32* [ %9, %8 ], [ %48, %46 ]
%55 = tail call i32 @fstrings(i32* %54, i32 %53)
%56 = tail call i32 @fclose(i32* %54)
%57 = load i32, i32* @EXIT_SUCCESS
br label %58
58: ; preds = %33, %29, %40, %52, %4
%59 = phi i32 [ 1, %4 ], [ %57, %52 ], [ 1, %40 ], [ 1, %29 ], [ 1, %33 ]
ret i32 %59
}