#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 daemon(int, int /*<<< orphan*/);
int /*<<< orphan*/ err(int, char *);
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ script_execute(char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  bool daemonize;
  int ch;
  int rv;
  daemonize = false;
  while ((ch = getopt(argc, argv, "d")) != -1) {
    switch (ch) {
    case 'd':
      daemonize = true;
      break;
    case '?':
    default:
      usage();
    }
  }
  argc -= optind;
  argv += optind;
  if (argc != 1)
    usage();
  if (daemonize) {
    rv = daemon(1, 0);
    if (rv == -1)
      err(1, "daemon");
  }
  script_execute(argv[0]);
  return (0);
}


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    0xe85(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     11ce <main+0x7e>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x3f,%eax
je     11bd <main+0x6d>
jmp    11a0 <main+0x50>
mov    -0x20(%rbp),%eax
sub    $0x64,%eax
jne    11c2 <main+0x72>
jmp    11b1 <main+0x61>
movl   $0x1,-0x14(%rbp)
jmp    11c9 <main+0x79>
jmp    11c2 <main+0x72>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    116d <main+0x1d>
mov    0x2e13(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2dff(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1209 <main+0xb9>
mov    $0x0,%al
call   1060 <usage@plt>
cmpl   $0x0,-0x14(%rbp)
je     1242 <main+0xf2>
mov    $0x1,%edi
xor    %esi,%esi
call   1050 <daemon@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    123d <main+0xed>
mov    $0x1,%edi
lea    0xdca(%rip),%rsi
call   1040 <err@plt>
jmp    1242 <main+0xf2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <script_execute@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r15b
lea    0xe9a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
cmp    $0xffffffff,%eax
je     1195 <main+0x45>
cmp    $0x64,%eax
je     1190 <main+0x40>
xor    %eax,%eax
call   1060 <usage@plt>
jmp    1170 <main+0x20>
xor    %r15d,%r15d
jmp    1170 <main+0x20>
mov    0x2e4c(%rip),%rax
mov    (%rax),%r14
sub    %r14d,%ebp
cmp    $0x1,%ebp
je     11ae <main+0x5e>
xor    %eax,%eax
call   1060 <usage@plt>
test   $0x1,%r15b
jne    11d6 <main+0x86>
mov    $0x1,%edi
xor    %esi,%esi
call   1050 <daemon@plt>
cmp    $0xffffffff,%eax
jne    11d6 <main+0x86>
lea    0xe36(%rip),%rsi
mov    $0x1,%edi
call   1040 <err@plt>
mov    (%rbx,%r14,8),%rdi
call   1030 <script_execute@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"d\00"
@optind = global i64 0
@.str.1 = [7 x i8] c"daemon\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = phi i1 [ true, %2 ], [ false, %5 ]
br label %5
5: ; preds = %3, %7
%6 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %6, label %7 [
i32 -1, label %9
i32 100, label %3
]
7: ; preds = %5
%8 = tail call i32 (...) @usage()
br label %5
9: ; preds = %5
%10 = load i64, i64* @optind
%11 = trunc i64 %10 to i32
%12 = sub i32 %0, %11
%13 = icmp eq i32 %12, 1
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = tail call i32 (...) @usage()
br label %16
16: ; preds = %14, %9
br i1 %4, label %22, label %17
17: ; preds = %16
%18 = tail call i32 @daemon(i32 1, i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %17, %20, %16
%23 = getelementptr inbounds i8*, i8** %1, i64 %10
%24 = load i8*, i8** %23
%25 = tail call i32 @script_execute(i8* %24)
ret i32 0
}