#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*/ execvp(char *, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int getchar();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ redirect_output(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (redirect_output(argv[1]))
    fprintf(stderr, "%s: Failed to open %s\n", argv[0], argv[1]);
  printf("Please press Enter to activate this console.\n");
  while (getchar() != 0xA)
    ;
  execvp(argv[2], &argv[2]);
  printf("%s: Failed to execute %s\n", argv[0], argv[2]);
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <redirect_output@plt>
cmp    $0x0,%rax
je     11a1 <main+0x51>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe64(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     11c4 <main+0x74>
jmp    11af <main+0x5f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x10,%rsi
call   1060 <execvp@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1080 <redirect_output@plt>
test   %rax,%rax
je     118e <main+0x2e>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    0x8(%rbx),%rcx
lea    0xe77(%rip),%rsi
call   1060 <fprintf@plt>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%eax
jne    11a0 <main+0x40>
lea    0x10(%rbx),%rsi
mov    0x10(%rbx),%rdi
call   1070 <execvp@plt>
mov    (%rbx),%rsi
mov    0x10(%rbx),%rdx
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"%s: Failed to open %s\0A\00"
@.str.1 = [46 x i8] c"Please press Enter to activate this console.\0A\00"
@.str.2 = [26 x i8] c"%s: Failed to execute %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 1
%8 = load i8*, i8** %7
%9 = call i64 @redirect_output(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %15, i8* %18)
br label %20
20: ; preds = %11, %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %25, %20
%23 = call i32 (...) @getchar()
%24 = icmp ne i32 %23, 10
br i1 %24, label %25, label %26
25: ; preds = %22
br label %22
26: ; preds = %22
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = call i32 @execvp(i8* %29, i8** %31)
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %35, i8* %38)
ret i32 -1
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"%s: Failed to open %s\0A\00"
@.str.2 = [26 x i8] c"%s: Failed to execute %s\0A\00"
@str = [45 x i8] c"Please press Enter to activate this console.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i64 @redirect_output(i8* %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = load i8*, i8** %3
%11 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10)
br label %12
12: ; preds = %7, %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %14, %12
%15 = tail call i32 (...) @getchar()
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %14
17: ; preds = %14
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @execvp(i8* %19, i8** %18)
%21 = load i8*, i8** %1
%22 = load i8*, i8** %18
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %21, i8* %22)
ret i32 -1
}