#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 + 1));
  size_t i;
  for (i = 1; i < argc; ++i) {
    args[i] = argv[i];
  }
  args[argc] = 0;
  execv("/opt/reprounzip/reprounzip-qt", 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    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    119f <main+0x6f>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1165 <main+0x35>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1050 <execv@plt>
lea    0xe58(%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   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
lea    0x8(,%rbx,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r15
movslq %ebx,%rbx
cmp    $0x2,%ebx
jb     117c <main+0x3c>
mov    %r15,%rdi
add    $0x8,%rdi
add    $0x8,%r14
lea    -0x8(,%rbx,8),%rdx
ff
mov    %r14,%rsi
call   1030 <memcpy@plt>
movq   $0x0,(%r15,%rbx,8)
lea    0xe75(%rip),%rdi
mov    %r15,%rsi
call   1060 <execv@plt>
lea    0xe84(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"/opt/reprounzip/reprounzip-qt\00"
@.str.1 = [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, 1
%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
store i64 1, i64* %7
br label %14
14: ; preds = %27, %2
%15 = load i64, i64* %7
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = icmp ult i64 %15, %17
br i1 %18, label %19, label %30
19: ; preds = %14
%20 = load i8**, i8*** %5
%21 = load i64, i64* %7
%22 = getelementptr inbounds i8*, i8** %20, i64 %21
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %6
%25 = load i64, i64* %7
%26 = getelementptr inbounds i8*, i8** %24, i64 %25
store i8* %23, i8** %26
br label %27
27: ; preds = %19
%28 = load i64, i64* %7
%29 = add i64 %28, 1
store i64 %29, i64* %7
br label %14
30: ; preds = %14
%31 = load i8**, i8*** %6
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
store i8* null, i8** %34
%35 = load i8**, i8*** %6
%36 = call i32 @execv(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8** %35)
%37 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str = [30 x i8] c"/opt/reprounzip/reprounzip-qt\00"
@.str.1 = [13 x i8] c"execv failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = shl i32 %0, 3
%4 = add i32 %3, 8
%5 = tail call i8** @malloc(i32 %4)
%6 = sext i32 %0 to i64
%7 = icmp ugt i32 %0, 1
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = getelementptr i8*, i8** %5, i64 1
%10 = bitcast i8** %9 to i8*
%11 = getelementptr i8*, i8** %1, i64 1
%12 = bitcast i8** %11 to i8*
%13 = shl nsw i64 %6, 3
%14 = add nsw i64 %13, -8
br label %15
15: ; preds = %8, %2
%16 = getelementptr inbounds i8*, i8** %5, i64 %6
store i8* null, i8** %16
%17 = tail call i32 @execv(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8** %5)
%18 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
ret i32 1
}