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

/* Variables and functions */
int /*<<< orphan*/ SIGHUP;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ close(int /*<<< orphan*/);
int errno;
int execl(char *, char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int /*<<< orphan*/ setsid();
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int main(int arg, char *argv[]) {
  pid_t pid = fork();
  if (pid != 0)
    _exit(0);
  setsid();
  signal(SIGHUP, SIG_IGN);
  pid = fork();
  if (pid != 0)
    _exit(0);
  umask(0);
  close(STDIN_FILENO);
  close(STDOUT_FILENO);
  close(STDERR_FILENO);
  int res = execl("resources/app/installUpdateNotificationLinux",
                  "resources/app/installUpdateNotificationLinux", (char *)NULL);
  FILE *file = fopen("execlerror", "w");
  fprintf(file, "%d %d", res, errno);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11c3 <main+0x33>
xor    %edi,%edi
call   1030 <_exit@plt>
mov    $0x0,%al
call   1050 <setsid@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
call   1060 <signal@plt>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11fe <main+0x6e>
xor    %edi,%edi
call   1030 <_exit@plt>
xor    %edi,%edi
call   1080 <umask@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
call   1040 <close@plt>
lea    0xdca(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    %rsi,%rdi
call   10a0 <execl@plt>
mov    %eax,-0x1c(%rbp)
lea    0xde1(%rip),%rdi
lea    0xde5(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    0x2d5e(%rip),%rax
mov    (%rax),%ecx
lea    0xdc7(%rip),%rsi
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   10b0 <fork@plt>
test   %rax,%rax
jne    1240 <main+0xb0>
xor    %eax,%eax
call   1050 <setsid@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
call   1060 <signal@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %rax,%rax
jne    1240 <main+0xb0>
xor    %edi,%edi
call   1080 <umask@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
call   1040 <close@plt>
lea    0xdfd(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   10a0 <execl@plt>
mov    %eax,%ebx
lea    0xe17(%rip),%rdi
lea    0xe1b(%rip),%rsi
call   1090 <fopen@plt>
mov    0x2d9f(%rip),%rcx
mov    (%rcx),%ecx
lea    0xe08(%rip),%rsi
mov    %rax,%rdi
mov    %ebx,%edx
call   1070 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %edi,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@SIGHUP = global i32 0
@SIG_IGN = global i32 0
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str = [45 x i8] c"resources/app/installUpdateNotificationLinux\00"
@.str.1 = [11 x i8] c"execlerror\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [6 x i8] c"%d %d\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i64 (...) @fork()
store i64 %9, i64* %6
%10 = load i64, i64* %6
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @_exit(i32 0)
unreachable
14: ; preds = %2
%15 = call i32 (...) @setsid()
%16 = load i32, i32* @SIGHUP
%17 = load i32, i32* @SIG_IGN
%18 = call i32 @signal(i32 %16, i32 %17)
%19 = call i64 (...) @fork()
store i64 %19, i64* %6
%20 = load i64, i64* %6
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = call i32 @_exit(i32 0)
unreachable
24: ; preds = %14
%25 = call i32 @umask(i32 0)
%26 = load i32, i32* @STDIN_FILENO
%27 = call i32 @close(i32 %26)
%28 = load i32, i32* @STDOUT_FILENO
%29 = call i32 @close(i32 %28)
%30 = load i32, i32* @STDERR_FILENO
%31 = call i32 @close(i32 %30)
%32 = call i32 @execl(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* null)
store i32 %32, i32* %7
%33 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %33, i32** %8
%34 = load i32*, i32** %8
%35 = load i32, i32* %7
%36 = load i32, i32* @errno
%37 = call i32 @fprintf(i32* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %36)
ret i32 0
}

LLVM IR (-O2):
@SIGHUP = global i32 0
@SIG_IGN = global i32 0
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str = [45 x i8] c"resources/app/installUpdateNotificationLinux\00"
@.str.1 = [11 x i8] c"execlerror\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [6 x i8] c"%d %d\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @fork()
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @_exit(i32 0)
unreachable
7: ; preds = %2
%8 = tail call i32 (...) @setsid()
%9 = load i32, i32* @SIGHUP
%10 = load i32, i32* @SIG_IGN
%11 = tail call i32 @signal(i32 %9, i32 %10)
%12 = tail call i64 (...) @fork()
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %7
%15 = tail call i32 @_exit(i32 0)
unreachable
16: ; preds = %7
%17 = tail call i32 @umask(i32 0)
%18 = load i32, i32* @STDIN_FILENO
%19 = tail call i32 @close(i32 %18)
%20 = load i32, i32* @STDOUT_FILENO
%21 = tail call i32 @close(i32 %20)
%22 = load i32, i32* @STDERR_FILENO
%23 = tail call i32 @close(i32 %22)
%24 = tail call i32 @execl(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* null)
%25 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* @errno
%27 = tail call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %26)
ret i32 0
}