#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*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int execvp(char *, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ redirect(int, int /*<<< orphan*/);
void run(char **argv, int in, int out) {
  redirect(in, STDIN_FILENO);
  redirect(out, STDOUT_FILENO);
  if (execvp(argv[0], argv) == -1) {
    perror(argv[0]);
  }
  exit(1);
}


x86 assembly (clang, -O0):
<run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
call   1030 <redirect@plt>
mov    -0x10(%rbp),%edi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1030 <redirect@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <execvp@plt>
cmp    $0xffffffff,%eax
jne    1199 <run+0x59>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<run>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%eax
mov    %rdi,%rbx
mov    0x2e87(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1030 <redirect@plt>
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   1030 <redirect@plt>
mov    (%rbx),%rdi
mov    %rbx,%rsi
call   1050 <execvp@plt>
cmp    $0xffffffff,%eax
jne    1182 <run+0x42>
mov    (%rbx),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
define void @run(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = load i32, i32* @STDIN_FILENO
%9 = call i32 @redirect(i32 %7, i32 %8)
%10 = load i32, i32* %6
%11 = load i32, i32* @STDOUT_FILENO
%12 = call i32 @redirect(i32 %10, i32 %11)
%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 = %3
%20 = load i8**, i8*** %4
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @perror(i8* %22)
br label %24
24: ; preds = %19, %3
%25 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
define void @run(i8** %0, i32 %1, i32 %2) {
%4 = load i32, i32* @STDIN_FILENO
%5 = tail call i32 @redirect(i32 %1, i32 %4)
%6 = load i32, i32* @STDOUT_FILENO
%7 = tail call i32 @redirect(i32 %2, i32 %6)
%8 = load i8*, i8** %0
%9 = tail call i32 @execvp(i8* %8, i8** %0)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8*, i8** %0
%13 = tail call i32 @perror(i8* %12)
br label %14
14: ; preds = %11, %3
%15 = tail call i32 @exit(i32 1)
unreachable
}