#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 EXIT_SUCCESS;
int execv(char *, char **);
int /*<<< orphan*/ printf(char *, char *, int);
char *sceKernelGetRandomizedPath();
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  char path[1024];
  char *args[2];
  int r;
  strcpy(path, "/");
  strcat(path, sceKernelGetRandomizedPath());
  strcat(path, "/common/lib/WebProcess.self");
  args[0] = path;
  args[1] = NULL;
  r = execv(args[0], args);
  printf("execv(%s) = %i\n", args[0], r);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    $0x0,%al
call   1050 <sceKernelGetRandomizedPath@plt>
mov    -0x430(%rbp),%rdi
mov    %rax,%rsi
call   1060 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x420(%rbp)
movq   $0x0,-0x418(%rbp)
mov    -0x420(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1070 <execv@plt>
mov    %eax,-0x424(%rbp)
mov    -0x420(%rbp),%rsi
mov    -0x424(%rbp),%edx
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x410,%rsp
lea    0xea1(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
xor    %eax,%eax
call   1050 <sceKernelGetRandomizedPath@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <strcat@plt>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1070 <execv@plt>
mov    (%rsp),%rsi
lea    0xe6e(%rip),%rdi
mov    %eax,%edx
call   1040 <printf@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%eax
add    $0x410,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [28 x i8] c"/common/lib/WebProcess.self\00"
@.str.2 = [16 x i8] c"execv(%s) = %i\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca [2 x i8*]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = call i8* (...) @sceKernelGetRandomizedPath()
%13 = call i32 @strcat(i8* %11, i8* %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%17 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
store i8* %16, i8** %17
%18 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 1
store i8* null, i8** %18
%19 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%20 = load i8*, i8** %19
%21 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%22 = call i32 @execv(i8* %20, i8** %21)
store i32 %22, i32* %8
%23 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%24 = load i8*, i8** %23
%25 = load i32, i32* %8
%26 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %24, i32 %25)
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [28 x i8] c"/common/lib/WebProcess.self\00"
@.str.2 = [16 x i8] c"execv(%s) = %i\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = alloca [2 x i8*]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = bitcast [2 x i8*]* %4 to i8*
%7 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = call i8* (...) @sceKernelGetRandomizedPath()
%9 = call i32 @strcat(i8* %5, i8* %8)
%10 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
store i8* %5, i8** %11
%12 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 1
store i8* null, i8** %12
%13 = call i32 @execv(i8* %5, i8** %11)
%14 = load i8*, i8** %11
%15 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 %13)
%16 = load i32, i32* @EXIT_SUCCESS
ret i32 %16
}