#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 execvp(char *, char **);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ wait(int *);
void exec_cmd(int argc, char **argv) {
  pid_t p;
  p = 0;
  p = fork();
  int *status;
  wait(status);
  if (p == 0) {
    if (execvp(argv[0], argv) == -1) {
      printf("No such file: (%s)\n", argv[0]);
    }
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<exec_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <wait@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11bc <exec_cmd+0x6c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <execvp@plt>
cmp    $0xffffffff,%eax
jne    11b2 <exec_cmd+0x62>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec_cmd>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
xor    %eax,%eax
call   1070 <fork@plt>
mov    %rax,%rbx
call   1060 <wait@plt>
test   %rbx,%rbx
je     1173 <exec_cmd+0x23>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    (%r14),%rdi
mov    %r14,%rsi
call   1040 <execvp@plt>
cmp    $0xffffffff,%eax
jne    1192 <exec_cmd+0x42>
mov    (%r14),%rsi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"No such file: (%s)\0A\00"
define void @exec_cmd(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64
%6 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i64 0, i64* %5
%7 = call i64 (...) @fork()
store i64 %7, i64* %5
%8 = load i32*, i32** %6
%9 = call i32 @wait(i32* %8)
%10 = load i64, i64* %5
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = load i8**, i8*** %4
%17 = call i32 @execvp(i8* %15, i8** %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = load i8**, i8*** %4
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %19, %12
%25 = call i32 @exit(i32 -1)
unreachable
26: ; preds = %2
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"No such file: (%s)\0A\00"
define void @exec_cmd(i32 %0, i8** %1) {
%3 = tail call i64 (...) @fork()
%4 = tail call i32 @wait(i32* undef)
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %15
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @execvp(i8* %7, i8** %1)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i8*, i8** %1
%12 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %6
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
ret void
}