#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*/ free(char *);
char *join(char **, int, char *);
int system(char *);
int run_dex(char *dex, char *main_class, char *parameters) {
  char *strs[4] = {"dalvikvm -cp", dex, main_class, parameters};
  char *cmd = join(strs, parameters ? 4 : 3, " ");
  int status = system(cmd);
  free(cmd);
  return status;
}


x86 assembly (clang, -O0):
<run_dex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xeb5(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x3,%esi
mov    $0x4,%eax
cmp    $0x0,%rcx
cmovne %eax,%esi
lea    0xe86(%rip),%rdx
call   1050 <join@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_dex>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
lea    0xec3(%rip),%rax
mov    %rax,(%rsp)
mov    %rdi,0x8(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdx,0x18(%rsp)
cmp    $0x1,%rdx
mov    $0x4,%esi
sbb    $0x0,%esi
lea    0xeaa(%rip),%rdx
mov    %rsp,%rdi
call   1050 <join@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <system@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"dalvikvm -cp\00"
@.str.1 = [2 x i8] c" \00"
define i32 @run_dex(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [4 x i8*]
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %4
store i8* %12, i8** %11
%13 = getelementptr inbounds i8*, i8** %11, i64 1
%14 = load i8*, i8** %5
store i8* %14, i8** %13
%15 = getelementptr inbounds i8*, i8** %13, i64 1
%16 = load i8*, i8** %6
store i8* %16, i8** %15
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 4, i32 3
%22 = call i8* @join(i8** %17, i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %22, i8** %8
%23 = load i8*, i8** %8
%24 = call i32 @system(i8* %23)
store i32 %24, i32* %9
%25 = load i8*, i8** %8
%26 = call i32 @free(i8* %25)
%27 = load i32, i32* %9
ret i32 %27
}

LLVM IR (-O2):
@.str = [13 x i8] c"dalvikvm -cp\00"
@.str.1 = [2 x i8] c" \00"
define i32 @run_dex(i8* %0, i8* %1, i8* %2) {
%4 = alloca [4 x i8*]
%5 = bitcast [4 x i8*]* %4 to i8*
%6 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 1
store i8* %0, i8** %7
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 2
store i8* %1, i8** %8
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 3
store i8* %2, i8** %9
%10 = icmp eq i8* %2, null
%11 = select i1 %10, i32 3, i32 4
%12 = call i8* @join(i8** %6, i32 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @system(i8* %12)
%14 = call i32 @free(i8* %12)
ret i32 %13
}