#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 execv(char const *, char *const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ putenv(char *const);
int /*<<< orphan*/ stderr;
int httpd_execve(const char *path, char *const argv[], char *const envp[]) {
  for (int i_ce = 0; envp[i_ce]; i_ce++) {
    if (putenv(envp[i_ce])) {
      fprintf(stderr, "error: "
                      "putenv failed"
                      "\n");
      exit(1);
    }
  }
  return execv(path, argv);
}


x86 assembly (clang, -O0):
<httpd_execve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11bb <httpd_execve+0x7b>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <putenv@plt>
cmp    $0x0,%rax
je     11a8 <httpd_execve+0x68>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11ad <httpd_execve+0x6d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <httpd_execve+0x1b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <execv@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpd_execve>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdx),%rdi
test   %rdi,%rdi
je     1176 <httpd_execve+0x36>
mov    %rdx,%rbx
add    $0x8,%rbx
nopw   0x0(%rax,%rax,1)
call   1030 <putenv@plt>
test   %rax,%rax
jne    1186 <httpd_execve+0x46>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1160 <httpd_execve+0x20>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <execv@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"error: putenv failed\0A\00"
define i32 @httpd_execve(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
store i32 0, i32* %7
br label %8
8: ; preds = %28, %3
%9 = load i8**, i8*** %6
%10 = load i32, i32* %7
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8*, i8** %9, i64 %11
%13 = load i8*, i8** %12
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %31
15: ; preds = %8
%16 = load i8**, i8*** %6
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i64 @putenv(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %15
br label %28
28: ; preds = %27
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %8
31: ; preds = %8
%32 = load i8*, i8** %4
%33 = load i8**, i8*** %5
%34 = call i32 @execv(i8* %32, i8** %33)
ret i32 %34
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"error: putenv failed\0A\00"
define i32 @httpd_execve(i8* %0, i8** %1, i8** nocapture %2) {
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %10, label %12
6: ; preds = %12
%7 = getelementptr inbounds i8*, i8** %2, i64 %17
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %6, %3
%11 = tail call i32 @execv(i8* %0, i8** %1)
ret i32 %11
12: ; preds = %3, %6
%13 = phi i64 [ %17, %6 ], [ 0, %3 ]
%14 = phi i8* [ %8, %6 ], [ %4, %3 ]
%15 = tail call i64 @putenv(i8* %14)
%16 = icmp eq i64 %15, 0
%17 = add nuw i64 %13, 1
br i1 %16, label %6, label %18
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
}