#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 /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ abort();
int atoi(char *);
int /*<<< orphan*/ exec_fdupe(int, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(char);
char *optarg;
scalar_t__ opterr;
char optopt;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int c = 0;
  char *rootdir = NULL;
  int nthreads = 0;
  opterr = 0;
  while ((c = getopt(argc, argv, "hd:n:")) != -1) {
    switch (c) {
    case 'h':
      usage();
      exit(EXIT_SUCCESS);
      break;
    case 'd':
      rootdir = optarg;
      printf("ROOTDIR: %s\n", rootdir);
      break;
    case 'n':
      nthreads = atoi(optarg);
      printf("NTHREADS: %d\n", nthreads);
      break;
    case '?':
      if ('c' == optopt)
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      else if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      return 1;
    default:
      abort();
    }
  }
  if (nthreads <= 0)
    nthreads = 4;
  if (NULL == rootdir)
    rootdir = ".";
  exec_fdupe(nthreads, rootdir);
  exit(EXIT_SUCCESS);
}


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   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    0x2e05(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe28(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1344 <main+0x1b4>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x3f,%eax
je     1292 <main+0x102>
jmp    11fd <main+0x6d>
mov    -0x28(%rbp),%eax
sub    $0x64,%eax
je     1245 <main+0xb5>
jmp    120e <main+0x7e>
mov    -0x28(%rbp),%eax
sub    $0x68,%eax
je     1230 <main+0xa0>
jmp    121f <main+0x8f>
mov    -0x28(%rbp),%eax
sub    $0x6e,%eax
je     126a <main+0xda>
jmp    1338 <main+0x1a8>
mov    $0x0,%al
call   1070 <usage@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133f <main+0x1af>
mov    0x2d87(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133f <main+0x1af>
mov    0x2d47(%rip),%rax
movsbl (%rax),%ecx
mov    $0x63,%eax
cmp    %ecx,%eax
jne    12cd <main+0x13d>
mov    0x2d20(%rip),%rax
mov    (%rax),%edi
lea    0xd68(%rip),%rsi
mov    0x2d20(%rip),%rax
movsbl (%rax),%edx
call   1060 <fprintf@plt>
jmp    132d <main+0x19d>
mov    0x2d0c(%rip),%rax
movsbl (%rax),%edi
call   1080 <isprint@plt>
cmp    $0x0,%eax
je     1309 <main+0x179>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    0xd4e(%rip),%rsi
mov    0x2ce4(%rip),%rax
movsbl (%rax),%edx
call   1060 <fprintf@plt>
jmp    1328 <main+0x198>
mov    0x2cc0(%rip),%rax
mov    (%rax),%edi
lea    0xd41(%rip),%rsi
mov    0x2cc0(%rip),%rax
movsbl (%rax),%edx
call   1060 <fprintf@plt>
jmp    132d <main+0x19d>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11ca <main+0x3a>
cmpl   $0x0,-0x24(%rbp)
jg     1355 <main+0x1c5>
movl   $0x4,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    136c <main+0x1dc>
lea    0xd14(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <exec_fdupe@plt>
mov    0x2c41(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x2e21(%rip),%rax
movq   $0x0,(%rax)
lea    0xe4b(%rip),%r12
mov    0x2e3c(%rip),%r14
lea    0xe50(%rip),%r13
xor    %eax,%eax
mov    %rax,(%rsp)
xor    %ebx,%ebx
jmp    11e6 <main+0x56>
nopl   (%rax)
mov    (%r14),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebx
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1090 <getopt@plt>
cmp    $0x6e,%eax
je     11d0 <main+0x40>
cmp    $0x63,%eax
jle    121d <main+0x8d>
cmp    $0x64,%eax
jne    1289 <main+0xf9>
mov    (%r14),%rsi
lea    0xdf6(%rip),%rdi
mov    %rsi,(%rsp)
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e6 <main+0x56>
cmp    $0x3f,%eax
jne    1297 <main+0x107>
mov    0x2db7(%rip),%rbx
mov    (%rbx),%al
cmp    $0x63,%al
jne    1246 <main+0xb6>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
mov    $0x63,%edx
jmp    1270 <main+0xe0>
movsbl %al,%edi
call   1080 <isprint@plt>
mov    0x2d7b(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx),%cl
movsbl %cl,%edx
test   %eax,%eax
je     1269 <main+0xd9>
lea    0xddc(%rip),%rsi
jmp    1270 <main+0xe0>
lea    0xdea(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x68,%eax
jne    12cb <main+0x13b>
xor    %eax,%eax
call   1070 <usage@plt>
jmp    12bd <main+0x12d>
cmp    $0xffffffff,%eax
jne    12cb <main+0x13b>
test   %ebx,%ebx
mov    $0x4,%edi
cmovg  %ebx,%edi
mov    (%rsp),%rax
test   %rax,%rax
lea    0xdc8(%rip),%rsi
cmovne %rax,%rsi
call   1050 <exec_fdupe@plt>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@opterr = global i64 0
@.str = [6 x i8] c"hd:n:\00"
@EXIT_SUCCESS = global i32 0
@optarg = global i8* null
@.str.1 = [13 x i8] c"ROOTDIR: %s\0A\00"
@.str.2 = [14 x i8] c"NTHREADS: %d\0A\00"
@optopt = global i8 0
@stderr = global i32 0
@.str.3 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.4 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.5 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.6 = [2 x i8] c".\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8* null, i8** %7
store i32 0, i32* %8
store i64 0, i64* @opterr
br label %9
9: ; preds = %53, %2
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @getopt(i32 %10, i8** %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %6
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %54
14: ; preds = %9
%15 = load i32, i32* %6
switch i32 %15, label %51 [
i32 104, label %16
i32 100, label %20
i32 110, label %24
i32 63, label %29
]
16: ; preds = %14
%17 = call i32 (...) @usage()
%18 = load i32, i32* @EXIT_SUCCESS
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %14
%21 = load i8*, i8** @optarg
store i8* %21, i8** %7
%22 = load i8*, i8** %7
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %53
24: ; preds = %14
%25 = load i8*, i8** @optarg
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %53
29: ; preds = %14
%30 = load i8, i8* @optopt
%31 = sext i8 %30 to i32
%32 = icmp eq i32 99, %31
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i8, i8* @optopt
%36 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8 signext %35)
br label %50
37: ; preds = %29
%38 = load i8, i8* @optopt
%39 = call i32 @isprint(i8 signext %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i32, i32* @stderr
%43 = load i8, i8* @optopt
%44 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8 signext %43)
br label %49
45: ; preds = %37
%46 = load i32, i32* @stderr
%47 = load i8, i8* @optopt
%48 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8 signext %47)
br label %49
49: ; preds = %45, %41
br label %50
50: ; preds = %49, %33
ret i32 1
51: ; preds = %14
%52 = call i32 (...) @abort()
unreachable
53: ; preds = %24, %20
br label %9
54: ; preds = %9
%55 = load i32, i32* %8
%56 = icmp sle i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %54
store i32 4, i32* %8
br label %58
58: ; preds = %57, %54
%59 = load i8*, i8** %7
%60 = icmp eq i8* null, %59
br i1 %60, label %61, label %62
61: ; preds = %58
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8** %7
br label %62
62: ; preds = %61, %58
%63 = load i32, i32* %8
%64 = load i8*, i8** %7
%65 = call i32 @exec_fdupe(i32 %63, i8* %64)
%66 = load i32, i32* @EXIT_SUCCESS
%67 = call i32 @exit(i32 %66)
unreachable
}

LLVM IR (-O2):
@opterr = global i64 0
@.str = [6 x i8] c"hd:n:\00"
@EXIT_SUCCESS = global i32 0
@optarg = global i8* null
@.str.1 = [13 x i8] c"ROOTDIR: %s\0A\00"
@.str.2 = [14 x i8] c"NTHREADS: %d\0A\00"
@optopt = global i8 0
@stderr = global i32 0
@.str.3 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.4 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.5 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.6 = [2 x i8] c".\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %13, %2
%4 = phi i8* [ %14, %13 ], [ null, %2 ]
%5 = phi i32 [ %7, %13 ], [ 0, %2 ]
br label %6
6: ; preds = %3, %16
%7 = phi i32 [ %18, %16 ], [ %5, %3 ]
%8 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %36 [
i32 -1, label %38
i32 104, label %9
i32 100, label %13
i32 110, label %16
i32 63, label %20
]
9: ; preds = %6
%10 = tail call i32 (...) @usage()
%11 = load i32, i32* @EXIT_SUCCESS
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %6
%14 = load i8*, i8** @optarg
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %3
16: ; preds = %6
%17 = load i8*, i8** @optarg
%18 = tail call i32 @atoi(i8* %17)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %6
20: ; preds = %6
%21 = load i8, i8* @optopt
%22 = icmp eq i8 %21, 99
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i8 signext 99)
br label %35
26: ; preds = %20
%27 = tail call i32 @isprint(i8 signext %21)
%28 = icmp eq i32 %27, 0
%29 = load i32, i32* @stderr
%30 = load i8, i8* @optopt
br i1 %28, label %33, label %31
31: ; preds = %26
%32 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8 signext %30)
br label %35
33: ; preds = %26
%34 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8 signext %30)
br label %35
35: ; preds = %31, %33, %23
ret i32 1
36: ; preds = %6
%37 = tail call i32 (...) @abort()
unreachable
38: ; preds = %6
%39 = icmp slt i32 %7, 1
%40 = select i1 %39, i32 4, i32 %7
%41 = icmp eq i8* %4, null
%42 = select i1 %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* %4
%43 = tail call i32 @exec_fdupe(i32 %40, i8* %42)
%44 = load i32, i32* @EXIT_SUCCESS
%45 = tail call i32 @exit(i32 %44)
unreachable
}