#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 execve(char *, char **, char **);
int /*<<< orphan*/ memcpy(char **, char **, int);
int main(int argc, char **argv, char **envp) {
  char *newargv[argc + 5];
  newargv[0] = argv[0];
  newargv[1] = "-cpu";
  newargv[2] = "arm1176";
  newargv[3] = "-r";
  newargv[4] = "3.6.11+";
  memcpy(&newargv[5], &argv[1], sizeof(*argv) * (argc - 1));
  newargv[argc + 4] = NULL;
  return execve("/usr/bin/qemu-arm-static", newargv, envp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x5,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,(%rdi)
lea    0xe8b(%rip),%rax
mov    %rax,0x8(%rdi)
lea    0xe85(%rip),%rax
mov    %rax,0x10(%rdi)
lea    0xe82(%rip),%rax
mov    %rax,0x18(%rdi)
lea    0xe7a(%rip),%rax
mov    %rax,0x20(%rdi)
add    $0x28,%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%eax
add    $0x4,%eax
cltq
movq   $0x0,(%rsi,%rax,8)
mov    -0x18(%rbp),%rdx
lea    0xe40(%rip),%rdi
call   1030 <execve@plt>
mov    %eax,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %edi,%r15d
lea    0x5(%r15),%eax
mov    %rsp,%rcx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
mov    %rcx,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
neg    %rax
mov    (%rsi),%rdx
mov    %rdx,(%rcx,%rax,1)
lea    0xea3(%rip),%rax
mov    %rax,0x8(%rbx)
lea    0xe9d(%rip),%rax
mov    %rax,0x10(%rbx)
lea    0xe9a(%rip),%rax
mov    %rax,0x18(%rbx)
lea    0xe92(%rip),%rax
mov    %rax,0x20(%rbx)
lea    0x28(%rbx),%rdi
add    $0x8,%rsi
lea    -0x8(,%r15,8),%edx
ff
call   1040 <memcpy@plt>
movslq %r15d,%rax
movq   $0x0,0x20(%rbx,%rax,8)
lea    0xe6e(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <execve@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"-cpu\00"
@.str.1 = [8 x i8] c"arm1176\00"
@.str.2 = [3 x i8] c"-r\00"
@.str.3 = [8 x i8] c"3.6.11+\00"
@.str.4 = [25 x i8] c"/usr/bin/qemu-arm-static\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i64
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = load i32, i32* %5
%11 = add nsw i32 %10, 5
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %8
%14 = alloca i8*, i64 %12
store i64 %12, i64* %9
%15 = load i8**, i8*** %6
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8*, i8** %14, i64 0
store i8* %17, i8** %18
%19 = getelementptr inbounds i8*, i8** %14, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds i8*, i8** %14, i64 2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds i8*, i8** %14, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %21
%22 = getelementptr inbounds i8*, i8** %14, i64 4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %22
%23 = getelementptr inbounds i8*, i8** %14, i64 5
%24 = load i8**, i8*** %6
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i32, i32* %5
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = mul i64 8, %28
%30 = trunc i64 %29 to i32
%31 = call i32 @memcpy(i8** %23, i8** %25, i32 %30)
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %14, i64 %34
store i8* null, i8** %35
%36 = load i8**, i8*** %7
%37 = call i32 @execve(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8** %14, i8** %36)
store i32 %37, i32* %4
%38 = load i8*, i8** %8
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
@.str = [5 x i8] c"-cpu\00"
@.str.1 = [8 x i8] c"arm1176\00"
@.str.2 = [3 x i8] c"-r\00"
@.str.3 = [8 x i8] c"3.6.11+\00"
@.str.4 = [25 x i8] c"/usr/bin/qemu-arm-static\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = add nsw i32 %0, 5
%5 = zext i32 %4 to i64
%6 = alloca i8*, i64 %5
%7 = load i8*, i8** %1
store i8* %7, i8** %6
%8 = getelementptr inbounds i8*, i8** %6, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds i8*, i8** %6, i64 2
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds i8*, i8** %6, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds i8*, i8** %6, i64 4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds i8*, i8** %6, i64 5
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = shl i32 %0, 3
%15 = add i32 %14, -8
%16 = call i32 @memcpy(i8** %12, i8** %13, i32 %15)
%17 = add nsw i32 %0, 4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %6, i64 %18
store i8* null, i8** %19
%20 = call i32 @execve(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8** %6, i8** %2)
ret i32 %20
}