#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*/ EXIT_FAILURE;
int /*<<< orphan*/ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int main(int argc, char *argv[]) {
  char *cmd = "/bin/bash";
  char *newargv[] = {"xxyy", NULL};
  char *newenv[] = {NULL};
  if (argc > 1 && argv[1][0] == '-') {
    newargv[0] = "-xxyy";
  }
  execve(cmd, newargv, newenv);
  perror("execve");
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c98(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c95(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
cmpl   $0x1,-0x8(%rbp)
jle    11b0 <main+0x70>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11b0 <main+0x70>
lea    0xe5e(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1040 <execve@plt>
lea    0xe48(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movaps 0x2cc5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
cmp    $0x2,%edi
jl     1163 <main+0x33>
mov    0x8(%rsi),%rax
cmpb   $0x2d,(%rax)
jne    1163 <main+0x33>
lea    0xeac(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe96(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1030 <execve@plt>
lea    0xe90(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"/bin/bash\00"
@.str.1 = [5 x i8] c"xxyy\00"
@__const.main.newargv = [2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [6 x i8] c"-xxyy\00"
@.str.3 = [7 x i8] c"execve\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [2 x i8*]
%8 = alloca [1 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %6
%9 = bitcast [2 x i8*]* %7 to i8*
%10 = bitcast [1 x i8*]* %8 to i8*
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %23
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 45
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %22
br label %23
23: ; preds = %21, %13, %2
%24 = load i8*, i8** %6
%25 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%26 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
%27 = call i32 @execve(i8* %24, i8** %25, i8** %26)
%28 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
}

LLVM IR (-O2):
@.str = [10 x i8] c"/bin/bash\00"
@.str.1 = [5 x i8] c"xxyy\00"
@__const.main.newargv = [2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [6 x i8] c"-xxyy\00"
@.str.3 = [7 x i8] c"execve\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i8*]
%4 = alloca [1 x i8*]
%5 = bitcast [2 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 = icmp sgt i32 %0, 1
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 45
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %15
br label %16
16: ; preds = %14, %9, %2
%17 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 0
%18 = getelementptr inbounds [1 x i8*], [1 x i8*]* %4, i64 0, i64 0
%19 = call i32 @execve(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %17, i8** %18)
%20 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
}