#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 *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int main(int argc, char **argv) {
  char *path = NULL;
  if (argc > 1) {
    path = malloc(512);
    sprintf(path, "/usr/bin/tests/%s.sh", argv[1]);
  }
  execl("/bin/busybox", "sh", path, (char *)NULL);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    117e <main+0x4e>
mov    $0x200,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe87(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%rdx
lea    0xe8c(%rip),%rdi
lea    0xe82(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <execl@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     115e <main+0x2e>
mov    %rsi,%r14
mov    $0x200,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%r14),%rdx
lea    0xeac(%rip),%rsi
mov    %rax,%rdi
call   1040 <sprintf@plt>
jmp    1160 <main+0x30>
xor    %ebx,%ebx
lea    0xeae(%rip),%rdi
lea    0xea4(%rip),%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1050 <execl@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"/usr/bin/tests/%s.sh\00"
@.str.1 = [13 x i8] c"/bin/busybox\00"
@.str.2 = [3 x i8] c"sh\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = call i8* @malloc(i32 512)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %9, %2
%17 = load i8*, i8** %6
%18 = call i32 @execl(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %17, i8* null)
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@.str = [21 x i8] c"/usr/bin/tests/%s.sh\00"
@.str.1 = [13 x i8] c"/bin/busybox\00"
@.str.2 = [3 x i8] c"sh\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %4, %2
%10 = phi i8* [ %5, %4 ], [ null, %2 ]
%11 = tail call i32 @execl(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %10, i8* null)
ret i32 0
}