#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 EXIT_FAILURE;
int execute(char *, char **, char **);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ ft_strdup(char *);
char *validate_file(int /*<<< orphan*/, int);
int test_direct_path(char *path, char **env, char **argv, int *not_found) {
  char *tmp;
  (void)not_found;
  (void)path;
  if (!(tmp = validate_file(ft_strdup(argv[0]), 1))) {
    free(tmp);
    return (EXIT_FAILURE);
  }
  return (execute(argv[0], argv, env));
}


x86 assembly (clang, -O0):
<test_direct_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1050 <ft_strdup@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1060 <validate_file@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1198 <test_direct_path+0x58>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11af <test_direct_path+0x6f>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <execute@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_direct_path>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    (%rdx),%rdi
call   1050 <ft_strdup@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1060 <validate_file@plt>
test   %rax,%rax
je     1178 <test_direct_path+0x38>
mov    (%rbx),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <execute@plt>
xor    %edi,%edi
call   1030 <free@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
define i32 @test_direct_path(i8* %0, i8** %1, i8** %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i8*
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i32* %3, i32** %9
%11 = load i32*, i32** %9
%12 = load i8*, i8** %6
%13 = load i8**, i8*** %8
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @ft_strdup(i8* %15)
%17 = call i8* @validate_file(i32 %16, i32 1)
store i8* %17, i8** %10
%18 = icmp ne i8* %17, null
br i1 %18, label %23, label %19
19: ; preds = %4
%20 = load i8*, i8** %10
%21 = call i32 @free(i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %5
br label %30
23: ; preds = %4
%24 = load i8**, i8*** %8
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %8
%28 = load i8**, i8*** %7
%29 = call i32 @execute(i8* %26, i8** %27, i8** %28)
store i32 %29, i32* %5
br label %30
30: ; preds = %23, %19
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
define i32 @test_direct_path(i8* nocapture readnone %0, i8** %1, i8** %2, i32* nocapture readnone %3) {
%5 = load i8*, i8** %2
%6 = tail call i32 @ft_strdup(i8* %5)
%7 = tail call i8* @validate_file(i32 %6, i32 1)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = tail call i32 @free(i8* null)
%11 = load i32, i32* @EXIT_FAILURE
br label %15
12: ; preds = %4
%13 = load i8*, i8** %2
%14 = tail call i32 @execute(i8* %13, i8** %2, i8** %1)
br label %15
15: ; preds = %12, %9
%16 = phi i32 [ %14, %12 ], [ %11, %9 ]
ret i32 %16
}