#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*/ execl(char *, char *, char *, char *, char *,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ getcwd(char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  char root[1024];
  getcwd(root, 1024);
  int len = strlen(root);
  if (root[len - 1] != '/') {
    root[len] = '/';
    root[len + 1] = '\0';
  } else {
    root[len] = '\0';
  }
  char java_home[1024];
  strcpy(java_home, root);
  strcat(java_home, "/runtime/bin/java\0");
  execl(java_home, "java", "-jar", "./client.jar", root, NULL);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   1050 <getcwd@plt>
lea    -0x410(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x414(%rbp)
mov    -0x414(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
je     11c8 <main+0x78>
movslq -0x414(%rbp),%rax
movb   $0x2f,-0x410(%rbp,%rax,1)
2f
mov    -0x414(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x410(%rbp,%rax,1)
jmp    11d7 <main+0x87>
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x820(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x820(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x820(%rbp),%rdi
lea    -0x410(%rbp),%r8
lea    0xe01(%rip),%rsi
lea    0xdff(%rip),%rdx
lea    0xdfd(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r9d
call   1070 <execl@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <getcwd@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
cmpb   $0x2f,-0x1(%rsp,%rcx,1)
lea    (%rsp,%rcx,1),%rax
je     118b <main+0x3b>
movb   $0x2f,(%rax)
lea    (%rcx,%rbx,1),%rax
add    $0x1,%rax
movb   $0x0,(%rax)
lea    0x400(%rsp),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe55(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xe59(%rip),%rsi
lea    0xe57(%rip),%rdx
lea    0xe55(%rip),%rcx
mov    %rbx,%rdi
mov    %r14,%r8
xor    %r9d,%r9d
call   1070 <execl@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"/runtime/bin/java\00\00"
@.str.1 = [5 x i8] c"java\00"
@.str.2 = [5 x i8] c"-jar\00"
@.str.3 = [13 x i8] c"./client.jar\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca [1024 x i8]
store i32 0, i32* %1
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = call i32 @getcwd(i8* %5, i32 1024)
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = sub nsw i32 %9, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 47
br i1 %15, label %16, label %24
16: ; preds = %0
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %18
store i8 47, i8* %19
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %22
store i8 0, i8* %23
br label %28
24: ; preds = %0
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %24, %16
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%36 = call i32 @execl(i8* %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %35, i32* null)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"/runtime/bin/java\00\00"
@.str.1 = [5 x i8] c"java\00"
@.str.2 = [5 x i8] c"-jar\00"
@.str.3 = [13 x i8] c"./client.jar\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = call i32 @getcwd(i8* %3, i32 1024)
%5 = call i32 @strlen(i8* %3)
%6 = add nsw i32 %5, -1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 47
%11 = sext i32 %5 to i64
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %11
br i1 %10, label %17, label %13
13: ; preds = %0
store i8 47, i8* %12
%14 = add nsw i32 %5, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %15
br label %17
17: ; preds = %0, %13
%18 = phi i8* [ %16, %13 ], [ %12, %0 ]
store i8 0, i8* %18
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%20 = call i32 @strcpy(i8* %19, i8* %3)
%21 = call i32 @strcat(i8* %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @execl(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %3, i32* null)
ret i32 0
}