#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*/ clean_cache_dir(char *);
int /*<<< orphan*/ free(char *);
char *join(char **, int, char *);
char *random_cache_dir();
int run_dex(char *, char *, char *);
int system(char *);
int run_jar(char *jar, char *main_class, char *parameters) {
  int status;
  char *cache_dir = random_cache_dir();
  char *dx_strs[6] = {"mkdir ",  cache_dir,  " && dx --dex --output=",
                      cache_dir, "run.dex ", jar};
  char *dx_cmd = join(dx_strs, 6, "");
  status = system(dx_cmd);
  free(dx_cmd);
  if (status != 0) {
    clean_cache_dir(cache_dir);
    return status;
  }
  char *dex_strs[2] = {cache_dir, "run.dex"};
  char *dex_name = join(dex_strs, 2, "");
  status = run_dex(dex_name, main_class, parameters);
  free(dex_name);
  clean_cache_dir(cache_dir);
  return status;
}


x86 assembly (clang, -O0):
<run_jar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x0,%al
call   1070 <random_cache_dir@plt>
mov    %rax,-0x30(%rbp)
lea    0xe77(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    0xe6b(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    0xe6f(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x6,%esi
lea    0xe3b(%rip),%rdx
call   1080 <join@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x24(%rbp)
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x24(%rbp)
je     1207 <run_jar+0xa7>
mov    -0x30(%rbp),%rdi
call   1060 <clean_cache_dir@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1268 <run_jar+0x108>
mov    -0x30(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    0xe11(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    -0x80(%rbp),%rdi
mov    $0x2,%esi
lea    0xddc(%rip),%rdx
call   1080 <join@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <run_dex@plt>
mov    %eax,-0x24(%rbp)
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1060 <clean_cache_dir@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_jar>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbp
xor    %eax,%eax
call   1070 <random_cache_dir@plt>
mov    %rax,%r12
lea    0xe7a(%rip),%rax
mov    %rax,0x10(%rsp)
mov    %r12,0x18(%rsp)
lea    0xe70(%rip),%rax
mov    %rax,0x20(%rsp)
mov    %r12,0x28(%rsp)
lea    0xe76(%rip),%rax
mov    %rax,0x30(%rsp)
mov    %rbp,0x38(%rsp)
lea    0xe4d(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x6,%esi
call   1080 <join@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <system@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
jne    1220 <run_jar+0xc0>
mov    %r12,(%rsp)
lea    0xe3b(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xe0e(%rip),%rdx
mov    %rsp,%rdi
mov    $0x2,%esi
call   1080 <join@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <run_dex@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1060 <clean_cache_dir@plt>
mov    %ebp,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"mkdir \00"
@.str.1 = [23 x i8] c" && dx --dex --output=\00"
@.str.2 = [9 x i8] c"run.dex \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [8 x i8] c"run.dex\00"
define i32 @run_jar(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca [6 x i8*]
%11 = alloca i8*
%12 = alloca [2 x i8*]
%13 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%14 = call i8* (...) @random_cache_dir()
store i8* %14, i8** %9
%15 = getelementptr inbounds [6 x i8*], [6 x i8*]* %10, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %9
store i8* %17, i8** %16
%18 = getelementptr inbounds i8*, i8** %16, i64 1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %9
store i8* %20, i8** %19
%21 = getelementptr inbounds i8*, i8** %19, i64 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %21
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %5
store i8* %23, i8** %22
%24 = getelementptr inbounds [6 x i8*], [6 x i8*]* %10, i64 0, i64 0
%25 = call i8* @join(i8** %24, i32 6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i8* %25, i8** %11
%26 = load i8*, i8** %11
%27 = call i32 @system(i8* %26)
store i32 %27, i32* %8
%28 = load i8*, i8** %11
%29 = call i32 @free(i8* %28)
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %3
%33 = load i8*, i8** %9
%34 = call i32 @clean_cache_dir(i8* %33)
%35 = load i32, i32* %8
store i32 %35, i32* %4
br label %51
36: ; preds = %3
%37 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 0
%38 = load i8*, i8** %9
store i8* %38, i8** %37
%39 = getelementptr inbounds i8*, i8** %37, i64 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %39
%40 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 0
%41 = call i8* @join(i8** %40, i32 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
store i8* %41, i8** %13
%42 = load i8*, i8** %13
%43 = load i8*, i8** %6
%44 = load i8*, i8** %7
%45 = call i32 @run_dex(i8* %42, i8* %43, i8* %44)
store i32 %45, i32* %8
%46 = load i8*, i8** %13
%47 = call i32 @free(i8* %46)
%48 = load i8*, i8** %9
%49 = call i32 @clean_cache_dir(i8* %48)
%50 = load i32, i32* %8
store i32 %50, i32* %4
br label %51
51: ; preds = %36, %32
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@.str = [7 x i8] c"mkdir \00"
@.str.1 = [23 x i8] c" && dx --dex --output=\00"
@.str.2 = [9 x i8] c"run.dex \00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [8 x i8] c"run.dex\00"
define i32 @run_jar(i8* %0, i8* %1, i8* %2) {
%4 = alloca [6 x i8*]
%5 = alloca [2 x i8*]
%6 = tail call i8* (...) @random_cache_dir()
%7 = bitcast [6 x i8*]* %4 to i8*
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 1
store i8* %6, i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 2
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 3
store i8* %6, i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 4
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 5
store i8* %0, i8** %13
%14 = call i8* @join(i8** %8, i32 6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @system(i8* %14)
%16 = call i32 @free(i8* %14)
%17 = icmp eq i32 %15, 0
br i1 %17, label %20, label %18
18: ; preds = %3
%19 = call i32 @clean_cache_dir(i8* %6)
br label %28
20: ; preds = %3
%21 = bitcast [2 x i8*]* %5 to i8*
%22 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
store i8* %6, i8** %22
%23 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %23
%24 = call i8* @join(i8** %22, i32 2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @run_dex(i8* %24, i8* %1, i8* %2)
%26 = call i32 @free(i8* %24)
%27 = call i32 @clean_cache_dir(i8* %6)
br label %28
28: ; preds = %20, %18
%29 = phi i32 [ %15, %18 ], [ %25, %20 ]
ret i32 %29
}