#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 ccache_exec(char const *, char *const *, char *const *);
scalar_t__ gcc_check(char const *, char *const *, char *const *);
int /*<<< orphan*/ *getenv(char *);
int libc_execve(char const *, char *const *, char *const *);
int /*<<< orphan*/ ucw_init();
int execve(const char *path, char *const argv[], char *const envv[]) {
  ;
  ucw_init();
  if (getenv("UCC_RECURSE") != NULL) {
    ;
    return libc_execve(path, argv, envv);
  }
  if (gcc_check(path, argv, envv)) {
    return ccache_exec(path, argv, envv);
  }
  return libc_execve(path, argv, envv);
}


x86 assembly (clang, -O0):
<execve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x0,%al
call   1040 <ucw_init@plt>
lea    0xe8e(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%rax
je     119a <execve+0x4a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <libc_execve@plt>
mov    %eax,-0x4(%rbp)
jmp    11e2 <execve+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1070 <gcc_check@plt>
cmp    $0x0,%rax
je     11ce <execve+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <ccache_exec@plt>
mov    %eax,-0x4(%rbp)
jmp    11e2 <execve+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <libc_execve@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execve>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <ucw_init@plt>
lea    0xe94(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1189 <execve+0x39>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <libc_execve@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1070 <gcc_check@plt>
test   %rax,%rax
je     1176 <execve+0x26>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <ccache_exec@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"UCC_RECURSE\00"
define i32 @execve(i8* %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i8**
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%8 = call i32 (...) @ucw_init()
%9 = call i32* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = load i8**, i8*** %6
%14 = load i8**, i8*** %7
%15 = call i32 @libc_execve(i8* %12, i8** %13, i8** %14)
store i32 %15, i32* %4
br label %32
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = load i8**, i8*** %6
%19 = load i8**, i8*** %7
%20 = call i64 @gcc_check(i8* %17, i8** %18, i8** %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load i8*, i8** %5
%24 = load i8**, i8*** %6
%25 = load i8**, i8*** %7
%26 = call i32 @ccache_exec(i8* %23, i8** %24, i8** %25)
store i32 %26, i32* %4
br label %32
27: ; preds = %16
%28 = load i8*, i8** %5
%29 = load i8**, i8*** %6
%30 = load i8**, i8*** %7
%31 = call i32 @libc_execve(i8* %28, i8** %29, i8** %30)
store i32 %31, i32* %4
br label %32
32: ; preds = %27, %22, %11
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@.str = [12 x i8] c"UCC_RECURSE\00"
define i32 @execve(i8* %0, i8** %1, i8** %2) {
%4 = tail call i32 (...) @ucw_init()
%5 = tail call i32* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 @libc_execve(i8* %0, i8** %1, i8** %2)
br label %16
9: ; preds = %3
%10 = tail call i64 @gcc_check(i8* %0, i8** %1, i8** %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @ccache_exec(i8* %0, i8** %1, i8** %2)
br label %16
14: ; preds = %9
%15 = tail call i32 @libc_execve(i8* %0, i8** %1, i8** %2)
br label %16
16: ; preds = %14, %12, %7
%17 = phi i32 [ %8, %7 ], [ %13, %12 ], [ %15, %14 ]
ret i32 %17
}