#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*/ assert(int);
int execve(char *, char **, char **);
int main(int argc, char *argv[], char *envp[]) {
  int res;
  char *badEnvp[] = {"KEY", "", NULL};
  assert(argc >= 4);
  return execve(argv[1], &argv[1], badEnvp);
}


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)
mov    %rdx,-0x18(%rbp)
mov    0x2cbf(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2cbc(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2cb9(%rip),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x4,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
lea    -0x40(%rbp),%rdx
call   1030 <execve@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    0x2ce1(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0x2cc5(%rip),%xmm0
movaps %xmm0,(%rsp)
xor    %eax,%eax
cmp    $0x4,%edi
setge  %al
mov    %eax,%edi
call   1040 <assert@plt>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
mov    %rsp,%rdx
mov    %rbx,%rsi
call   1030 <execve@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"KEY\00"
@.str.1 = [1 x i8] zeroinitializer
@__const.main.badEnvp = [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* null]
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca [3 x i8*]
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = bitcast [3 x i8*]* %9 to i8*
%11 = load i32, i32* %5
%12 = icmp sge i32 %11, 4
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8**, i8*** %6
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %6
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 0
%21 = call i32 @execve(i8* %17, i8** %19, i8** %20)
ret i32 %21
}

LLVM IR (-O2):
@.str = [4 x i8] c"KEY\00"
@.str.1 = [1 x i8] zeroinitializer
@__const.main.badEnvp = [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i32 0, i32 0), i8* null]
define i32 @main(i32 %0, i8** %1, i8** nocapture readnone %2) {
%4 = alloca [3 x i8*]
%5 = bitcast [3 x i8*]* %4 to i8*
%6 = icmp sgt i32 %0, 3
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
%12 = call i32 @execve(i8* %10, i8** %9, i8** %11)
ret i32 %12
}