#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*/ execv(char *, char **);
char **malloc(int);
int /*<<< orphan*/ perror(char *);
int main(int argc, char **argv) {
  char **args = malloc(sizeof(char *) * (argc + 4));
  size_t i;
  args[0] = "/bin/sh";
  args[1] = "-c";
  args[2] =
      ". /Users/remram/Documents/programming/_venvs/reprozip/bin/activate && "
      "reprounzip-qt \"$@\"";
  args[3] = "-";
  for (i = 1; i < argc; ++i) {
    args[i + 3] = argv[i];
  }
  args[argc + 3] = 0;
  execv("/bin/sh", args);
  perror("execv failed");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x4,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
lea    0xe98(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
lea    0xe92(%rip),%rcx
mov    %rcx,0x8(%rax)
mov    -0x18(%rbp),%rax
lea    0xe86(%rip),%rcx
mov    %rcx,0x10(%rax)
mov    -0x18(%rbp),%rax
lea    0xed0(%rip),%rcx
mov    %rcx,0x18(%rax)
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    11db <main+0xab>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,0x18(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a0 <main+0x70>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1050 <execv@plt>
lea    0xe5f(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
lea    0x20(,%r15,8),%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xe9b(%rip),%rax
mov    %rax,(%rbx)
lea    0xe99(%rip),%rax
mov    %rax,0x8(%rbx)
lea    0xe91(%rip),%rax
mov    %rax,0x10(%rbx)
lea    0xedf(%rip),%rax
mov    %rax,0x18(%rbx)
movslq %r15d,%r12
cmp    $0x2,%r15d
jb     11ad <main+0x6d>
mov    %rbx,%rdi
add    $0x20,%rdi
add    $0x8,%r14
lea    -0x8(,%r12,8),%rdx
ff
mov    %r14,%rsi
call   1030 <memcpy@plt>
movq   $0x0,0x18(%rbx,%r12,8)
lea    0xe43(%rip),%rdi
mov    %rbx,%rsi
call   1060 <execv@plt>
lea    0xe9a(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [89 x i8] c". /Users/remram/Documents/programming/_venvs/reprozip/bin/activate && reprounzip-qt \22$@\22\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [13 x i8] c"execv failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = add nsw i32 %8, 4
%10 = sext i32 %9 to i64
%11 = mul i64 8, %10
%12 = trunc i64 %11 to i32
%13 = call i8** @malloc(i32 %12)
store i8** %13, i8*** %6
%14 = load i8**, i8*** %6
%15 = getelementptr inbounds i8*, i8** %14, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %15
%16 = load i8**, i8*** %6
%17 = getelementptr inbounds i8*, i8** %16, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %17
%18 = load i8**, i8*** %6
%19 = getelementptr inbounds i8*, i8** %18, i64 2
store i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.2, i64 0, i64 0), i8** %19
%20 = load i8**, i8*** %6
%21 = getelementptr inbounds i8*, i8** %20, i64 3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %21
store i64 1, i64* %7
br label %22
22: ; preds = %36, %2
%23 = load i64, i64* %7
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = icmp ult i64 %23, %25
br i1 %26, label %27, label %39
27: ; preds = %22
%28 = load i8**, i8*** %5
%29 = load i64, i64* %7
%30 = getelementptr inbounds i8*, i8** %28, i64 %29
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %6
%33 = load i64, i64* %7
%34 = add i64 %33, 3
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
store i8* %31, i8** %35
br label %36
36: ; preds = %27
%37 = load i64, i64* %7
%38 = add i64 %37, 1
store i64 %38, i64* %7
br label %22
39: ; preds = %22
%40 = load i8**, i8*** %6
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %40, i64 %43
store i8* null, i8** %44
%45 = load i8**, i8*** %6
%46 = call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %45)
%47 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [89 x i8] c". /Users/remram/Documents/programming/_venvs/reprozip/bin/activate && reprounzip-qt \22$@\22\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [13 x i8] c"execv failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = shl i32 %0, 3
%4 = add i32 %3, 32
%5 = tail call i8** @malloc(i32 %4)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds i8*, i8** %5, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds i8*, i8** %5, i64 2
store i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds i8*, i8** %5, i64 3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = icmp ugt i32 %0, 1
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = sext i32 %0 to i64
%12 = getelementptr i8*, i8** %5, i64 4
%13 = bitcast i8** %12 to i8*
%14 = getelementptr i8*, i8** %1, i64 1
%15 = bitcast i8** %14 to i8*
%16 = shl nsw i64 %11, 3
%17 = add nsw i64 %16, -8
br label %18
18: ; preds = %10, %2
%19 = add nsw i32 %0, 3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %5, i64 %20
store i8* null, i8** %21
%22 = tail call i32 @execv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %5)
%23 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
ret i32 1
}