#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 **);
int main(int argc, char **argv) {
  char *args[] = {"/bin/tar", "cf",    "/tmp/ownership.$$.tar",
                  argv[1],    argv[2], argv[3]};
  execv(args[0], args);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xed8(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xed0(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x40(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <execv@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xee5(%rip),%rdi
mov    %rdi,(%rsp)
lea    0xee3(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xeda(%rip),%rax
mov    %rax,0x10(%rsp)
movups 0x8(%rsi),%xmm0
movups %xmm0,0x18(%rsp)
mov    0x18(%rsi),%rax
mov    %rax,0x28(%rsp)
mov    %rsp,%rsi
call   1030 <execv@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"/bin/tar\00"
@.str.1 = [3 x i8] c"cf\00"
@.str.2 = [22 x i8] c"/tmp/ownership.$$.tar\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [6 x i8*]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds i8*, i8** %6, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds i8*, i8** %7, i64 1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8**, i8*** %4
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
store i8* %12, i8** %9
%13 = getelementptr inbounds i8*, i8** %9, i64 1
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
store i8* %16, i8** %13
%17 = getelementptr inbounds i8*, i8** %13, i64 1
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 3
%20 = load i8*, i8** %19
store i8* %20, i8** %17
%21 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 0
%22 = load i8*, i8** %21
%23 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 0
%24 = call i32 @execv(i8* %22, i8** %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"/bin/tar\00"
@.str.1 = [3 x i8] c"cf\00"
@.str.2 = [22 x i8] c"/tmp/ownership.$$.tar\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [6 x i8*]
%4 = bitcast [6 x i8*]* %3 to i8*
%5 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 2
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 3
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = bitcast i8** %9 to <2 x i8*>*
%11 = load <2 x i8*>, <2 x i8*>* %10
%12 = bitcast i8** %8 to <2 x i8*>*
store <2 x i8*> %11, <2 x i8*>* %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 5
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
store i8* %15, i8** %13
%16 = call i32 @execv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %5)
ret i32 0
}