#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 */
typedef int /*<<< orphan*/ suffixes;
typedef int /*<<< orphan*/ bases;

/* Variables and functions */
char *concat(char const *, char *, char const *, char const *, char const *);
int /*<<< orphan*/ free(char *);
scalar_t__ is_valid_test(char *);
char *x_strdup(char const *, char *, int);
char *find_test(const char *name, const char *source, const char *build) {
  char *path;
  const char *bases[3], *suffix, *base;
  unsigned int i, j;
  const char *suffixes[3] = {"-t", ".t", ""};
  bases[0] = ".";
  bases[1] = build;
  bases[2] = source;
  for (i = 0; i < (sizeof(suffixes) / sizeof((suffixes)[0])); i++) {
    suffix = suffixes[i];
    for (j = 0; j < (sizeof(bases) / sizeof((bases)[0])); j++) {
      base = bases[j];
      if (base == NULL)
        continue;
      path = concat(base, "/", name, suffix, (const char *)0);
      if (is_valid_test(path))
        return path;
      free(path);
      path = NULL;
    }
  }
  if (path == NULL)
    path = x_strdup((name),
                    "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/jeffreykegler/kollos/"
                    "refs/heads/master/components/tap/runtests.c",
                    1161);
  return path;
}


x86 assembly (clang, -O0):
<find_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2ca5(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0x2ca2(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0x2c9f(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    $0x3,%rax
jae    1253 <find_test+0x113>
mov    -0x54(%rbp),%eax
mov    -0x70(%rbp,%rax,8),%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    $0x3,%rax
jae    1240 <find_test+0x100>
mov    -0x58(%rbp),%eax
mov    -0x40(%rbp,%rax,8),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    11e0 <find_test+0xa0>
jmp    1232 <find_test+0xf2>
mov    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x48(%rbp),%rcx
lea    0xe15(%rip),%rsi
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <concat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <is_valid_test@plt>
cmp    $0x0,%rax
je     1221 <find_test+0xe1>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    127f <find_test+0x13f>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11b7 <find_test+0x77>
jmp    1245 <find_test+0x105>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1197 <find_test+0x57>
cmpq   $0x0,-0x28(%rbp)
jne    1277 <find_test+0x137>
mov    -0x10(%rbp),%rdi
lea    0xda1(%rip),%rsi
mov    $0x489,%edx
call   1060 <x_strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_test>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xeae(%rip),%rdi
lea    0xea9(%rip),%rsi
lea    0xe9a(%rip),%rcx
mov    %r12,%rdx
xor    %r8d,%r8d
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_valid_test@plt>
test   %rax,%rax
je     1190 <find_test+0x50>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r15,%r15
je     11d1 <find_test+0x91>
lea    0xe64(%rip),%rsi
lea    0xe55(%rip),%rcx
mov    %r15,%rdi
mov    %r12,%rdx
xor    %r8d,%r8d
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_valid_test@plt>
test   %rax,%rax
jne    1181 <find_test+0x41>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
je     120e <find_test+0xce>
lea    0xe2b(%rip),%rsi
lea    0xe1c(%rip),%rcx
mov    %r14,%rdi
mov    %r12,%rdx
xor    %r8d,%r8d
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_valid_test@plt>
test   %rax,%rax
jne    1181 <find_test+0x41>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xdf1(%rip),%rdi
lea    0xdec(%rip),%rsi
lea    0xde0(%rip),%rcx
mov    %r12,%rdx
xor    %r8d,%r8d
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_valid_test@plt>
test   %rax,%rax
jne    1181 <find_test+0x41>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r15,%r15
je     1287 <find_test+0x147>
lea    0xdb2(%rip),%rsi
lea    0xda6(%rip),%rcx
mov    %r15,%rdi
mov    %r12,%rdx
xor    %r8d,%r8d
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_valid_test@plt>
test   %rax,%rax
jne    1181 <find_test+0x41>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
je     12c4 <find_test+0x184>
lea    0xd75(%rip),%rsi
lea    0xd69(%rip),%rcx
mov    %r14,%rdi
mov    %r12,%rdx
xor    %r8d,%r8d
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_valid_test@plt>
test   %rax,%rax
jne    1181 <find_test+0x41>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xd3b(%rip),%rdi
lea    0xd36(%rip),%rsi
lea    0xd2e(%rip),%rcx
mov    %r12,%rdx
xor    %r8d,%r8d
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_valid_test@plt>
test   %rax,%rax
jne    1181 <find_test+0x41>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r15,%r15
je     133d <find_test+0x1fd>
lea    0xcfc(%rip),%rsi
lea    0xcf4(%rip),%rcx
mov    %r15,%rdi
mov    %r12,%rdx
xor    %r8d,%r8d
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_valid_test@plt>
test   %rax,%rax
jne    1181 <find_test+0x41>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r14,%r14
je     137a <find_test+0x23a>
lea    0xcbf(%rip),%rsi
lea    0xcb7(%rip),%rcx
mov    %r14,%rdi
mov    %r12,%rdx
xor    %r8d,%r8d
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <is_valid_test@plt>
test   %rax,%rax
jne    1181 <find_test+0x41>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xc89(%rip),%rsi
mov    %r12,%rdi
mov    $0x489,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <x_strdup@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-t\00"
@.str.1 = [3 x i8] c".t\00"
@.str.2 = [1 x i8] zeroinitializer
@__const.find_test.suffixes = [3 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0)]
@.str.3 = [2 x i8] c".\00"
@.str.4 = [2 x i8] c"/\00"
@.str.5 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jeffreykegler/kollos/refs/heads/master/components/tap/runtests.c\00"
define i8* @find_test(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [3 x i8*]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca [3 x i8*]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%15 = bitcast [3 x i8*]* %14 to i8*
%16 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %16
%17 = load i8*, i8** %7
%18 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 1
store i8* %17, i8** %18
%19 = load i8*, i8** %6
%20 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 2
store i8* %19, i8** %20
store i32 0, i32* %12
br label %21
21: ; preds = %59, %3
%22 = load i32, i32* %12
%23 = zext i32 %22 to i64
%24 = icmp ult i64 %23, 3
br i1 %24, label %25, label %62
25: ; preds = %21
%26 = load i32, i32* %12
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [3 x i8*], [3 x i8*]* %14, i64 0, i64 %27
%29 = load i8*, i8** %28
store i8* %29, i8** %10
store i32 0, i32* %13
br label %30
30: ; preds = %55, %25
%31 = load i32, i32* %13
%32 = zext i32 %31 to i64
%33 = icmp ult i64 %32, 3
br i1 %33, label %34, label %58
34: ; preds = %30
%35 = load i32, i32* %13
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds [3 x i8*], [3 x i8*]* %9, i64 0, i64 %36
%38 = load i8*, i8** %37
store i8* %38, i8** %11
%39 = load i8*, i8** %11
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %42
41: ; preds = %34
br label %55
42: ; preds = %34
%43 = load i8*, i8** %11
%44 = load i8*, i8** %5
%45 = load i8*, i8** %10
%46 = call i8* @concat(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %44, i8* %45, i8* null)
store i8* %46, i8** %8
%47 = load i8*, i8** %8
%48 = call i64 @is_valid_test(i8* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %42
%51 = load i8*, i8** %8
store i8* %51, i8** %4
br label %70
52: ; preds = %42
%53 = load i8*, i8** %8
%54 = call i32 @free(i8* %53)
store i8* null, i8** %8
br label %55
55: ; preds = %52, %41
%56 = load i32, i32* %13
%57 = add i32 %56, 1
store i32 %57, i32* %13
br label %30
58: ; preds = %30
br label %59
59: ; preds = %58
%60 = load i32, i32* %12
%61 = add i32 %60, 1
store i32 %61, i32* %12
br label %21
62: ; preds = %21
%63 = load i8*, i8** %8
%64 = icmp eq i8* %63, null
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load i8*, i8** %5
%67 = call i8* @x_strdup(i8* %66, i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.5, i64 0, i64 0), i32 1161)
store i8* %67, i8** %8
br label %68
68: ; preds = %65, %62
%69 = load i8*, i8** %8
store i8* %69, i8** %4
br label %70
70: ; preds = %68, %50
%71 = load i8*, i8** %4
ret i8* %71
}

LLVM IR (-O2):
@.str = [3 x i8] c"-t\00"
@.str.1 = [3 x i8] c".t\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c".\00"
@.str.4 = [2 x i8] c"/\00"
@.str.5 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jeffreykegler/kollos/refs/heads/master/components/tap/runtests.c\00"
define i8* @find_test(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %2, null
%5 = icmp eq i8* %1, null
%6 = tail call i8* @concat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* null)
%7 = tail call i64 @is_valid_test(i8* %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %64
9: ; preds = %3
%10 = tail call i32 @free(i8* %6)
br i1 %4, label %17, label %11
11: ; preds = %9
%12 = tail call i8* @concat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* null)
%13 = tail call i64 @is_valid_test(i8* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %64
15: ; preds = %11
%16 = tail call i32 @free(i8* %12)
br label %17
17: ; preds = %15, %9
br i1 %5, label %24, label %18
18: ; preds = %17
%19 = tail call i8* @concat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* null)
%20 = tail call i64 @is_valid_test(i8* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %64
22: ; preds = %18
%23 = tail call i32 @free(i8* %19)
br label %24
24: ; preds = %22, %17
%25 = tail call i8* @concat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* null)
%26 = tail call i64 @is_valid_test(i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %64
28: ; preds = %24
%29 = tail call i32 @free(i8* %25)
br i1 %4, label %36, label %30
30: ; preds = %28
%31 = tail call i8* @concat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* null)
%32 = tail call i64 @is_valid_test(i8* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %64
34: ; preds = %30
%35 = tail call i32 @free(i8* %31)
br label %36
36: ; preds = %34, %28
br i1 %5, label %43, label %37
37: ; preds = %36
%38 = tail call i8* @concat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* null)
%39 = tail call i64 @is_valid_test(i8* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %64
41: ; preds = %37
%42 = tail call i32 @free(i8* %38)
br label %43
43: ; preds = %41, %36
%44 = tail call i8* @concat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* null)
%45 = tail call i64 @is_valid_test(i8* %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %64
47: ; preds = %43
%48 = tail call i32 @free(i8* %44)
br i1 %4, label %55, label %49
49: ; preds = %47
%50 = tail call i8* @concat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* null)
%51 = tail call i64 @is_valid_test(i8* %50)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %64
53: ; preds = %49
%54 = tail call i32 @free(i8* %50)
br label %55
55: ; preds = %53, %47
br i1 %5, label %62, label %56
56: ; preds = %55
%57 = tail call i8* @concat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* null)
%58 = tail call i64 @is_valid_test(i8* %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = tail call i32 @free(i8* %57)
br label %62
62: ; preds = %60, %55
%63 = tail call i8* @x_strdup(i8* %0, i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.5, i64 0, i64 0), i32 1161)
br label %64
64: ; preds = %3, %11, %18, %24, %30, %37, %43, %49, %56, %62
%65 = phi i8* [ %63, %62 ], [ %19, %18 ], [ %12, %11 ], [ %6, %3 ], [ %25, %24 ], [ %31, %30 ], [ %38, %37 ], [ %44, %43 ], [ %50, %49 ], [ %57, %56 ]
ret i8* %65
}