#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__ _basename(char *, char *);
int _basename_usage();
int getopt(int, char **, char *);
int optind;
int main(int argc, char *argv[]) {
  int o;
  while ((o = getopt(argc, argv, "")) != -1)
    switch (o) {
    default:
      return _basename_usage();
    }
  if (optind != argc - 1 && optind != argc - 2)
    return _basename_usage();
  return (_basename(argv[optind], argv[optind + 1]) == 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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xeac(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1174 <main+0x44>
mov    $0x0,%al
call   1030 <_basename_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11f3 <main+0xc3>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11b1 <main+0x81>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
je     11b1 <main+0x81>
mov    $0x0,%al
call   1030 <_basename_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11f3 <main+0xc3>
mov    -0x10(%rbp),%rax
mov    0x2e2c(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    0x2e1a(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1050 <_basename@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   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xec0(%rip),%rdx
call   1040 <getopt@plt>
cmp    $0xffffffff,%eax
jne    1161 <main+0x31>
mov    0x2e97(%rip),%rax
mov    (%rax),%eax
lea    -0x1(%rbx),%ecx
cmp    %ecx,%eax
je     116f <main+0x3f>
add    $0xfffffffe,%ebx
cmp    %ebx,%eax
je     116f <main+0x3f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <_basename_usage@plt>
cltq
mov    (%r14,%rax,8),%rdi
mov    0x8(%r14,%rax,8),%rsi
call   1050 <_basename@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
add    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %3, -1
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 (...) @_basename_usage()
br label %27
7: ; preds = %2
%8 = load i32, i32* @optind
%9 = add nsw i32 %0, -1
%10 = icmp eq i32 %8, %9
%11 = add nsw i32 %0, -2
%12 = icmp eq i32 %8, %11
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %16, label %14
14: ; preds = %7
%15 = tail call i32 (...) @_basename_usage()
br label %27
16: ; preds = %7
%17 = sext i32 %8 to i64
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = add nsw i32 %8, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = tail call i64 @_basename(i8* %19, i8* %23)
%25 = icmp eq i64 %24, 0
%26 = select i1 %25, i32 0, i32 2
br label %27
27: ; preds = %16, %14, %5
%28 = phi i32 [ %6, %5 ], [ %15, %14 ], [ %26, %16 ]
ret i32 %28
}