#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 /*<<< orphan*/ readlines(char *, int);
int main(int argc, char *argv[]) {
  char line[1000];
  long lineno = 0;
  int i, n;
  if (argc != 3) {
    printf("Usage: tail -n N\n");
  } else if (argv[1][0] != '-' || argv[1][1] != 'n') {
    printf("Usage: tail -n N\n");
  } else {
    n = atoi(argv[2]);
    char lines[n];
    readlines(lines, n);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x408(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     116f <main+0x3f>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
jmp    1201 <main+0xd1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1198 <main+0x68>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x6e,%eax
je     11a9 <main+0x79>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
jmp    11fc <main+0xcc>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x410(%rbp)
mov    -0x410(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x418(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,%rsp
mov    %rax,-0x420(%rbp)
mov    -0x410(%rbp),%esi
call   1050 <readlines@plt>
mov    -0x418(%rbp),%rax
mov    %rax,%rsp
jmp    1201 <main+0xd1>
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1175 <main+0x45>
mov    0x8(%rsi),%rax
cmpb   $0x2d,(%rax)
jne    1175 <main+0x45>
cmpb   $0x6e,0x1(%rax)
jne    1175 <main+0x45>
mov    0x10(%rsi),%rdi
call   1040 <atoi@plt>
mov    %rsp,%rbx
mov    %eax,%ecx
mov    %rsp,%rdi
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rdi
mov    %rdi,%rsp
mov    %eax,%esi
call   1050 <readlines@plt>
mov    %rbx,%rsp
jmp    1181 <main+0x51>
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Usage: tail -n N\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8]
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %7
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %47
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 45
br i1 %23, label %32, label %24
24: ; preds = %16
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %30, 110
br i1 %31, label %32, label %34
32: ; preds = %24, %16
%33 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %46
34: ; preds = %24
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @atoi(i8* %37)
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = zext i32 %39 to i64
%41 = call i8* @llvm.stacksave()
store i8* %41, i8** %10
%42 = alloca i8, i64 %40
store i64 %40, i64* %11
%43 = load i32, i32* %9
%44 = call i32 @readlines(i8* %42, i32 %43)
%45 = load i8*, i8** %10
br label %46
46: ; preds = %34, %32
br label %47
47: ; preds = %46, %14
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@str.1 = [17 x i8] c"Usage: tail -n N\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.1, i64 0, i64 0))
br label %25
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 45
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 110
br i1 %14, label %17, label %15
15: ; preds = %11, %6
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.1, i64 0, i64 0))
br label %25
17: ; preds = %11
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = zext i32 %20 to i64
%22 = tail call i8* @llvm.stacksave()
%23 = alloca i8, i64 %21
%24 = call i32 @readlines(i8* %23, i32 %20)
br label %25
25: ; preds = %15, %17, %4
ret i32 0
}