#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 */
scalar_t__ _head(int, int, char **);
int _usage();
int getopt(int, char **, char *);
char *optarg;
int optind;
int strtol(char *, char **, int);
int main(int argc, char *argv[]) {
  int flgn = 10;
  int o;
  char *p;
  while ((o = getopt(argc, argv, "n:")) != -1)
    switch (o) {
    case 'n':
      flgn = strtol(optarg, &p, 10);
      if (*optarg == '\0' || *p != '\0')
        return _usage();
      break;
    default:
      return _usage();
    }
  return _head(flgn, argc - optind, &argv[optind]) == 0 ? 0 : 2;
}


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)
movl   $0xa,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe95(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     11f6 <main+0xb6>
mov    -0x18(%rbp),%eax
sub    $0x6e,%eax
jne    11e2 <main+0xa2>
jmp    118d <main+0x4d>
mov    0x2e64(%rip),%rax
mov    (%rax),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ce <main+0x8e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11dd <main+0x9d>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1233 <main+0xf3>
jmp    11f1 <main+0xb1>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1233 <main+0xf3>
jmp    115d <main+0x1d>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2ddd(%rip),%rax
sub    (%rax),%esi
mov    -0x10(%rbp),%rdx
mov    0x2dd0(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
add    %rax,%rdx
call   1040 <_head@plt>
mov    %rax,%rdx
mov    $0x2,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r13d
mov    $0xa,%ebp
lea    0xea3(%rip),%r15
mov    0x2e94(%rip),%rbx
mov    %rsp,%r12
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <getopt@plt>
cmp    $0x6e,%eax
jne    11a8 <main+0x68>
mov    (%rbx),%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%ebp
mov    (%rbx),%rax
cmpb   $0x0,(%rax)
je     11e3 <main+0xa3>
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     1170 <main+0x30>
jmp    11e3 <main+0xa3>
cmp    $0xffffffff,%eax
jne    11e3 <main+0xa3>
mov    0x2e2c(%rip),%rax
movslq (%rax),%rax
sub    %eax,%r13d
lea    (%r14,%rax,8),%rdx
mov    %ebp,%edi
mov    %r13d,%esi
call   1040 <_head@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
add    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_usage@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"n:\00"
@optarg = global i8* null
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
br label %5
5: ; preds = %14, %2
%6 = phi i32 [ 10, %2 ], [ %10, %14 ]
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %7, label %20 [
i32 -1, label %22
i32 110, label %8
]
8: ; preds = %5
%9 = load i8*, i8** @optarg
%10 = call i32 @strtol(i8* %9, i8** %3, i32 10)
%11 = load i8*, i8** @optarg
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %8
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %5, label %18
18: ; preds = %14, %8
%19 = tail call i32 (...) @_usage()
br label %30
20: ; preds = %5
%21 = tail call i32 (...) @_usage()
br label %30
22: ; preds = %5
%23 = load i32, i32* @optind
%24 = sub nsw i32 %0, %23
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds i8*, i8** %1, i64 %25
%27 = tail call i64 @_head(i32 %6, i32 %24, i8** %26)
%28 = icmp eq i64 %27, 0
%29 = select i1 %28, i32 0, i32 2
br label %30
30: ; preds = %22, %20, %18
%31 = phi i32 [ %19, %18 ], [ %21, %20 ], [ %29, %22 ]
ret i32 %31
}