#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*/ printlines(char **, int, int);
int readlines(char **);
int main(int argc, char *argv[]) {
  char *linesarray[30];
  int nlines;
  int n;
  if (argc == 1)
    n = 4;
  else if (argc == 2)
    if (*argv[1] == '-')
      n = atoi((argv[1] + 1));
    else {
      printf("Not a valid argument. Argument is of type int positive and "
             "starts with '-'\n");
      return 0;
    }
  if ((nlines = readlines(linesarray)) > 0)
    printlines(linesarray, n, nlines);
  else
    printf("YOU MADE A SERIOUS MISTAKE\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1172 <main+0x32>
movl   $0x4,-0x108(%rbp)
jmp    11ce <main+0x8e>
cmpl   $0x2,-0x8(%rbp)
jne    11c9 <main+0x89>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11ac <main+0x6c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
add    $0x1,%rdi
call   1050 <atoi@plt>
mov    %eax,-0x108(%rbp)
jmp    11c4 <main+0x84>
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1219 <main+0xd9>
jmp    11c9 <main+0x89>
jmp    11ce <main+0x8e>
lea    -0x100(%rbp),%rdi
call   1060 <readlines@plt>
mov    %eax,-0x104(%rbp)
cmp    $0x0,%eax
jle    1206 <main+0xc6>
lea    -0x100(%rbp),%rdi
mov    -0x108(%rbp),%esi
mov    -0x104(%rbp),%edx
call   1040 <printlines@plt>
jmp    1212 <main+0xd2>
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xf0,%rsp
mov    $0x4,%ebx
cmp    $0x2,%edi
jne    1166 <main+0x26>
mov    0x8(%rsi),%rdi
cmpb   $0x2d,(%rdi)
jne    1189 <main+0x49>
add    $0x1,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %rsp,%rdi
call   1060 <readlines@plt>
test   %eax,%eax
jle    1180 <main+0x40>
mov    %rsp,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printlines@plt>
jmp    1195 <main+0x55>
lea    0xe79(%rip),%rdi
jmp    1190 <main+0x50>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [76 x i8] c"Not a valid argument. Argument is of type int positive and starts with '-'\0A\00"
@.str.1 = [28 x i8] c"YOU MADE A SERIOUS MISTAKE\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [30 x i8*]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 4, i32* %8
br label %32
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %31
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 45
br i1 %21, label %22, label %28
22: ; preds = %15
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %8
br label %30
28: ; preds = %15
%29 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %44
30: ; preds = %22
br label %31
31: ; preds = %30, %12
br label %32
32: ; preds = %31, %11
%33 = getelementptr inbounds [30 x i8*], [30 x i8*]* %6, i64 0, i64 0
%34 = call i32 @readlines(i8** %33)
store i32 %34, i32* %7
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = getelementptr inbounds [30 x i8*], [30 x i8*]* %6, i64 0, i64 0
%38 = load i32, i32* %8
%39 = load i32, i32* %7
%40 = call i32 @printlines(i8** %37, i32 %38, i32 %39)
br label %43
41: ; preds = %32
%42 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %43
43: ; preds = %41, %36
store i32 0, i32* %3
br label %44
44: ; preds = %43, %28
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@str = [27 x i8] c"YOU MADE A SERIOUS MISTAKE\00"
@str.2 = [75 x i8] c"Not a valid argument. Argument is of type int positive and starts with '-'\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [30 x i8*]
%4 = bitcast [30 x i8*]* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %16
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 %14
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = tail call i32 @atoi(i8* %12)
br label %16
14: ; preds = %6
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str.2, i64 0, i64 0))
br label %25
16: ; preds = %2, %11
%17 = phi i32 [ %13, %11 ], [ 4, %2 ]
%18 = getelementptr inbounds [30 x i8*], [30 x i8*]* %3, i64 0, i64 0
%19 = call i32 @readlines(i8** %18)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @printlines(i8** %18, i32 %17, i32 %19)
br label %25
23: ; preds = %16
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %25
25: ; preds = %21, %23, %14
ret i32 0
}