#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*/ *filepath_sfindfile(char *, char *, char *, char const *);
char *filepath_sfind(char **respathv, char *filepath, const char *filename) {
  int respathc = 0;
  if ((respathv == NULL) || (respathv[0] == NULL) || (filepath == NULL))
    return NULL;
  while (respathv[respathc] != NULL) {
    if (filepath_sfindfile(filepath, "%s/%s", respathv[respathc], filename) !=
        NULL) {
      return filepath;
    }
    respathc++;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<filepath_sfind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114f <filepath_sfind+0x3f>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     114f <filepath_sfind+0x3f>
cmpq   $0x0,-0x18(%rbp)
jne    115c <filepath_sfind+0x4c>
movq   $0x0,-0x8(%rbp)
jmp    11c1 <filepath_sfind+0xb1>
jmp    1161 <filepath_sfind+0x51>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11b9 <filepath_sfind+0xa9>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe71(%rip),%rsi
call   1030 <filepath_sfindfile@plt>
cmp    $0x0,%rax
je     11ab <filepath_sfind+0x9b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c1 <filepath_sfind+0xb1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1161 <filepath_sfind+0x51>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filepath_sfind>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rdi,%rdi
je     1171 <filepath_sfind+0x61>
mov    %rsi,%r12
xor    %r14d,%r14d
test   %rsi,%rsi
je     1179 <filepath_sfind+0x69>
mov    %rdx,%r15
mov    %rdi,%rbx
mov    (%rdi),%rdx
test   %rdx,%rdx
je     1179 <filepath_sfind+0x69>
add    $0x8,%rbx
lea    0xebe(%rip),%r13
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rcx
call   1030 <filepath_sfindfile@plt>
test   %rax,%rax
jne    1176 <filepath_sfind+0x66>
mov    (%rbx),%rdx
add    $0x8,%rbx
test   %rdx,%rdx
jne    1150 <filepath_sfind+0x40>
jmp    1179 <filepath_sfind+0x69>
xor    %r14d,%r14d
jmp    1179 <filepath_sfind+0x69>
mov    %r12,%r14
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
define i8* @filepath_sfind(i8** %0, i8* %1, i8* %2) {
%4 = icmp eq i8** %0, null
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = load i8*, i8** %0
%7 = icmp eq i8* %6, null
%8 = icmp eq i8* %1, null
%9 = or i1 %8, %7
br i1 %9, label %20, label %14
10: ; preds = %14
%11 = getelementptr inbounds i8*, i8** %0, i64 %19
%12 = load i8*, i8** %11
%13 = icmp eq i8* %12, null
br i1 %13, label %20, label %14
14: ; preds = %5, %10
%15 = phi i64 [ %19, %10 ], [ 0, %5 ]
%16 = phi i8* [ %12, %10 ], [ %6, %5 ]
%17 = tail call i32* @filepath_sfindfile(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %2)
%18 = icmp eq i32* %17, null
%19 = add nuw i64 %15, 1
br i1 %18, label %10, label %20
20: ; preds = %14, %10, %3, %5
%21 = phi i8* [ null, %5 ], [ null, %3 ], [ %1, %14 ], [ null, %10 ]
ret i8* %21
}