#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 BUFSIZ;
int /*<<< orphan*/ execvp(char *, char *const *);
int /*<<< orphan*/ perror(char *);
char **prepare_argv(int, char **);
int /*<<< orphan*/ set_LD_PRELOAD();
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int main(int argc, char *argv[]) {
  char *file = argv[1];
  char *const *newargv = prepare_argv(argc, argv);
  ;
  ;
  ;
  ;
  set_LD_PRELOAD();
  execvp(file, newargv);
  {
    char name[BUFSIZ];
    sprintf(name, "%s: %s", argv[0], argv[2]);
    perror(name);
  }
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <prepare_argv@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
call   1030 <set_LD_PRELOAD@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <execvp@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xe28(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x38(%rbp),%rdi
call   1050 <perror@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    $0xffffffff,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    0x8(%rsi),%r14
call   1040 <prepare_argv@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1030 <set_LD_PRELOAD@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <execvp@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%r12),%rdx
mov    0x10(%r12),%rcx
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [7 x i8] c"%s: %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
store i8* %12, i8** %6
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i8** @prepare_argv(i32 %13, i8** %14)
store i8** %15, i8*** %7
%16 = call i32 (...) @set_LD_PRELOAD()
%17 = load i8*, i8** %6
%18 = load i8**, i8*** %7
%19 = call i32 @execvp(i8* %17, i8** %18)
%20 = load i32, i32* @BUFSIZ
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %8
%23 = alloca i8, i64 %21
store i64 %21, i64* %9
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %29)
%31 = call i32 @perror(i8* %23)
%32 = load i8*, i8** %8
ret i32 -1
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [7 x i8] c"%s: %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i8** @prepare_argv(i32 %0, i8** %1)
%6 = tail call i32 (...) @set_LD_PRELOAD()
%7 = tail call i32 @execvp(i8* %4, i8** %5)
%8 = load i32, i32* @BUFSIZ
%9 = zext i32 %8 to i64
%10 = alloca i8, i64 %9
%11 = load i8*, i8** %1
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %13)
%15 = call i32 @perror(i8* %10)
ret i32 -1
}