#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 error(char *);
int /*<<< orphan*/ head(int);
int /*<<< orphan*/ longlines(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ tail(int);
int main(int argc, char *argv[]) {
  int lines;
  char *num;
  switch (argc) {
  case 3:
    num = argv[2] + 1;
    if (strcmp(num, "\0") != 0) {
      lines = atoi(num);
      if (strcmp(argv[1], "head") == 0) {
        head(lines);
      } else if (strcmp(argv[1], "tail") == 0) {
        tail(lines);
      } else if (strcmp(argv[1], "longlines") == 0) {
        longlines(lines);
      } else {
        return error(argv[0]);
      }
    } else {
      printf("Error, el parametro -N no es valido, introduzca un numero de "
             "lineas valido.\n");
    }
    break;
  default:
    return error(argv[0]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
jne    127e <main+0x10e>
jmp    1197 <main+0x27>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     126d <main+0xfd>
mov    -0x20(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe27(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11f6 <main+0x86>
mov    -0x14(%rbp),%edi
call   1060 <head@plt>
jmp    1268 <main+0xf8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe02(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1220 <main+0xb0>
mov    -0x14(%rbp),%edi
call   1050 <tail@plt>
jmp    1263 <main+0xf3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xddd(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    124a <main+0xda>
mov    -0x14(%rbp),%edi
call   1070 <longlines@plt>
jmp    125e <main+0xee>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <error@plt>
mov    %eax,-0x4(%rbp)
jmp    1299 <main+0x129>
jmp    1263 <main+0xf3>
jmp    1268 <main+0xf8>
jmp    1279 <main+0x109>
lea    0xda2(%rip),%rdi
call   1030 <printf@plt>
jmp    1292 <main+0x122>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <error@plt>
mov    %eax,-0x4(%rbp)
jmp    1299 <main+0x129>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11cf <main+0x5f>
mov    0x10(%rbx),%rdi
cmpb   $0x0,0x1(%rdi)
je     11db <main+0x6b>
add    $0x1,%rdi
call   1090 <atoi@plt>
mov    %eax,%r14d
mov    0x8(%rbx),%rbp
lea    0xe63(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11e9 <main+0x79>
lea    0xe55(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11f3 <main+0x83>
lea    0xe47(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11fd <main+0x8d>
mov    (%rbx),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <error@plt>
lea    0xe32(%rip),%rdi
call   1030 <puts@plt>
jmp    1205 <main+0x95>
mov    %r14d,%edi
call   1060 <head@plt>
jmp    1205 <main+0x95>
mov    %r14d,%edi
call   1050 <tail@plt>
jmp    1205 <main+0x95>
mov    %r14d,%edi
call   1070 <longlines@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] zeroinitializer
@.str.1 = [5 x i8] c"head\00"
@.str.2 = [5 x i8] c"tail\00"
@.str.3 = [10 x i8] c"longlines\00"
@.str.4 = [77 x i8] c"Error, el parametro -N no es valido, introduzca un numero de lineas valido.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
switch i32 %8, label %57 [
i32 3, label %9
]
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 2
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 1
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %54
17: ; preds = %9
%18 = load i8*, i8** %7
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load i32, i32* %6
%27 = call i32 @head(i32 %26)
br label %53
28: ; preds = %17
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i32, i32* %6
%36 = call i32 @tail(i32 %35)
br label %52
37: ; preds = %28
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = load i32, i32* %6
%45 = call i32 @longlines(i32 %44)
br label %51
46: ; preds = %37
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 @error(i8* %49)
store i32 %50, i32* %3
br label %63
51: ; preds = %43
br label %52
52: ; preds = %51, %34
br label %53
53: ; preds = %52, %25
br label %56
54: ; preds = %9
%55 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %54, %53
br label %62
57: ; preds = %2
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 0
%60 = load i8*, i8** %59
%61 = call i32 @error(i8* %60)
store i32 %61, i32* %3
br label %63
62: ; preds = %56
store i32 0, i32* %3
br label %63
63: ; preds = %62, %57, %46
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"head\00"
@.str.2 = [5 x i8] c"tail\00"
@.str.3 = [10 x i8] c"longlines\00"
@str = [76 x i8] c"Error, el parametro -N no es valido, introduzca un numero de lineas valido.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %33
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %31, label %10
10: ; preds = %4
%11 = tail call i32 @atoi(i8* %7)
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = tail call i32 @head(i32 %11)
br label %36
18: ; preds = %10
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @tail(i32 %11)
br label %36
23: ; preds = %18
%24 = tail call i32 @strcmp(i8* dereferenceable(1) %13, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @longlines(i32 %11)
br label %36
28: ; preds = %23
%29 = load i8*, i8** %1
%30 = tail call i32 @error(i8* %29)
br label %36
31: ; preds = %4
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str, i64 0, i64 0))
br label %36
33: ; preds = %2
%34 = load i8*, i8** %1
%35 = tail call i32 @error(i8* %34)
br label %36
36: ; preds = %16, %26, %21, %31, %33, %28
%37 = phi i32 [ %30, %28 ], [ %35, %33 ], [ 0, %31 ], [ 0, %21 ], [ 0, %26 ], [ 0, %16 ]
ret i32 %37
}