#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__ _rmdir(int, int, char **);
int _usage();
int getopt(int, char **, char *);
int optind;
int main(int argc, char *argv[]) {
  int flagp = 0;
  int o;
  while ((o = getopt(argc, argv, "p")) != -1)
    switch (o) {
    case 'p':
      flagp = 1;
      break;
    default:
      return _usage();
    }
  if (optind == argc)
    return _usage();
  return (_rmdir(flagp, 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   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea5(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     119d <main+0x6d>
mov    -0x18(%rbp),%eax
sub    $0x70,%eax
jne    1189 <main+0x59>
jmp    117d <main+0x4d>
movl   $0x1,-0x14(%rbp)
jmp    1198 <main+0x68>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11fb <main+0xcb>
jmp    114d <main+0x1d>
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    11be <main+0x8e>
mov    $0x0,%al
call   1030 <_usage@plt>
mov    %eax,-0x4(%rbp)
jmp    11fb <main+0xcb>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    0x2e1d(%rip),%rax
sub    (%rax),%esi
mov    -0x10(%rbp),%rdx
mov    0x2e10(%rip),%rax
movslq (%rax),%rax
shl    $0x3,%rax
add    %rax,%rdx
call   1040 <_rmdir@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   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
xor    %ecx,%ecx
lea    0xebb(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ecx,%ebp
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x70,%eax
je     1150 <main+0x20>
cmp    $0xffffffff,%eax
jne    117c <main+0x4c>
mov    0x2e73(%rip),%rax
movslq (%rax),%rax
cmp    %ebx,%eax
jne    118d <main+0x5d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <_usage@plt>
sub    %eax,%ebx
lea    (%r14,%rax,8),%rdx
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <_rmdir@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
add    %ecx,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"p\00"
@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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %8
8: ; preds = %18, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %7
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = load i32, i32* %7
switch i32 %14, label %16 [
i32 112, label %15
]
15: ; preds = %13
store i32 1, i32* %6
br label %18
16: ; preds = %13
%17 = call i32 (...) @_usage()
store i32 %17, i32* %3
br label %38
18: ; preds = %15
br label %8
19: ; preds = %8
%20 = load i32, i32* @optind
%21 = load i32, i32* %4
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 (...) @_usage()
store i32 %24, i32* %3
br label %38
25: ; preds = %19
%26 = load i32, i32* %6
%27 = load i32, i32* %4
%28 = load i32, i32* @optind
%29 = sub nsw i32 %27, %28
%30 = load i8**, i8*** %5
%31 = load i32, i32* @optind
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = call i64 @_rmdir(i32 %26, i32 %29, i8** %33)
%35 = icmp eq i64 %34, 0
%36 = zext i1 %35 to i64
%37 = select i1 %35, i32 0, i32 2
store i32 %37, i32* %3
br label %38
38: ; preds = %25, %23, %16
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [2 x i8] c"p\00"
@optind = global i32 0
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ 0, %2 ], [ 1, %3 ]
%5 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %5, label %6 [
i32 -1, label %8
i32 112, label %3
]
6: ; preds = %3
%7 = tail call i32 (...) @_usage()
br label %20
8: ; preds = %3
%9 = load i32, i32* @optind
%10 = icmp eq i32 %9, %0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 (...) @_usage()
br label %20
13: ; preds = %8
%14 = sub nsw i32 %0, %9
%15 = sext i32 %9 to i64
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = tail call i64 @_rmdir(i32 %4, i32 %14, i8** %16)
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i32 0, i32 2
br label %20
20: ; preds = %13, %11, %6
%21 = phi i32 [ %7, %6 ], [ %12, %11 ], [ %19, %13 ]
ret i32 %21
}