#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*/ F_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
char *malloc(scalar_t__);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
scalar_t__ strlen(char const *);
char *indexes(const char *path) {
  char *indexphp = malloc(strlen(path) + 12 + 1);
  strcpy(indexphp, path);
  strcat(indexphp, "/index.php");
  char *indexhtml = malloc(strlen(path) + 13 + 1);
  strcpy(indexhtml, path);
  strcat(indexhtml, "/index.html");
  if (access(indexphp, F_OK) == 0)
    return indexphp;
  else if (access(indexhtml, F_OK) == 0)
    return indexhtml;
  else
    return NULL;
}


x86 assembly (clang, -O0):
<indexes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0xc,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0xd,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xe40(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
cmp    $0x0,%rax
jne    11f9 <indexes+0xa9>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <indexes+0xda>
mov    -0x20(%rbp),%rdi
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
call   1060 <access@plt>
cmp    $0x0,%rax
jne    1222 <indexes+0xd2>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    122a <indexes+0xda>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<indexes>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
lea    0xd(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcat@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0xe(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe62(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcat@plt>
mov    0x2e20(%rip),%r14
mov    (%r14),%esi
mov    %rbx,%rdi
call   1060 <access@plt>
test   %rax,%rax
je     11dc <indexes+0x8c>
mov    (%r14),%esi
mov    %r15,%rdi
call   1060 <access@plt>
xor    %ebx,%ebx
test   %rax,%rax
cmove  %r15,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/index.php\00"
@.str.1 = [12 x i8] c"/index.html\00"
@F_OK = global i32 0
define i8* @indexes(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @strlen(i8* %6)
%8 = add nsw i64 %7, 12
%9 = add nsw i64 %8, 1
%10 = call i8* @malloc(i64 %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = load i8*, i8** %3
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = load i8*, i8** %4
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%16 = load i8*, i8** %3
%17 = call i64 @strlen(i8* %16)
%18 = add nsw i64 %17, 13
%19 = add nsw i64 %18, 1
%20 = call i8* @malloc(i64 %19)
store i8* %20, i8** %5
%21 = load i8*, i8** %5
%22 = load i8*, i8** %3
%23 = call i32 @strcpy(i8* %21, i8* %22)
%24 = load i8*, i8** %5
%25 = call i32 @strcat(i8* %24, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%26 = load i8*, i8** %4
%27 = load i32, i32* @F_OK
%28 = call i64 @access(i8* %26, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %1
%31 = load i8*, i8** %4
store i8* %31, i8** %2
br label %40
32: ; preds = %1
%33 = load i8*, i8** %5
%34 = load i32, i32* @F_OK
%35 = call i64 @access(i8* %33, i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = load i8*, i8** %5
store i8* %38, i8** %2
br label %40
39: ; preds = %32
store i8* null, i8** %2
br label %40
40: ; preds = %39, %37, %30
%41 = load i8*, i8** %2
ret i8* %41
}

LLVM IR (-O2):
@.str = [11 x i8] c"/index.php\00"
@.str.1 = [12 x i8] c"/index.html\00"
@F_OK = global i32 0
define i8* @indexes(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 13
%4 = tail call i8* @malloc(i64 %3)
%5 = tail call i32 @strcpy(i8* %4, i8* %0)
%6 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = add nsw i64 %7, 14
%9 = tail call i8* @malloc(i64 %8)
%10 = tail call i32 @strcpy(i8* %9, i8* %0)
%11 = tail call i32 @strcat(i8* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @F_OK
%13 = tail call i64 @access(i8* %4, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %1
%16 = load i32, i32* @F_OK
%17 = tail call i64 @access(i8* %9, i32 %16)
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i8* %9, i8* null
br label %20
20: ; preds = %15, %1
%21 = phi i8* [ %4, %1 ], [ %19, %15 ]
ret i8* %21
}