#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 */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ printf(char *);
int readtail(char **, int, int);
int /*<<< orphan*/ writetail(char **, int, int);
int main(int argc, char *argv[]) {
  char c;
  int row = 10;
  char *lineptr[10000];
  int nlines;
  while (--argc > 0)
    switch (c = (*++argv)[0]) {
    case '-':
      row = atoi(++argv[0]);
      break;
    default:
      break;
    }
  if (row > 10000)
    row = 10000;
  if ((nlines = readtail(lineptr, 10000, row)) > 0)
    writetail(lineptr, nlines, row);
  else
    printf("input file is too big!!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xa,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11bc <main+0x7c>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
sub    $0x2d,%al
jne    11b2 <main+0x72>
jmp    1197 <main+0x57>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
mov    %rdi,(%rax)
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    11b7 <main+0x77>
jmp    11b7 <main+0x77>
jmp    1160 <main+0x20>
cmpl   $0x2710,-0x18(%rbp)
jle    11d0 <main+0x90>
movl   $0x2710,-0x18(%rbp)
lea    -0x138a0(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    $0x2710,%esi
call   1030 <readtail@plt>
mov    %eax,-0x138a4(%rbp)
cmp    $0x0,%eax
jle    120d <main+0xcd>
lea    -0x138a0(%rbp),%rdi
mov    -0x138a4(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <writetail@plt>
jmp    1219 <main+0xd9>
lea    0xdec(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x138b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x13888,%rsp
mov    $0xa,%eax
cmp    $0x2,%edi
jl     119e <main+0x5e>
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0x1,%ebp
add    $0x8,%rbx
mov    $0xa,%eax
jmp    117c <main+0x3c>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
add    $0x8,%rbx
cmp    $0x2,%ebp
jbe    1192 <main+0x52>
mov    (%rbx),%rdi
cmpb   $0x2d,(%rdi)
jne    1170 <main+0x30>
add    $0x1,%rdi
mov    %rdi,(%rbx)
call   1060 <atoi@plt>
jmp    1170 <main+0x30>
mov    $0x2710,%ebx
cmp    $0x270f,%eax
jg     11a0 <main+0x60>
mov    %eax,%ebx
mov    %rsp,%rdi
mov    $0x2710,%esi
mov    %ebx,%edx
call   1040 <readtail@plt>
test   %eax,%eax
jle    11c1 <main+0x81>
mov    %rsp,%rdi
mov    %eax,%esi
mov    %ebx,%edx
call   1050 <writetail@plt>
jmp    11cd <main+0x8d>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x13888,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"input file is too big!!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca [10000 x i8*]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10, i32* %7
br label %10
10: ; preds = %28, %2
%11 = load i32, i32* %4
%12 = add nsw i32 %11, -1
store i32 %12, i32* %4
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i32 1
store i8** %16, i8*** %5
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
store i8 %19, i8* %6
%20 = sext i8 %19 to i32
switch i32 %20, label %27 [
i32 45, label %21
]
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %23
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %7
br label %28
27: ; preds = %14
br label %28
28: ; preds = %27, %21
br label %10
29: ; preds = %10
%30 = load i32, i32* %7
%31 = icmp sgt i32 %30, 10000
br i1 %31, label %32, label %33
32: ; preds = %29
store i32 10000, i32* %7
br label %33
33: ; preds = %32, %29
%34 = getelementptr inbounds [10000 x i8*], [10000 x i8*]* %8, i64 0, i64 0
%35 = load i32, i32* %7
%36 = call i32 @readtail(i8** %34, i32 10000, i32 %35)
store i32 %36, i32* %9
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %33
%39 = getelementptr inbounds [10000 x i8*], [10000 x i8*]* %8, i64 0, i64 0
%40 = load i32, i32* %9
%41 = load i32, i32* %7
%42 = call i32 @writetail(i8** %39, i32 %40, i32 %41)
br label %45
43: ; preds = %33
%44 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %45
45: ; preds = %43, %38
ret i32 0
}

LLVM IR (-O2):
@str = [24 x i8] c"input file is too big!!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10000 x i8*]
%4 = bitcast [10000 x i8*]* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %23
6: ; preds = %2, %18
%7 = phi i32 [ %10, %18 ], [ %0, %2 ]
%8 = phi i32 [ %19, %18 ], [ 10, %2 ]
%9 = phi i8** [ %11, %18 ], [ %1, %2 ]
%10 = add nsw i32 %7, -1
%11 = getelementptr inbounds i8*, i8** %9, i64 1
%12 = load i8*, i8** %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 45
br i1 %14, label %15, label %18
15: ; preds = %6
%16 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %16, i8** %11
%17 = tail call i32 @atoi(i8* %16)
br label %18
18: ; preds = %6, %15
%19 = phi i32 [ %17, %15 ], [ %8, %6 ]
%20 = icmp ugt i32 %7, 2
br i1 %20, label %6, label %21
21: ; preds = %18
%22 = icmp slt i32 %19, 10000
br i1 %22, label %23, label %25
23: ; preds = %2, %21
%24 = phi i32 [ %19, %21 ], [ 10, %2 ]
br label %25
25: ; preds = %21, %23
%26 = phi i32 [ %24, %23 ], [ 10000, %21 ]
%27 = getelementptr inbounds [10000 x i8*], [10000 x i8*]* %3, i64 0, i64 0
%28 = call i32 @readtail(i8** %27, i32 10000, i32 %26)
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 @writetail(i8** %27, i32 %28, i32 %26)
br label %34
32: ; preds = %25
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
ret i32 0
}