#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execl(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int main(int argc, char **argv) {
  syslog(LOG_INFO, "init: starting...");
  pid_t f = fork();
  if (f == 0) {
    syslog(LOG_INFO, "init: starting preloadd...");
    execl("/applications/preloadd", "/applications/preloadd", 0);
    syslog(LOG_INFO, "init: loading preloadd failed: %s", strerror(errno));
    exit(errno);
  }
  syslog(LOG_INFO, "init: preloadd running with pid %d", f);
  f = fork();
  if (f == 0) {
    syslog(LOG_INFO, "init: starting winman...");
    execl("/applications/winman", "/applications/winman", 0);
    syslog(LOG_INFO, "init: loading winman failed: %s", strerror(errno));
    exit(errno);
  }
  syslog(LOG_INFO, "init: winman running with pid %d", f);
  syslog(LOG_INFO, "init: complete!");
  while (1)
    ;
  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)
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1030 <syslog@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f6 <main+0xa6>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1030 <syslog@plt>
lea    0xe7c(%rip),%rsi
xor    %edx,%edx
mov    %rsi,%rdi
call   1060 <execl@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%edx
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1030 <syslog@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1030 <syslog@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    128a <main+0x13a>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1030 <syslog@plt>
lea    0xe5d(%rip),%rsi
xor    %edx,%edx
mov    %rsi,%rdi
call   1060 <execl@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%edx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1030 <syslog@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    0x2d47(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1030 <syslog@plt>
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1030 <syslog@plt>
jmp    12bc <main+0x16c>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e7d(%rip),%rbx
mov    (%rbx),%edi
lea    0xe9c(%rip),%rsi
xor    %eax,%eax
call   1030 <syslog@plt>
xor    %eax,%eax
call   1070 <fork@plt>
mov    (%rbx),%edi
test   %rax,%rax
je     11c2 <main+0x72>
lea    0xee6(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <syslog@plt>
xor    %eax,%eax
call   1070 <fork@plt>
mov    (%rbx),%edi
test   %rax,%rax
je     11fb <main+0xab>
lea    0xf38(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <syslog@plt>
mov    (%rbx),%edi
lea    0xf46(%rip),%rsi
xor    %eax,%eax
call   1030 <syslog@plt>
nopl   0x0(%rax)
jmp    11c0 <main+0x70>
lea    0xe49(%rip),%rsi
xor    %eax,%eax
call   1030 <syslog@plt>
lea    0xe56(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1060 <execl@plt>
mov    (%rbx),%ebx
mov    0x2df6(%rip),%r14
mov    (%r14),%edi
call   1050 <strerror@plt>
lea    0xe4b(%rip),%rsi
jmp    1232 <main+0xe2>
lea    0xe87(%rip),%rsi
xor    %eax,%eax
call   1030 <syslog@plt>
lea    0xe92(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1060 <execl@plt>
mov    (%rbx),%ebx
mov    0x2dbd(%rip),%r14
mov    (%r14),%edi
call   1050 <strerror@plt>
lea    0xe85(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <syslog@plt>
mov    (%r14),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@LOG_INFO = global i32 0
@.str = [18 x i8] c"init: starting...\00"
@.str.1 = [27 x i8] c"init: starting preloadd...\00"
@.str.2 = [23 x i8] c"/applications/preloadd\00"
@.str.3 = [34 x i8] c"init: loading preloadd failed: %s\00"
@errno = global i32 0
@.str.4 = [35 x i8] c"init: preloadd running with pid %d\00"
@.str.5 = [25 x i8] c"init: starting winman...\00"
@.str.6 = [21 x i8] c"/applications/winman\00"
@.str.7 = [32 x i8] c"init: loading winman failed: %s\00"
@.str.8 = [33 x i8] c"init: winman running with pid %d\00"
@.str.9 = [16 x i8] c"init: complete!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @LOG_INFO
%8 = call i32 (i32, i8*, ...) @syslog(i32 %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = call i64 (...) @fork()
store i64 %9, i64* %6
%10 = load i64, i64* %6
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %2
%13 = load i32, i32* @LOG_INFO
%14 = call i32 (i32, i8*, ...) @syslog(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @execl(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 0)
%16 = load i32, i32* @LOG_INFO
%17 = load i32, i32* @errno
%18 = call i32 @strerror(i32 %17)
%19 = call i32 (i32, i8*, ...) @syslog(i32 %16, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* @errno
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = load i32, i32* @LOG_INFO
%24 = load i64, i64* %6
%25 = call i32 (i32, i8*, ...) @syslog(i32 %23, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i64 %24)
%26 = call i64 (...) @fork()
store i64 %26, i64* %6
%27 = load i64, i64* %6
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %22
%30 = load i32, i32* @LOG_INFO
%31 = call i32 (i32, i8*, ...) @syslog(i32 %30, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32 @execl(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 0)
%33 = load i32, i32* @LOG_INFO
%34 = load i32, i32* @errno
%35 = call i32 @strerror(i32 %34)
%36 = call i32 (i32, i8*, ...) @syslog(i32 %33, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @errno
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %22
%40 = load i32, i32* @LOG_INFO
%41 = load i64, i64* %6
%42 = call i32 (i32, i8*, ...) @syslog(i32 %40, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i64 %41)
%43 = load i32, i32* @LOG_INFO
%44 = call i32 (i32, i8*, ...) @syslog(i32 %43, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %45
45: ; preds = %39, %45
br label %45
}

LLVM IR (-O2):
@LOG_INFO = global i32 0
@.str = [18 x i8] c"init: starting...\00"
@.str.1 = [27 x i8] c"init: starting preloadd...\00"
@.str.2 = [23 x i8] c"/applications/preloadd\00"
@.str.3 = [34 x i8] c"init: loading preloadd failed: %s\00"
@errno = global i32 0
@.str.4 = [35 x i8] c"init: preloadd running with pid %d\00"
@.str.5 = [25 x i8] c"init: starting winman...\00"
@.str.6 = [21 x i8] c"/applications/winman\00"
@.str.7 = [32 x i8] c"init: loading winman failed: %s\00"
@.str.8 = [33 x i8] c"init: winman running with pid %d\00"
@.str.9 = [16 x i8] c"init: complete!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @LOG_INFO
%4 = tail call i32 (i32, i8*, ...) @syslog(i32 %3, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = tail call i64 (...) @fork()
%6 = icmp eq i64 %5, 0
%7 = load i32, i32* @LOG_INFO
br i1 %6, label %8, label %17
8: ; preds = %2
%9 = tail call i32 (i32, i8*, ...) @syslog(i32 %7, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @execl(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 0)
%11 = load i32, i32* @LOG_INFO
%12 = load i32, i32* @errno
%13 = tail call i32 @strerror(i32 %12)
%14 = tail call i32 (i32, i8*, ...) @syslog(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @errno
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %2
%18 = tail call i32 (i32, i8*, ...) @syslog(i32 %7, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i64 %5)
%19 = tail call i64 (...) @fork()
%20 = icmp eq i64 %19, 0
%21 = load i32, i32* @LOG_INFO
br i1 %20, label %22, label %31
22: ; preds = %17
%23 = tail call i32 (i32, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%24 = tail call i32 @execl(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 0)
%25 = load i32, i32* @LOG_INFO
%26 = load i32, i32* @errno
%27 = tail call i32 @strerror(i32 %26)
%28 = tail call i32 (i32, i8*, ...) @syslog(i32 %25, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @errno
%30 = tail call i32 @exit(i32 %29)
unreachable
31: ; preds = %17
%32 = tail call i32 (i32, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i64 %19)
%33 = load i32, i32* @LOG_INFO
%34 = tail call i32 (i32, i8*, ...) @syslog(i32 %33, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
br label %35
35: ; preds = %35, %31
br label %35
}