#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 */
typedef int /*<<< orphan*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ daemon(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ help();
int /*<<< orphan*/ parse_commands(int, char **);
int /*<<< orphan*/ perror(char *);
scalar_t__ setup_signals();
int /*<<< orphan*/ sigfillset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ start();
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int daemonize = 0;
  sigset_t new, old;
  if (argc > 1 && strcmp(argv[1], "-d") == 0) {
    daemonize = 1;
    argv++;
    argc--;
  }
  if (argc <= 1 || strcmp(argv[1], "-h") == 0) {
    help();
    exit(0);
  }
  if (daemonize)
    daemon(0, 0);
  parse_commands(argc - 1, argv + 1);
  if (setup_signals()) {
    perror("setup_signals");
    exit(1);
  }
  sigfillset(&new);
  sigprocmask(SIG_BLOCK, &new, &old);
  start();
  sigprocmask(SIG_SETMASK, &old, NULL);
  while (1)
    sleep(1000000);
}


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)
cmpl   $0x1,-0x8(%rbp)
jle    1211 <main+0x61>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1211 <main+0x61>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1239 <main+0x89>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1247 <main+0x97>
mov    $0x0,%al
call   10b0 <help@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x14(%rbp)
je     125a <main+0xaa>
xor    %esi,%esi
mov    %esi,%edi
call   1080 <daemon@plt>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1090 <parse_commands@plt>
mov    $0x0,%al
call   1070 <setup_signals@plt>
cmp    $0x0,%rax
je     1294 <main+0xe4>
lea    0xd81(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x18(%rbp),%rdi
call   1060 <sigfillset@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1030 <sigprocmask@plt>
mov    $0x0,%al
call   1050 <start@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
lea    -0x1c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
mov    $0xf4240,%edi
call   10d0 <sleep@plt>
jmp    12d0 <main+0x120>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     128c <main+0xdc>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe34(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11f3 <main+0x43>
add    $0x8,%rbx
mov    (%rbx),%rdi
lea    0xe1f(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1221 <main+0x71>
jmp    128c <main+0xdc>
add    $0xffffffff,%ebp
cmp    $0x2,%ebp
jb     128c <main+0xdc>
mov    0x10(%rbx),%rdi
lea    0xdf9(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     128c <main+0xdc>
add    $0x10,%rbx
xor    %edi,%edi
xor    %esi,%esi
call   1080 <daemon@plt>
add    $0xffffffff,%ebp
mov    %ebp,%edi
mov    %rbx,%rsi
call   1090 <parse_commands@plt>
xor    %eax,%eax
call   1070 <setup_signals@plt>
test   %rax,%rax
jne    129a <main+0xea>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sigfillset@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rbp
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1030 <sigprocmask@plt>
xor    %eax,%eax
call   1050 <start@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xf4240,%edi
call   10d0 <sleep@plt>
jmp    1280 <main+0xd0>
xor    %eax,%eax
call   10b0 <help@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
lea    0xd65(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-d\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [14 x i8] c"setup_signals\00"
@SIG_BLOCK = global i32 0
@SIG_SETMASK = 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
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %22
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %11
store i32 1, i32* %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i32 1
store i8** %19, i8*** %5
%20 = load i32, i32* %4
%21 = add nsw i32 %20, -1
store i32 %21, i32* %4
br label %22
22: ; preds = %17, %11, %2
%23 = load i32, i32* %4
%24 = icmp sle i32 %23, 1
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %25, %22
%32 = call i32 (...) @help()
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %25
%35 = load i32, i32* %6
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 @daemon(i32 0, i32 0)
br label %39
39: ; preds = %37, %34
%40 = load i32, i32* %4
%41 = sub nsw i32 %40, 1
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 1
%44 = call i32 @parse_commands(i32 %41, i8** %43)
%45 = call i64 (...) @setup_signals()
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %39
%48 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %39
%51 = call i32 @sigfillset(i32* %7)
%52 = load i32, i32* @SIG_BLOCK
%53 = call i32 @sigprocmask(i32 %52, i32* %7, i32* %8)
%54 = call i32 (...) @start()
%55 = load i32, i32* @SIG_SETMASK
%56 = call i32 @sigprocmask(i32 %55, i32* %8, i32* null)
br label %57
57: ; preds = %50, %57
%58 = call i32 @sleep(i32 1000000)
br label %57
}

LLVM IR (-O2):
@.str = [3 x i8] c"-d\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [14 x i8] c"setup_signals\00"
@SIG_BLOCK = global i32 0
@SIG_SETMASK = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %25
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = add nsw i32 %0, -1
%15 = icmp ult i32 %14, 2
br i1 %15, label %25, label %20
16: ; preds = %8
%17 = load i8*, i8** %9
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %25, label %30
20: ; preds = %13
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %2, %20, %16, %13
%26 = tail call i32 (...) @help()
%27 = tail call i32 @exit(i32 0)
unreachable
28: ; preds = %20
%29 = tail call i32 @daemon(i32 0, i32 0)
br label %30
30: ; preds = %16, %28
%31 = phi i32 [ %14, %28 ], [ %0, %16 ]
%32 = phi i8** [ %21, %28 ], [ %9, %16 ]
%33 = add nsw i32 %31, -1
%34 = tail call i32 @parse_commands(i32 %33, i8** %32)
%35 = tail call i64 (...) @setup_signals()
%36 = icmp eq i64 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %30
%38 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%39 = tail call i32 @exit(i32 1)
unreachable
40: ; preds = %30
%41 = call i32 @sigfillset(i32* %3)
%42 = load i32, i32* @SIG_BLOCK
%43 = call i32 @sigprocmask(i32 %42, i32* %3, i32* %4)
%44 = call i32 (...) @start()
%45 = load i32, i32* @SIG_SETMASK
%46 = call i32 @sigprocmask(i32 %45, i32* %4, i32* null)
br label %47
47: ; preds = %47, %40
%48 = call i32 @sleep(i32 1000000)
br label %47
}