#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 pid_t;

/* Variables and functions */
int /*<<< orphan*/ _PATH_BSHELL;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ execl(int /*<<< orphan*/, char *, char *, char const *,
                         int /*<<< orphan*/ *);
int fork();
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int uefiop_exec(const char *command) {
  pid_t pid;
  pid = fork();
  switch (pid) {
  case -1:
    return -1;
  case 0:
    execl(_PATH_BSHELL, "sh", "-c", command, NULL);
    _exit(-1);
  default:
    wait(NULL);
    return 0;
  }
}


x86 assembly (clang, -O0):
<uefiop_exec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
call   1060 <fork@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0xffffffff,%eax
je     117a <uefiop_exec+0x3a>
jmp    116a <uefiop_exec+0x2a>
mov    -0x18(%rbp),%eax
test   %eax,%eax
je     1186 <uefiop_exec+0x46>
jmp    11b5 <uefiop_exec+0x75>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c5 <uefiop_exec+0x85>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rcx
lea    0xe66(%rip),%rsi
lea    0xe62(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <execl@plt>
mov    $0xffffffff,%edi
call   1030 <_exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uefiop_exec>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1060 <fork@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1162 <uefiop_exec+0x22>
test   %ebx,%ebx
je     116c <uefiop_exec+0x2c>
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <wait@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
lea    0xe80(%rip),%rdx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1040 <execl@plt>
mov    $0xffffffff,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@_PATH_BSHELL = global i32 0
@.str = [3 x i8] c"sh\00"
@.str.1 = [3 x i8] c"-c\00"
define i32 @uefiop_exec(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = call i32 (...) @fork()
store i32 %5, i32* %4
%6 = load i32, i32* %4
switch i32 %6, label %13 [
i32 -1, label %7
i32 0, label %8
]
7: ; preds = %1
store i32 -1, i32* %2
br label %15
8: ; preds = %1
%9 = load i32, i32* @_PATH_BSHELL
%10 = load i8*, i8** %3
%11 = call i32 @execl(i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32* null)
%12 = call i32 @_exit(i32 -1)
unreachable
13: ; preds = %1
%14 = call i32 @wait(i32* null)
store i32 0, i32* %2
br label %15
15: ; preds = %13, %7
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
@_PATH_BSHELL = global i32 0
@.str = [3 x i8] c"sh\00"
@.str.1 = [3 x i8] c"-c\00"
define i32 @uefiop_exec(i8* %0) {
%2 = tail call i32 (...) @fork()
switch i32 %2, label %7 [
i32 -1, label %9
i32 0, label %3
]
3: ; preds = %1
%4 = load i32, i32* @_PATH_BSHELL
%5 = tail call i32 @execl(i32 %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32* null)
%6 = tail call i32 @_exit(i32 -1)
unreachable
7: ; preds = %1
%8 = tail call i32 @wait(i32* null)
br label %9
9: ; preds = %1, %7
%10 = phi i32 [ 0, %7 ], [ %2, %1 ]
ret i32 %10
}