#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*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ log_message(int /*<<< orphan*/, char *);
int /*<<< orphan*/ script_setup();
int /*<<< orphan*/ system_call(char *);
int notify_exec(char *cmd) {
  pid_t pid;
  pid = fork();
  if (pid < 0) {
    log_message(LOG_INFO, "Failed fork process");
    return -1;
  }
  if (pid)
    return 0;
  script_setup();
  system_call(cmd);
  exit(0);
}


x86 assembly (clang, -O0):
<notify_exec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    1193 <notify_exec+0x43>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
call   1050 <log_message@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c1 <notify_exec+0x71>
cmpq   $0x0,-0x18(%rbp)
je     11aa <notify_exec+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    11c1 <notify_exec+0x71>
mov    $0x0,%al
call   1040 <script_setup@plt>
mov    -0x10(%rbp),%rdi
call   1030 <system_call@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<notify_exec>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
js     117c <notify_exec+0x2c>
jne    1196 <notify_exec+0x46>
xor    %eax,%eax
call   1040 <script_setup@plt>
mov    %rbx,%rdi
call   1030 <system_call@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
call   1050 <log_message@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@LOG_INFO = global i32 0
@.str = [20 x i8] c"Failed fork process\00"
define i32 @notify_exec(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
%5 = call i64 (...) @fork()
store i64 %5, i64* %4
%6 = load i64, i64* %4
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* @LOG_INFO
%10 = call i32 @log_message(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %20
11: ; preds = %1
%12 = load i64, i64* %4
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 0, i32* %2
br label %20
15: ; preds = %11
%16 = call i32 (...) @script_setup()
%17 = load i8*, i8** %3
%18 = call i32 @system_call(i8* %17)
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %14, %8
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@LOG_INFO = global i32 0
@.str = [20 x i8] c"Failed fork process\00"
define i32 @notify_exec(i8* %0) {
%2 = tail call i64 (...) @fork()
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = load i32, i32* @LOG_INFO
%6 = tail call i32 @log_message(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %13
7: ; preds = %1
%8 = icmp eq i64 %2, 0
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = tail call i32 (...) @script_setup()
%11 = tail call i32 @system_call(i8* %0)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %7, %4
%14 = phi i32 [ -1, %4 ], [ 0, %7 ]
ret i32 %14
}