#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*/ EX_OSERR;
int daemon(int, int);
int /*<<< orphan*/ err(int /*<<< orphan*/, char *);
int /*<<< orphan*/ execvp(char *, char **);
int main(int argc, char **argv) {
  int rc;
  rc = daemon(true, true);
  if (rc == -1)
    err(EX_OSERR, "daemon(2)");
  execvp(argv[1], argv + 1);
  err(EX_OSERR, "execvp(3)");
}


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)
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <daemon@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1174 <main+0x44>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1030 <err@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1050 <execvp@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
call   1030 <err@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <daemon@plt>
cmp    $0xffffffff,%eax
jne    115d <main+0x2d>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
call   1030 <err@plt>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
mov    %rbx,%rsi
call   1050 <execvp@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1030 <err@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@EX_OSERR = global i32 0
@.str = [10 x i8] c"daemon(2)\00"
@.str.1 = [10 x i8] c"execvp(3)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @daemon(i32 1, i32 1)
store i32 %7, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @EX_OSERR
%12 = call i32 @err(i32 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %10, %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = call i32 @execvp(i8* %16, i8** %18)
%20 = load i32, i32* @EX_OSERR
%21 = call i32 @err(i32 %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@EX_OSERR = global i32 0
@.str = [10 x i8] c"daemon(2)\00"
@.str.1 = [10 x i8] c"execvp(3)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @daemon(i32 1, i32 1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @EX_OSERR
%7 = tail call i32 @err(i32 %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @execvp(i8* %10, i8** %9)
%12 = load i32, i32* @EX_OSERR
%13 = tail call i32 @err(i32 %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}