#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*/ execve(char *, char **, char **);
int main(int argc, char **argv) {
  char *newargv[] = {"/bin/sh", "/etc/init.d/tomcat6", "restart", NULL};
  char *newenviron[] = {NULL};
  execve("/bin/sh", newargv, newenviron);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2cca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cc7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cc4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cc1(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    0xe86(%rip),%rdi
call   1040 <execve@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movaps 0x2cf5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2cd9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xec4(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <execve@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [20 x i8] c"/etc/init.d/tomcat6\00"
@.str.2 = [8 x i8] c"restart\00"
@__const.main.newargv = [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* null]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [4 x i8*]
%6 = alloca [1 x i8*]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = bitcast [4 x i8*]* %5 to i8*
%8 = bitcast [1 x i8*]* %6 to i8*
%9 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 0
%10 = getelementptr inbounds [1 x i8*], [1 x i8*]* %6, i64 0, i64 0
%11 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %9, i8** %10)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"/bin/sh\00"
@.str.1 = [20 x i8] c"/etc/init.d/tomcat6\00"
@.str.2 = [8 x i8] c"restart\00"
@__const.main.newargv = [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* null]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i8*]
%4 = alloca [1 x i8*]
%5 = bitcast [4 x i8*]* %3 to i8*
%6 = bitcast [1 x i8*]* %4 to i8*
%7 = bitcast [1 x i8*]* %4 to i64*
store i64 0, i64* %7
%8 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 0
%9 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
%10 = call i32 @execve(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %8, i8** %9)
ret i32 0
}