#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__ _chroot(char *, char *);
int _chroot_usage();
int getopt(int, char **, char *);
int optind;
int main(int argc, char *argv[]) {
  int o;
  while ((o = getopt(argc, argv, "")) != -1)
    return _chroot_usage();
  if (argc - optind != 1 && argc - optind != 2)
    return _chroot_usage();
  return (_chroot(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   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1174 <main+0x44>
mov    $0x0,%al
call   1030 <_chroot_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11ef <main+0xbf>
mov    -0x8(%rbp),%eax
mov    0x2e6a(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x1,%eax
je     11ad <main+0x7d>
mov    -0x8(%rbp),%eax
mov    0x2e55(%rip),%rcx
sub    (%rcx),%eax
cmp    $0x2,%eax
je     11ad <main+0x7d>
mov    $0x0,%al
call   1030 <_chroot_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11ef <main+0xbf>
mov    -0x10(%rbp),%rax
mov    0x2e30(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    0x2e1e(%rip),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <_chroot@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   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xec1(%rip),%rdx
call   1050 <getopt@plt>
cmp    $0xffffffff,%eax
jne    117f <main+0x4f>
mov    0x2e98(%rip),%rax
movslq (%rax),%rax
mov    %eax,%ecx
not    %ecx
add    %ebp,%ecx
cmp    $0x2,%ecx
jae    117f <main+0x4f>
mov    (%rbx,%rax,8),%rdi
mov    0x8(%rbx,%rax,8),%rsi
call   1040 <_chroot@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
add    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <_chroot_usage@plt>

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 %14
12: ; preds = %7
%13 = call i32 (...) @_chroot_usage()
store i32 %13, i32* %3
br label %42
14: ; preds = %7
%15 = load i32, i32* %4
%16 = load i32, i32* @optind
%17 = sub nsw i32 %15, %16
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %26
19: ; preds = %14
%20 = load i32, i32* %4
%21 = load i32, i32* @optind
%22 = sub nsw i32 %20, %21
%23 = icmp ne i32 %22, 2
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = call i32 (...) @_chroot_usage()
store i32 %25, i32* %3
br label %42
26: ; preds = %19, %14
%27 = load i8**, i8*** %5
%28 = load i32, i32* @optind
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = load i32, i32* @optind
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %32, i64 %35
%37 = load i8*, i8** %36
%38 = call i64 @_chroot(i8* %31, i8* %37)
%39 = icmp eq i64 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i32 0, i32 2
store i32 %41, i32* %3
br label %42
42: ; preds = %26, %24, %12
%43 = load i32, i32* %3
ret i32 %43
}

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 (...) @_chroot_usage()
br label %25
7: ; preds = %2
%8 = load i32, i32* @optind
%9 = xor i32 %8, -1
%10 = add i32 %9, %0
%11 = icmp ult i32 %10, 2
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = tail call i32 (...) @_chroot_usage()
br label %25
14: ; preds = %7
%15 = sext i32 %8 to i64
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = add nsw i32 %8, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i64 @_chroot(i8* %17, i8* %21)
%23 = icmp eq i64 %22, 0
%24 = select i1 %23, i32 0, i32 2
br label %25
25: ; preds = %14, %12, %5
%26 = phi i32 [ %6, %5 ], [ %13, %12 ], [ %24, %14 ]
ret i32 %26
}