#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*/ LOG_DEBUG;
int /*<<< orphan*/ LOG_ERR;
int WEXITSTATUS(int);
int /*<<< orphan*/ _debug(char *, int, int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
scalar_t__ execvp(char *, char *const *);
int /*<<< orphan*/ exit(int);
int safe_fork();
int strerror(int /*<<< orphan*/);
int waitpid(int, int *, int /*<<< orphan*/);
int execute(char *cmd_line, int quiet) {
  int pid, status, rc;
  const char *new_argv[4];
  new_argv[0] = "/bin/sh";
  new_argv[1] = "-c";
  new_argv[2] = cmd_line;
  new_argv[3] = NULL;
  pid = safe_fork();
  if (pid == 0) {
    if (quiet)
      close(2);
    if (execvp("/bin/sh", (char *const *)new_argv) < 0) {
      _debug("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/sxpert/wifidog-ffw/refs/heads/master/"
             "src/util.c",
             104, LOG_ERR, "execvp(): %s", strerror(errno));
      exit(1);
    }
  } else {
    _debug("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/sxpert/wifidog-ffw/refs/heads/master/src/"
           "util.c",
           109, LOG_DEBUG, "Waiting for PID %d to exit", pid);
    rc = waitpid(pid, &status, 0);
    _debug("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/sxpert/wifidog-ffw/refs/heads/master/src/"
           "util.c",
           111, LOG_DEBUG, "Process PID %d exited", rc);
  }
  return (WEXITSTATUS(status));
}


x86 assembly (clang, -O0):
<execute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xe6a(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe67(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1050 <safe_fork@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    123e <execute+0xbe>
cmpl   $0x0,-0xc(%rbp)
je     11dd <execute+0x5d>
mov    $0x2,%edi
call   1030 <close@plt>
lea    -0x40(%rbp),%rsi
lea    0xe18(%rip),%rdi
call   1080 <execvp@plt>
cmp    $0x0,%rax
jge    1239 <execute+0xb9>
mov    0x2dca(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x44(%rbp),%edx
mov    %eax,%r8d
lea    0xded(%rip),%rdi
mov    $0x68,%esi
lea    0xe6b(%rip),%rcx
call   1040 <_debug@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    1299 <execute+0x119>
mov    0x2d93(%rip),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%r8d
lea    0xdb9(%rip),%rdi
mov    $0x6d,%esi
lea    0xe44(%rip),%rcx
call   1040 <_debug@plt>
mov    -0x10(%rbp),%edi
lea    -0x14(%rbp),%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d5d(%rip),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%r8d
lea    0xd83(%rip),%rdi
mov    $0x6f,%esi
lea    0xe29(%rip),%rcx
call   1040 <_debug@plt>
mov    -0x14(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %esi,%ebp
lea    0xe6f(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe6b(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %rdi,0x20(%rsp)
movq   $0x0,0x28(%rsp)
xor    %eax,%eax
call   1050 <safe_fork@plt>
test   %eax,%eax
je     121f <execute+0x9f>
mov    %eax,%ebx
mov    0x2e14(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xe3d(%rip),%r14
lea    0xecd(%rip),%rcx
mov    %r14,%rdi
mov    $0x6d,%esi
mov    %eax,%r8d
call   1040 <_debug@plt>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   1070 <waitpid@plt>
mov    0x0(%rbp),%edx
lea    0xec0(%rip),%rcx
mov    %r14,%rdi
mov    $0x6f,%esi
mov    %eax,%r8d
call   1040 <_debug@plt>
mov    0xc(%rsp),%edi
call   1060 <WEXITSTATUS@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
test   %ebp,%ebp
je     122d <execute+0xad>
mov    $0x2,%edi
call   1030 <close@plt>
lea    0xdcc(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1080 <execvp@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%ebx
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xdaf(%rip),%rdi
lea    0xe32(%rip),%rcx
mov    $0x68,%esi
mov    %ebx,%edx
mov    %eax,%r8d
call   1040 <_debug@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sxpert/wifidog-ffw/refs/heads/master/src/util.c\00"
@LOG_ERR = global i32 0
@.str.3 = [13 x i8] c"execvp(): %s\00"
@errno = global i32 0
@LOG_DEBUG = global i32 0
@.str.4 = [27 x i8] c"Waiting for PID %d to exit\00"
@.str.5 = [22 x i8] c"Process PID %d exited\00"
define i32 @execute(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [4 x i8*]
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = load i8*, i8** %3
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 2
store i8* %11, i8** %12
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 3
store i8* null, i8** %13
%14 = call i32 (...) @safe_fork()
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %2
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @close(i32 2)
br label %22
22: ; preds = %20, %17
%23 = getelementptr inbounds [4 x i8*], [4 x i8*]* %8, i64 0, i64 0
%24 = call i64 @execvp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %23)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i32, i32* @LOG_ERR
%28 = load i32, i32* @errno
%29 = call i32 @strerror(i32 %28)
%30 = call i32 @_debug(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i32 104, i32 %27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %22
br label %42
33: ; preds = %2
%34 = load i32, i32* @LOG_DEBUG
%35 = load i32, i32* %5
%36 = call i32 @_debug(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i32 109, i32 %34, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %5
%38 = call i32 @waitpid(i32 %37, i32* %6, i32 0)
store i32 %38, i32* %7
%39 = load i32, i32* @LOG_DEBUG
%40 = load i32, i32* %7
%41 = call i32 @_debug(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i32 111, i32 %39, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %33, %32
%43 = load i32, i32* %6
%44 = call i32 @WEXITSTATUS(i32 %43)
ret i32 %44
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sxpert/wifidog-ffw/refs/heads/master/src/util.c\00"
@LOG_ERR = global i32 0
@.str.3 = [13 x i8] c"execvp(): %s\00"
@errno = global i32 0
@LOG_DEBUG = global i32 0
@.str.4 = [27 x i8] c"Waiting for PID %d to exit\00"
@.str.5 = [22 x i8] c"Process PID %d exited\00"
define i32 @execute(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca [4 x i8*]
%5 = bitcast i32* %3 to i8*
%6 = bitcast [4 x i8*]* %4 to i8*
%7 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 2
store i8* %0, i8** %9
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 3
store i8* null, i8** %10
%11 = tail call i32 (...) @safe_fork()
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %2
%14 = icmp eq i32 %1, 0
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = tail call i32 @close(i32 2)
br label %17
17: ; preds = %15, %13
%18 = call i64 @execvp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %7)
%19 = icmp slt i64 %18, 0
%20 = load i32, i32* @LOG_ERR
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = call i32 @_debug(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i32 104, i32 %20, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = load i32, i32* @LOG_DEBUG
%27 = tail call i32 @_debug(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i32 109, i32 %26, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%28 = call i32 @waitpid(i32 %11, i32* %3, i32 0)
%29 = load i32, i32* @LOG_DEBUG
%30 = call i32 @_debug(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.2, i64 0, i64 0), i32 111, i32 %29, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %28)
%31 = load i32, i32* %3
%32 = call i32 @WEXITSTATUS(i32 %31)
ret i32 %32
}