#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 head(int, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  int skip = 1;
  int nl = 10;
  if (argc > 1) {
    if (!strcmp(argv[1], "--"))
      skip += 1;
    if (!strcmp(argv[1], "-n")) {
      nl = (argc > 2) ? atoi(argv[2]) : nl;
      skip += 2;
    }
  }
  return head(nl, (argc > skip) ? argv[skip] : "/dev/stdin");
}


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   $0x1,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11da <main+0xaa>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe93(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1184 <main+0x54>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe70(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11d5 <main+0xa5>
cmpl   $0x2,-0x8(%rbp)
jle    11c0 <main+0x90>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    11c6 <main+0x96>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    11da <main+0xaa>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1201 <main+0xd1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
jmp    1211 <main+0xe1>
lea    0xdfe(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1211 <main+0xe1>
mov    -0x20(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1040 <head@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%r12d
mov    $0xa,%r15d
mov    $0x1,%ebx
cmp    $0x2,%edi
jl     117f <main+0x4f>
mov    0x8(%r14),%rbp
lea    0xea7(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
cmp    $0x1,%eax
mov    $0x1,%ebx
adc    $0x0,%ebx
lea    0xe90(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     118c <main+0x5c>
cmp    %r12d,%ebx
jge    11ac <main+0x7c>
mov    %ebx,%eax
mov    (%r14,%rax,8),%rsi
jmp    11b3 <main+0x83>
mov    $0xa,%r15d
cmp    $0x3,%r12d
jb     11a4 <main+0x74>
mov    0x10(%r14),%rdi
call   1050 <atoi@plt>
mov    %eax,%r15d
add    $0x2,%ebx
cmp    %r12d,%ebx
jl     1184 <main+0x54>
lea    0xe53(%rip),%rsi
mov    %r15d,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <head@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"--\00"
@.str.1 = [3 x i8] c"-n\00"
@.str.2 = [11 x i8] c"/dev/stdin\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 10, i32* %7
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %40
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %19
19: ; preds = %16, %10
%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 ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %39, label %25
25: ; preds = %19
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 2
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
br label %35
33: ; preds = %25
%34 = load i32, i32* %7
br label %35
35: ; preds = %33, %28
%36 = phi i32 [ %32, %28 ], [ %34, %33 ]
store i32 %36, i32* %7
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 2
store i32 %38, i32* %6
br label %39
39: ; preds = %35, %19
br label %40
40: ; preds = %39, %2
%41 = load i32, i32* %7
%42 = load i32, i32* %4
%43 = load i32, i32* %6
%44 = icmp sgt i32 %42, %43
br i1 %44, label %45, label %51
45: ; preds = %40
%46 = load i8**, i8*** %5
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
br label %52
51: ; preds = %40
br label %52
52: ; preds = %51, %45
%53 = phi i8* [ %50, %45 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %51 ]
%54 = call i32 @head(i32 %41, i8* %53)
ret i32 %54
}

LLVM IR (-O2):
@.str = [3 x i8] c"--\00"
@.str.1 = [3 x i8] c"-n\00"
@.str.2 = [11 x i8] c"/dev/stdin\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i32 2, i32 1
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %4
%13 = icmp ugt i32 %0, 2
br i1 %13, label %14, label %18
14: ; preds = %12
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
br label %18
18: ; preds = %12, %14
%19 = phi i32 [ %17, %14 ], [ 10, %12 ]
%20 = add nuw nsw i32 %9, 2
br label %21
21: ; preds = %4, %18, %2
%22 = phi i32 [ %9, %4 ], [ %20, %18 ], [ 1, %2 ]
%23 = phi i32 [ 10, %4 ], [ %19, %18 ], [ 10, %2 ]
%24 = icmp slt i32 %22, %0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = zext i32 %22 to i64
%27 = getelementptr inbounds i8*, i8** %1, i64 %26
%28 = load i8*, i8** %27
br label %29
29: ; preds = %21, %25
%30 = phi i8* [ %28, %25 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %21 ]
%31 = tail call i32 @head(i32 %23, i8* %30)
ret i32 %31
}