#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*/ ECHILD;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execl(char *, char *, char *, char *);
int fork();
int start_visualizer_process(char *fileArg) {
  int pidFiglio;
  if ((pidFiglio = fork()) == -1) {
    errno = ECHILD;
  } else if (pidFiglio == 0) {
    execl("./visualizer", "./visualizer", fileArg, (char *)NULL);
    errno = ECHILD;
    pidFiglio = 0;
  }
  return pidFiglio;
}


x86 assembly (clang, -O0):
<start_visualizer_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <fork@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    1156 <start_visualizer_process+0x36>
mov    0x2e92(%rip),%rax
mov    (%rax),%ecx
mov    0x2e91(%rip),%rax
mov    %ecx,(%rax)
jmp    1195 <start_visualizer_process+0x75>
cmpl   $0x0,-0xc(%rbp)
jne    1190 <start_visualizer_process+0x70>
mov    -0x8(%rbp),%rdx
lea    0xe95(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rsi,%rdi
call   1030 <execl@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%ecx
mov    0x2e59(%rip),%rax
mov    %ecx,(%rax)
movl   $0x0,-0xc(%rbp)
jmp    1195 <start_visualizer_process+0x75>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_visualizer_process>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1040 <fork@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     114d <start_visualizer_process+0x2d>
test   %ebx,%ebx
jne    115f <start_visualizer_process+0x3f>
lea    0xec0(%rip),%rdi
mov    %rdi,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1030 <execl@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    0x2e83(%rip),%rcx
mov    %eax,(%rcx)
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@ECHILD = global i32 0
@errno = global i32 0
@.str = [13 x i8] c"./visualizer\00"
define i32 @start_visualizer_process(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 (...) @fork()
store i32 %4, i32* %3
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load i32, i32* @ECHILD
store i32 %7, i32* @errno
br label %16
8: ; preds = %1
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i8*, i8** %2
%13 = call i32 @execl(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %12, i8* null)
%14 = load i32, i32* @ECHILD
store i32 %14, i32* @errno
store i32 0, i32* %3
br label %15
15: ; preds = %11, %8
br label %16
16: ; preds = %15, %6
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
@ECHILD = global i32 0
@errno = global i32 0
@.str = [13 x i8] c"./visualizer\00"
define i32 @start_visualizer_process(i8* %0) {
%2 = tail call i32 (...) @fork()
switch i32 %2, label %7 [
i32 -1, label %5
i32 0, label %3
]
3: ; preds = %1
%4 = tail call i32 @execl(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, i8* null)
br label %5
5: ; preds = %1, %3
%6 = load i32, i32* @ECHILD
store i32 %6, i32* @errno
br label %7
7: ; preds = %5, %1
ret i32 %2
}