#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 EX_OK;
int EX_OSERR;
int EX_UNAVAILABLE;
int EX_USAGE;
int /*<<< orphan*/ assert(char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ help(int);
int optind;
int /*<<< orphan*/ optopt;
int /*<<< orphan*/ rep(char *);
int /*<<< orphan*/ warn(char *, char *);
int /*<<< orphan*/ warnx(char *, ...);
int main(int argc, char *argv[]) {
  char *srcdir = NULL;
  int ch = 0;
  while ((ch = getopt(argc, argv, ":h")) != -1) {
    switch (ch) {
    case 'h':
      help(true);
      return EX_OK;
    case '?':
      warnx("error: unrecognized flag -%c", optopt);
      help(false);
      return EX_USAGE;
    default:
      warnx("fatal: this is not supposed to be reached");
      help(false);
      return EX_UNAVAILABLE;
    }
  }
  if (optind >= argc) {
    warnx("error: no source dir given\n");
    help(false);
    return EX_USAGE;
  }
  srcdir = argv[optind];
  if (optind + 1 < argc) {
    warnx("error: too many arguments given\n");
    help(false);
    return EX_USAGE;
  }
  assert(srcdir);
  if (!rep(srcdir)) {
    warn("error: cannot replicate %s", srcdir);
    return EX_OSERR;
  }
  return EX_OK;
}


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)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe6d(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     1239 <main+0xd9>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x3f,%eax
je     11e4 <main+0x84>
jmp    11b8 <main+0x58>
mov    -0x20(%rbp),%eax
sub    $0x68,%eax
jne    1213 <main+0xb3>
jmp    11c9 <main+0x69>
mov    $0x1,%edi
call   1080 <help@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    130a <main+0x1aa>
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <warnx@plt>
xor    %edi,%edi
call   1080 <help@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    130a <main+0x1aa>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1050 <warnx@plt>
xor    %edi,%edi
call   1080 <help@plt>
mov    0x2d89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    130a <main+0x1aa>
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jl     1271 <main+0x111>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1050 <warnx@plt>
xor    %edi,%edi
call   1080 <help@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    130a <main+0x1aa>
mov    -0x10(%rbp),%rax
mov    0x2d5c(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    0x2d4a(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    12c2 <main+0x162>
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1050 <warnx@plt>
xor    %edi,%edi
call   1080 <help@plt>
mov    0x2d30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    130a <main+0x1aa>
mov    -0x18(%rbp),%rdi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1040 <rep@plt>
cmp    $0x0,%eax
jne    12fe <main+0x19e>
mov    -0x18(%rbp),%rsi
lea    0xd9f(%rip),%rdi
call   1030 <warn@plt>
mov    0x2ccc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    130a <main+0x1aa>
mov    0x2cc3(%rip),%rax
mov    (%rax),%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    0xe91(%rip),%rdx
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
je     1196 <main+0x36>
cmp    $0x3f,%eax
je     11b4 <main+0x54>
cmp    $0x68,%eax
jne    11cd <main+0x6d>
mov    $0x1,%edi
call   1080 <help@plt>
mov    0x2e34(%rip),%rax
jmp    1207 <main+0xa7>
mov    0x2e3b(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
jge    11eb <main+0x8b>
lea    0x1(%rax),%ecx
cmp    %ebp,%ecx
jge    1210 <main+0xb0>
lea    0xeb4(%rip),%rdi
jmp    11f2 <main+0x92>
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1050 <warnx@plt>
jmp    11f9 <main+0x99>
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1050 <warnx@plt>
xor    %edi,%edi
call   1080 <help@plt>
mov    0x2dcf(%rip),%rax
jmp    1207 <main+0xa7>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1050 <warnx@plt>
xor    %edi,%edi
call   1080 <help@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    (%rbx,%rax,8),%rbx
mov    %rbx,%rdi
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1040 <rep@plt>
test   %eax,%eax
je     1231 <main+0xd1>
mov    0x2d99(%rip),%rax
jmp    1207 <main+0xa7>
lea    0xe4f(%rip),%rdi
mov    %rbx,%rsi
call   1030 <warn@plt>
mov    0x2d79(%rip),%rax
jmp    1207 <main+0xa7>

LLVM IR (-O0):
@.str = [3 x i8] c":h\00"
@EX_OK = global i32 0
@.str.1 = [29 x i8] c"error: unrecognized flag -%c\00"
@optopt = global i32 0
@EX_USAGE = global i32 0
@.str.2 = [42 x i8] c"fatal: this is not supposed to be reached\00"
@EX_UNAVAILABLE = global i32 0
@optind = global i32 0
@.str.3 = [28 x i8] c"error: no source dir given\0A\00"
@.str.4 = [33 x i8] c"error: too many arguments given\0A\00"
@.str.5 = [27 x i8] c"error: cannot replicate %s\00"
@EX_OSERR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %7
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %27
13: ; preds = %8
%14 = load i32, i32* %7
switch i32 %14, label %23 [
i32 104, label %15
i32 63, label %18
]
15: ; preds = %13
%16 = call i32 @help(i32 1)
%17 = load i32, i32* @EX_OK
store i32 %17, i32* %3
br label %61
18: ; preds = %13
%19 = load i32, i32* @optopt
%20 = call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = call i32 @help(i32 0)
%22 = load i32, i32* @EX_USAGE
store i32 %22, i32* %3
br label %61
23: ; preds = %13
%24 = call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @help(i32 0)
%26 = load i32, i32* @EX_UNAVAILABLE
store i32 %26, i32* %3
br label %61
27: ; preds = %8
%28 = load i32, i32* @optind
%29 = load i32, i32* %4
%30 = icmp sge i32 %28, %29
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @help(i32 0)
%34 = load i32, i32* @EX_USAGE
store i32 %34, i32* %3
br label %61
35: ; preds = %27
%36 = load i8**, i8*** %5
%37 = load i32, i32* @optind
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
store i8* %40, i8** %6
%41 = load i32, i32* @optind
%42 = add nsw i32 %41, 1
%43 = load i32, i32* %4
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %49
45: ; preds = %35
%46 = call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%47 = call i32 @help(i32 0)
%48 = load i32, i32* @EX_USAGE
store i32 %48, i32* %3
br label %61
49: ; preds = %35
%50 = load i8*, i8** %6
%51 = call i32 @assert(i8* %50)
%52 = load i8*, i8** %6
%53 = call i32 @rep(i8* %52)
%54 = icmp ne i32 %53, 0
br i1 %54, label %59, label %55
55: ; preds = %49
%56 = load i8*, i8** %6
%57 = call i32 @warn(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %56)
%58 = load i32, i32* @EX_OSERR
store i32 %58, i32* %3
br label %61
59: ; preds = %49
%60 = load i32, i32* @EX_OK
store i32 %60, i32* %3
br label %61
61: ; preds = %59, %55, %45, %31, %23, %18, %15
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [3 x i8] c":h\00"
@EX_OK = global i32 0
@.str.1 = [29 x i8] c"error: unrecognized flag -%c\00"
@optopt = global i32 0
@EX_USAGE = global i32 0
@.str.2 = [42 x i8] c"fatal: this is not supposed to be reached\00"
@EX_UNAVAILABLE = global i32 0
@optind = global i32 0
@.str.3 = [28 x i8] c"error: no source dir given\0A\00"
@.str.4 = [33 x i8] c"error: too many arguments given\0A\00"
@.str.5 = [27 x i8] c"error: cannot replicate %s\00"
@EX_OSERR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %3, label %10 [
i32 -1, label %13
i32 104, label %4
i32 63, label %6
]
4: ; preds = %2
%5 = tail call i32 @help(i32 1)
br label %34
6: ; preds = %2
%7 = load i32, i32* @optopt
%8 = tail call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 @help(i32 0)
br label %34
10: ; preds = %2
%11 = tail call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @help(i32 0)
br label %34
13: ; preds = %2
%14 = load i32, i32* @optind
%15 = icmp slt i32 %14, %0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%18 = tail call i32 @help(i32 0)
br label %34
19: ; preds = %13
%20 = sext i32 %14 to i64
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = add nsw i32 %14, 1
%24 = icmp slt i32 %23, %0
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = tail call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%27 = tail call i32 @help(i32 0)
br label %34
28: ; preds = %19
%29 = tail call i32 @assert(i8* %22)
%30 = tail call i32 @rep(i8* %22)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = tail call i32 @warn(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %22)
br label %34
34: ; preds = %28, %32, %25, %16, %10, %6, %4
%35 = phi i32* [ @EX_UNAVAILABLE, %10 ], [ @EX_USAGE, %6 ], [ @EX_OK, %4 ], [ @EX_USAGE, %16 ], [ @EX_USAGE, %25 ], [ @EX_OSERR, %32 ], [ @EX_OK, %28 ]
%36 = load i32, i32* %35
ret i32 %36
}