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

/* Variables and functions */
int /*<<< orphan*/ SIG_SETMASK;
int /*<<< orphan*/ _exit(int);
size_t errno;
int /*<<< orphan*/ execlp(char *, char *, char *, char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ *sys_errlist;
unsigned int sys_nerr;
int /*<<< orphan*/ system_log(char *, char *, int, char *, char *, ...);
pid_t make_process(char *progname, char *directory, sigset_t *oldmask) {
  pid_t pid;
  switch (pid = fork()) {
  case -1:
    system_log("<F>",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/master/"
               "src/init_afd/init_afd.c",
               2045, ("Could not create a new process : %s"),
               sys_errlist[((unsigned)(errno) < sys_nerr) ? (errno) : 0]);
    exit(-1);
  case 0:
    if (oldmask != NULL) {
      if (sigprocmask(SIG_SETMASK, oldmask, NULL) < 0) {
        system_log("<E>",
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/"
                   "master/src/init_afd/init_afd.c",
                   2055, ("sigprocmask() error : %s"),
                   sys_errlist[((unsigned)(errno) < sys_nerr) ? (errno) : 0]);
      }
    }
    if (execlp(progname, progname, "-w", directory, (char *)0) < 0) {
      system_log("<E>",
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/master/"
                 "src/init_afd/init_afd.c",
                 2062, ("Failed to start process %s : %s"), progname,
                 sys_errlist[((unsigned)(errno) < sys_nerr) ? (errno) : 0]);
      _exit(-1);
    }
    exit(0);
  default:
    return (pid);
  }
}


x86 assembly (clang, -O0):
<make_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
call   1080 <fork@plt>
mov    %eax,-0x1c(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x20(%rbp)
sub    $0xffffffff,%eax
je     11a1 <make_process+0x41>
jmp    1191 <make_process+0x31>
mov    -0x20(%rbp),%eax
test   %eax,%eax
je     121d <make_process+0xbd>
jmp    1373 <make_process+0x213>
mov    0x2e50(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e12(%rip),%rax
mov    (%rax),%rax
mov    0x2e28(%rip),%rcx
cmp    (%rcx),%eax
jae    11db <make_process+0x7b>
mov    0x2df9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    11e6 <make_process+0x86>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    11e6 <make_process+0x86>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movslq (%rax,%rcx,4),%r8
lea    0xe07(%rip),%rdi
lea    0xe04(%rip),%rsi
mov    $0x7fd,%edx
lea    0xe84(%rip),%rcx
mov    $0x0,%al
call   1050 <system_log@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
je     12be <make_process+0x15e>
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
cmp    $0x0,%eax
jge    12b9 <make_process+0x159>
mov    0x2daa(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2d6c(%rip),%rax
mov    (%rax),%rax
mov    0x2d82(%rip),%rcx
cmp    (%rcx),%eax
jae    1281 <make_process+0x121>
mov    0x2d53(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
jmp    128c <make_process+0x12c>
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
jmp    128c <make_process+0x12c>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
movslq (%rax,%rcx,4),%r8
lea    0xe15(%rip),%rdi
lea    0xd5e(%rip),%rsi
mov    $0x807,%edx
lea    0xe06(%rip),%rcx
mov    $0x0,%al
call   1050 <system_log@plt>
jmp    12be <make_process+0x15e>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rcx
lea    0xe00(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1070 <execlp@plt>
cmp    $0x0,%eax
jge    136c <make_process+0x20c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    0x2d05(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2cc7(%rip),%rax
mov    (%rax),%rax
mov    0x2cdd(%rip),%rcx
cmp    (%rcx),%eax
jae    1326 <make_process+0x1c6>
mov    0x2cae(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    1331 <make_process+0x1d1>
xor    %eax,%eax
mov    %rax,-0x58(%rbp)
jmp    1331 <make_process+0x1d1>
mov    -0x50(%rbp),%r8
mov    -0x48(%rbp),%rax
mov    -0x58(%rbp),%rcx
mov    (%rax,%rcx,4),%r9d
lea    0xd6c(%rip),%rdi
lea    0xcb5(%rip),%rsi
mov    $0x80e,%edx
lea    0xd79(%rip),%rcx
mov    $0x0,%al
call   1050 <system_log@plt>
mov    $0xffffffff,%edi
call   1040 <_exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x1c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_process>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
je     1188 <make_process+0x28>
cmp    $0xffffffff,%eax
je     1261 <make_process+0x101>
pop    %rbx
pop    %r14
pop    %r15
ret
test   %rbx,%rbx
je     11ec <make_process+0x8c>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
test   %eax,%eax
jns    11ec <make_process+0x8c>
mov    0x2e4d(%rip),%rax
mov    (%rax),%rax
mov    0x2e13(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e29(%rip),%rdx
xor    %esi,%esi
cmp    %ecx,(%rdx)
cmovbe %rsi,%rcx
movslq (%rax,%rcx,4),%r8
lea    0xee2(%rip),%rdi
lea    0xe2b(%rip),%rsi
lea    0xed8(%rip),%rcx
mov    $0x807,%edx
xor    %eax,%eax
call   1050 <system_log@plt>
lea    0xede(%rip),%rdx
mov    %r14,%rdi
mov    %r14,%rsi
mov    %r15,%rcx
xor    %r8d,%r8d
call   1070 <execlp@plt>
test   %eax,%eax
jns    12b3 <make_process+0x153>
mov    0x2de5(%rip),%rax
mov    (%rax),%rax
mov    0x2dab(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2dc1(%rip),%rdx
xor    %esi,%esi
cmp    %ecx,(%rdx)
cmovbe %rsi,%rcx
mov    (%rax,%rcx,4),%r9d
lea    0xe7a(%rip),%rdi
lea    0xdc3(%rip),%rsi
lea    0xe8c(%rip),%rcx
mov    $0x80e,%edx
mov    %r14,%r8
xor    %eax,%eax
call   1050 <system_log@plt>
mov    $0xffffffff,%edi
call   1040 <_exit@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%rax
mov    0x2d56(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2d6c(%rip),%rdx
xor    %esi,%esi
cmp    %ecx,(%rdx)
cmovbe %rsi,%rcx
movslq (%rax,%rcx,4),%r8
lea    0xd71(%rip),%rdi
lea    0xd6e(%rip),%rsi
lea    0xdf3(%rip),%rcx
mov    $0x7fd,%edx
xor    %eax,%eax
call   1050 <system_log@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"<F>\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/master/src/init_afd/init_afd.c\00"
@.str.2 = [36 x i8] c"Could not create a new process : %s\00"
@sys_errlist = global i32* null
@errno = global i64 0
@sys_nerr = global i32 0
@SIG_SETMASK = global i32 0
@.str.3 = [4 x i8] c"<E>\00"
@.str.4 = [25 x i8] c"sigprocmask() error : %s\00"
@.str.5 = [3 x i8] c"-w\00"
@.str.6 = [32 x i8] c"Failed to start process %s : %s\00"
define i32 @make_process(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = call i32 (...) @fork()
store i32 %8, i32* %7
switch i32 %8, label %75 [
i32 -1, label %9
i32 0, label %26
]
9: ; preds = %3
%10 = load i32*, i32** @sys_errlist
%11 = load i64, i64* @errno
%12 = trunc i64 %11 to i32
%13 = load i32, i32* @sys_nerr
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = load i64, i64* @errno
br label %18
17: ; preds = %9
br label %18
18: ; preds = %17, %15
%19 = phi i64 [ %16, %15 ], [ 0, %17 ]
%20 = getelementptr inbounds i32, i32* %10, i64 %19
%21 = load i32, i32* %20
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i8*
%24 = call i32 (i8*, i8*, i32, i8*, i8*, ...) @system_log(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 2045, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 -1)
unreachable
26: ; preds = %3
%27 = load i32*, i32** %6
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %51
29: ; preds = %26
%30 = load i32, i32* @SIG_SETMASK
%31 = load i32*, i32** %6
%32 = call i32 @sigprocmask(i32 %30, i32* %31, i32* null)
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %50
34: ; preds = %29
%35 = load i32*, i32** @sys_errlist
%36 = load i64, i64* @errno
%37 = trunc i64 %36 to i32
%38 = load i32, i32* @sys_nerr
%39 = icmp ult i32 %37, %38
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = load i64, i64* @errno
br label %43
42: ; preds = %34
br label %43
43: ; preds = %42, %40
%44 = phi i64 [ %41, %40 ], [ 0, %42 ]
%45 = getelementptr inbounds i32, i32* %35, i64 %44
%46 = load i32, i32* %45
%47 = sext i32 %46 to i64
%48 = inttoptr i64 %47 to i8*
%49 = call i32 (i8*, i8*, i32, i8*, i8*, ...) @system_log(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 2055, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %43, %29
br label %51
51: ; preds = %50, %26
%52 = load i8*, i8** %4
%53 = load i8*, i8** %4
%54 = load i8*, i8** %5
%55 = call i32 @execlp(i8* %52, i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %54, i8* null)
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %73
57: ; preds = %51
%58 = load i8*, i8** %4
%59 = load i32*, i32** @sys_errlist
%60 = load i64, i64* @errno
%61 = trunc i64 %60 to i32
%62 = load i32, i32* @sys_nerr
%63 = icmp ult i32 %61, %62
br i1 %63, label %64, label %66
64: ; preds = %57
%65 = load i64, i64* @errno
br label %67
66: ; preds = %57
br label %67
67: ; preds = %66, %64
%68 = phi i64 [ %65, %64 ], [ 0, %66 ]
%69 = getelementptr inbounds i32, i32* %59, i64 %68
%70 = load i32, i32* %69
%71 = call i32 (i8*, i8*, i32, i8*, i8*, ...) @system_log(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 2062, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %58, i32 %70)
%72 = call i32 @_exit(i32 -1)
unreachable
73: ; preds = %51
%74 = call i32 @exit(i32 0)
unreachable
75: ; preds = %3
%76 = load i32, i32* %7
ret i32 %76
}

LLVM IR (-O2):
@.str = [4 x i8] c"<F>\00"
@.str.1 = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/hfs/afd/refs/heads/master/src/init_afd/init_afd.c\00"
@.str.2 = [36 x i8] c"Could not create a new process : %s\00"
@sys_errlist = global i32* null
@errno = global i64 0
@sys_nerr = global i32 0
@SIG_SETMASK = global i32 0
@.str.3 = [4 x i8] c"<E>\00"
@.str.4 = [25 x i8] c"sigprocmask() error : %s\00"
@.str.5 = [3 x i8] c"-w\00"
@.str.6 = [32 x i8] c"Failed to start process %s : %s\00"
define i32 @make_process(i8* %0, i8* %1, i32* %2) {
%4 = tail call i32 (...) @fork()
switch i32 %4, label %52 [
i32 -1, label %5
i32 0, label %18
]
5: ; preds = %3
%6 = load i32*, i32** @sys_errlist
%7 = load i64, i64* @errno
%8 = trunc i64 %7 to i32
%9 = load i32, i32* @sys_nerr
%10 = icmp ugt i32 %9, %8
%11 = select i1 %10, i64 %7, i64 0
%12 = getelementptr inbounds i32, i32* %6, i64 %11
%13 = load i32, i32* %12
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i8*
%16 = tail call i32 (i8*, i8*, i32, i8*, i8*, ...) @system_log(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 2045, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 -1)
unreachable
18: ; preds = %3
%19 = icmp eq i32* %2, null
br i1 %19, label %36, label %20
20: ; preds = %18
%21 = load i32, i32* @SIG_SETMASK
%22 = tail call i32 @sigprocmask(i32 %21, i32* %2, i32* null)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %20
%25 = load i32*, i32** @sys_errlist
%26 = load i64, i64* @errno
%27 = trunc i64 %26 to i32
%28 = load i32, i32* @sys_nerr
%29 = icmp ugt i32 %28, %27
%30 = select i1 %29, i64 %26, i64 0
%31 = getelementptr inbounds i32, i32* %25, i64 %30
%32 = load i32, i32* %31
%33 = sext i32 %32 to i64
%34 = inttoptr i64 %33 to i8*
%35 = tail call i32 (i8*, i8*, i32, i8*, i8*, ...) @system_log(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 2055, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %20, %24, %18
%37 = tail call i32 @execlp(i8* %0, i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* null)
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %50
39: ; preds = %36
%40 = load i32*, i32** @sys_errlist
%41 = load i64, i64* @errno
%42 = trunc i64 %41 to i32
%43 = load i32, i32* @sys_nerr
%44 = icmp ugt i32 %43, %42
%45 = select i1 %44, i64 %41, i64 0
%46 = getelementptr inbounds i32, i32* %40, i64 %45
%47 = load i32, i32* %46
%48 = tail call i32 (i8*, i8*, i32, i8*, i8*, ...) @system_log(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str.1, i64 0, i64 0), i32 2062, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %0, i32 %47)
%49 = tail call i32 @_exit(i32 -1)
unreachable
50: ; preds = %36
%51 = tail call i32 @exit(i32 0)
unreachable
52: ; preds = %3
ret i32 %4
}