#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 */
scalar_t__ check_executable(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ *getcwd(char *, int);
char *getenv(char *);
int /*<<< orphan*/ lt_debugprintf(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ lt_fatal(char *, int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ nonempty(char const *);
int /*<<< orphan*/ nonnull(int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int strlen(char const *);
scalar_t__ xmalloc(int);
char *xstrdup(char const *);
char *find_executable(const char *wrapper) {
  int has_slash = 0;
  const char *p;
  const char *p_next;
  char tmp[1024 + 1];
  int tmp_len;
  char *concat_name;
  lt_debugprintf(
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/JosenChareles/os-virt-viewer/refs/heads/"
      "master/src/.libs/lt-windows-cmdline-wrapper.c",
      411, "(find_executable): %s\n", nonempty(wrapper));
  if ((wrapper == NULL) || (*wrapper == '\0'))
    return NULL;
  if (((wrapper[0]) == '/')) {
    concat_name = xstrdup(wrapper);
    if (check_executable(concat_name))
      return concat_name;
    do {
      if (concat_name) {
        free((void *)concat_name);
        concat_name = 0;
      }
    } while (0);
  }
  for (p = wrapper; *p; p++)
    if (*p == '/') {
      has_slash = 1;
      break;
    }
  if (!has_slash) {
    const char *path = getenv("PATH");
    if (path != NULL) {
      for (p = path; *p; p = p_next) {
        const char *q;
        size_t p_len;
        for (q = p; *q; q++)
          if (((*q) == ':'))
            break;
        p_len = q - p;
        p_next = (*q == '\0' ? q : q + 1);
        if (p_len == 0) {
          if (getcwd(tmp, 1024) == NULL)
            lt_fatal("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/JosenChareles/"
                     "os-virt-viewer/refs/heads/master/src/.libs/"
                     "lt-windows-cmdline-wrapper.c",
                     465, "getcwd failed: %s", nonnull(strerror(errno)));
          tmp_len = strlen(tmp);
          concat_name = ((char *)xmalloc((tmp_len + 1 + strlen(wrapper) + 1) *
                                         sizeof(char)));
          memcpy(concat_name, tmp, tmp_len);
          concat_name[tmp_len] = '/';
          strcpy(concat_name + tmp_len + 1, wrapper);
        } else {
          concat_name = ((char *)xmalloc((p_len + 1 + strlen(wrapper) + 1) *
                                         sizeof(char)));
          memcpy(concat_name, p, p_len);
          concat_name[p_len] = '/';
          strcpy(concat_name + p_len + 1, wrapper);
        }
        if (check_executable(concat_name))
          return concat_name;
        do {
          if (concat_name) {
            free((void *)concat_name);
            concat_name = 0;
          }
        } while (0);
      }
    }
  }
  if (getcwd(tmp, 1024) == NULL)
    lt_fatal("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/JosenChareles/os-virt-viewer/refs/"
             "heads/master/src/.libs/lt-windows-cmdline-wrapper.c",
             491, "getcwd failed: %s", nonnull(strerror(errno)));
  tmp_len = strlen(tmp);
  concat_name =
      ((char *)xmalloc((tmp_len + 1 + strlen(wrapper) + 1) * sizeof(char)));
  memcpy(concat_name, tmp, tmp_len);
  concat_name[tmp_len] = '/';
  strcpy(concat_name + tmp_len + 1, wrapper);
  if (check_executable(concat_name))
    return concat_name;
  do {
    if (concat_name) {
      free((void *)concat_name);
      concat_name = 0;
    }
  } while (0);
  return NULL;
}


x86 assembly (clang, -O0):
<find_executable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x480,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <nonempty@plt>
mov    %eax,%ecx
lea    0xdf8(%rip),%rdi
mov    $0x19b,%esi
lea    0xe9c(%rip),%rdx
call   10f0 <lt_debugprintf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1234 <find_executable+0x54>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1241 <find_executable+0x61>
movq   $0x0,-0x8(%rbp)
jmp    170f <find_executable+0x52f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    12bb <find_executable+0xdb>
mov    -0x10(%rbp),%rdi
call   10b0 <xstrdup@plt>
mov    %rax,-0x440(%rbp)
mov    -0x440(%rbp),%rdi
call   10e0 <check_executable@plt>
cmp    $0x0,%rax
je     1287 <find_executable+0xa7>
mov    -0x440(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    170f <find_executable+0x52f>
jmp    128c <find_executable+0xac>
cmpq   $0x0,-0x440(%rbp)
je     12b1 <find_executable+0xd1>
mov    -0x440(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x440(%rbp)
jmp    12b6 <find_executable+0xd6>
jmp    12bb <find_executable+0xdb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1302 <find_executable+0x122>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    12ec <find_executable+0x10c>
movl   $0x1,-0x14(%rbp)
jmp    1302 <find_executable+0x122>
jmp    12f1 <find_executable+0x111>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    12c3 <find_executable+0xe3>
cmpl   $0x0,-0x14(%rbp)
jne    15d4 <find_executable+0x3f4>
lea    0xdb4(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x448(%rbp)
cmpq   $0x0,-0x448(%rbp)
je     15cf <find_executable+0x3ef>
mov    -0x448(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     15ca <find_executable+0x3ea>
mov    -0x20(%rbp),%rax
mov    %rax,-0x450(%rbp)
mov    -0x450(%rbp),%rax
cmpb   $0x0,(%rax)
je     1394 <find_executable+0x1b4>
mov    -0x450(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1378 <find_executable+0x198>
jmp    1394 <find_executable+0x1b4>
jmp    137d <find_executable+0x19d>
mov    -0x450(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x450(%rbp)
jmp    1350 <find_executable+0x170>
mov    -0x450(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x458(%rbp)
mov    -0x450(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    13cf <find_executable+0x1ef>
mov    -0x450(%rbp),%rax
mov    %rax,-0x460(%rbp)
jmp    13e1 <find_executable+0x201>
mov    -0x450(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x460(%rbp)
mov    -0x460(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x458(%rbp)
jne    14dd <find_executable+0x2fd>
lea    -0x430(%rbp),%rdi
mov    $0x400,%esi
call   1090 <getcwd@plt>
cmp    $0x0,%rax
jne    1444 <find_executable+0x264>
mov    0x2bc4(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %eax,%edi
call   10c0 <nonnull@plt>
mov    %eax,%ecx
lea    0xbcd(%rip),%rdi
mov    $0x1d1,%esi
lea    0xc8d(%rip),%rdx
call   1050 <lt_fatal@plt>
lea    -0x430(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x434(%rbp)
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x464(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x464(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <xmalloc@plt>
mov    %rax,-0x440(%rbp)
mov    -0x440(%rbp),%rdi
lea    -0x430(%rbp),%rsi
mov    -0x434(%rbp),%edx
call   10d0 <memcpy@plt>
mov    -0x440(%rbp),%rax
movslq -0x434(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x440(%rbp),%rdi
movslq -0x434(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcpy@plt>
jmp    1563 <find_executable+0x383>
mov    -0x458(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x470(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x470(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <xmalloc@plt>
mov    %rax,-0x440(%rbp)
mov    -0x440(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x458(%rbp),%rax
mov    %eax,%edx
call   10d0 <memcpy@plt>
mov    -0x440(%rbp),%rax
mov    -0x458(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x440(%rbp),%rdi
add    -0x458(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcpy@plt>
mov    -0x440(%rbp),%rdi
call   10e0 <check_executable@plt>
cmp    $0x0,%rax
je     1589 <find_executable+0x3a9>
mov    -0x440(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    170f <find_executable+0x52f>
jmp    158e <find_executable+0x3ae>
cmpq   $0x0,-0x440(%rbp)
je     15b3 <find_executable+0x3d3>
mov    -0x440(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x440(%rbp)
jmp    15b8 <find_executable+0x3d8>
jmp    15bd <find_executable+0x3dd>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1338 <find_executable+0x158>
jmp    15cf <find_executable+0x3ef>
jmp    15d4 <find_executable+0x3f4>
lea    -0x430(%rbp),%rdi
mov    $0x400,%esi
call   1090 <getcwd@plt>
cmp    $0x0,%rax
jne    161e <find_executable+0x43e>
mov    0x29ea(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %eax,%edi
call   10c0 <nonnull@plt>
mov    %eax,%ecx
lea    0x9f3(%rip),%rdi
mov    $0x1eb,%esi
lea    0xab3(%rip),%rdx
call   1050 <lt_fatal@plt>
lea    -0x430(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,-0x434(%rbp)
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x474(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x474(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <xmalloc@plt>
mov    %rax,-0x440(%rbp)
mov    -0x440(%rbp),%rdi
lea    -0x430(%rbp),%rsi
mov    -0x434(%rbp),%edx
call   10d0 <memcpy@plt>
mov    -0x440(%rbp),%rax
movslq -0x434(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x440(%rbp),%rdi
movslq -0x434(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcpy@plt>
mov    -0x440(%rbp),%rdi
call   10e0 <check_executable@plt>
cmp    $0x0,%rax
je     16d8 <find_executable+0x4f8>
mov    -0x440(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    170f <find_executable+0x52f>
jmp    16dd <find_executable+0x4fd>
cmpq   $0x0,-0x440(%rbp)
je     1702 <find_executable+0x522>
mov    -0x440(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x440(%rbp)
jmp    1707 <find_executable+0x527>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_executable>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%r13
call   1070 <nonempty@plt>
lea    0xe00(%rip),%rdi
lea    0xea9(%rip),%rdx
mov    $0x19b,%esi
mov    %eax,%ecx
call   10f0 <lt_debugprintf@plt>
test   %r13,%r13
je     1462 <find_executable+0x282>
mov    0x0(%r13),%al
test   %al,%al
je     1462 <find_executable+0x282>
cmp    $0x2f,%al
jne    1255 <find_executable+0x75>
mov    %r13,%rdi
call   10b0 <xstrdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10e0 <check_executable@plt>
test   %rax,%rax
jne    1464 <find_executable+0x284>
test   %rbx,%rbx
je     1255 <find_executable+0x75>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %r13,%rax
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
test   %cl,%cl
je     1276 <find_executable+0x96>
cmp    $0x2f,%cl
je     13c0 <find_executable+0x1e0>
add    $0x1,%rax
jmp    1260 <find_executable+0x80>
lea    0xe4a(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     13c0 <find_executable+0x1e0>
mov    %rax,%r12
mov    (%rax),%al
test   %al,%al
je     13c0 <find_executable+0x1e0>
mov    %r12,%rbp
nopl   0x0(%rax,%rax,1)
xor    %r14d,%r14d
test   %al,%al
je     12c4 <find_executable+0xe4>
nopw   0x0(%rax,%rax,1)
cmp    $0x3a,%al
je     12c4 <find_executable+0xe4>
movzbl 0x1(%rbp),%eax
add    $0x1,%rbp
add    $0xffffffffffffffff,%r14
test   %al,%al
jne    12b0 <find_executable+0xd0>
cmp    $0x1,%al
sbb    $0xffffffffffffffff,%rbp
test   %r14,%r14
je     1310 <find_executable+0x130>
mov    %r13,%rdi
call   1080 <strlen@plt>
sub    %r14d,%eax
mov    %r14d,%r15d
neg    %r15d
lea    0x2(%rax),%edi
call   10a0 <xmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   10d0 <memcpy@plt>
mov    %rbx,%rdi
sub    %r14,%rdi
jmp    138a <find_executable+0x1aa>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x400,%esi
call   1090 <getcwd@plt>
test   %rax,%rax
jne    1354 <find_executable+0x174>
mov    0x2cb4(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %eax,%edi
call   10c0 <nonnull@plt>
lea    0xcbf(%rip),%rdi
mov    $0x1d1,%esi
lea    0xd7f(%rip),%rdx
mov    %eax,%ecx
call   1050 <lt_fatal@plt>
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %eax,%r15d
mov    %r13,%rdi
call   1080 <strlen@plt>
lea    (%r15,%rax,1),%edi
add    $0x2,%edi
call   10a0 <xmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   10d0 <memcpy@plt>
movslq %r15d,%rdi
add    %rbx,%rdi
movb   $0x2f,(%rdi)
add    $0x1,%rdi
mov    %r13,%rsi
call   1060 <strcpy@plt>
mov    %rbx,%rdi
call   10e0 <check_executable@plt>
test   %rax,%rax
jne    1464 <find_executable+0x284>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    0x0(%rbp),%al
mov    %rbp,%r12
test   %al,%al
jne    12a0 <find_executable+0xc0>
mov    %rsp,%rdi
mov    $0x400,%esi
call   1090 <getcwd@plt>
test   %rax,%rax
jne    1401 <find_executable+0x221>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %eax,%edi
call   10c0 <nonnull@plt>
lea    0xc12(%rip),%rdi
lea    0xcd7(%rip),%rdx
mov    $0x1eb,%esi
mov    %eax,%ecx
call   1050 <lt_fatal@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <strlen@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1080 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x2,%edi
call   10a0 <xmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   10d0 <memcpy@plt>
movslq %ebp,%rax
movb   $0x2f,(%rbx,%rax,1)
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
mov    %r13,%rsi
call   1060 <strcpy@plt>
mov    %rbx,%rdi
call   10e0 <check_executable@plt>
test   %rax,%rax
jne    1464 <find_executable+0x284>
test   %rbx,%rbx
je     1462 <find_executable+0x282>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [176 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/JosenChareles/os-virt-viewer/refs/heads/master/src/.libs/lt-windows-cmdline-wrapper.c\00"
@.str.1 = [23 x i8] c"(find_executable): %s\0A\00"
@.str.2 = [5 x i8] c"PATH\00"
@.str.3 = [18 x i8] c"getcwd failed: %s\00"
@errno = global i32 0
define i8* @find_executable(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [1025 x i8]
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i64
store i8* %0, i8** %3
store i32 0, i32* %4
%13 = load i8*, i8** %3
%14 = call i32 @nonempty(i8* %13)
%15 = call i32 @lt_debugprintf(i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 411, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i8*, i8** %3
%17 = icmp eq i8* %16, null
br i1 %17, label %23, label %18
18: ; preds = %1
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18, %1
store i8* null, i8** %2
br label %246
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 47
br i1 %29, label %30, label %47
30: ; preds = %24
%31 = load i8*, i8** %3
%32 = call i8* @xstrdup(i8* %31)
store i8* %32, i8** %9
%33 = load i8*, i8** %9
%34 = call i64 @check_executable(i8* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = load i8*, i8** %9
store i8* %37, i8** %2
br label %246
38: ; preds = %30
br label %39
39: ; preds = %38
%40 = load i8*, i8** %9
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i8*, i8** %9
%44 = call i32 @free(i8* %43)
store i8* null, i8** %9
br label %45
45: ; preds = %42, %39
br label %46
46: ; preds = %45
br label %47
47: ; preds = %46, %24
%48 = load i8*, i8** %3
store i8* %48, i8** %5
br label %49
49: ; preds = %60, %47
%50 = load i8*, i8** %5
%51 = load i8, i8* %50
%52 = icmp ne i8 %51, 0
br i1 %52, label %53, label %63
53: ; preds = %49
%54 = load i8*, i8** %5
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 47
br i1 %57, label %58, label %59
58: ; preds = %53
store i32 1, i32* %4
br label %63
59: ; preds = %53
br label %60
60: ; preds = %59
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i32 1
store i8* %62, i8** %5
br label %49
63: ; preds = %58, %49
%64 = load i32, i32* %4
%65 = icmp ne i32 %64, 0
br i1 %65, label %194, label %66
66: ; preds = %63
%67 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %67, i8** %10
%68 = load i8*, i8** %10
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %193
70: ; preds = %66
%71 = load i8*, i8** %10
store i8* %71, i8** %5
br label %72
72: ; preds = %190, %70
%73 = load i8*, i8** %5
%74 = load i8, i8* %73
%75 = icmp ne i8 %74, 0
br i1 %75, label %76, label %192
76: ; preds = %72
%77 = load i8*, i8** %5
store i8* %77, i8** %11
br label %78
78: ; preds = %89, %76
%79 = load i8*, i8** %11
%80 = load i8, i8* %79
%81 = icmp ne i8 %80, 0
br i1 %81, label %82, label %92
82: ; preds = %78
%83 = load i8*, i8** %11
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = icmp eq i32 %85, 58
br i1 %86, label %87, label %88
87: ; preds = %82
br label %92
88: ; preds = %82
br label %89
89: ; preds = %88
%90 = load i8*, i8** %11
%91 = getelementptr inbounds i8, i8* %90, i32 1
store i8* %91, i8** %11
br label %78
92: ; preds = %87, %78
%93 = load i8*, i8** %11
%94 = load i8*, i8** %5
%95 = ptrtoint i8* %93 to i64
%96 = ptrtoint i8* %94 to i64
%97 = sub i64 %95, %96
store i64 %97, i64* %12
%98 = load i8*, i8** %11
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %104
102: ; preds = %92
%103 = load i8*, i8** %11
br label %107
104: ; preds = %92
%105 = load i8*, i8** %11
%106 = getelementptr inbounds i8, i8* %105, i64 1
br label %107
107: ; preds = %104, %102
%108 = phi i8* [ %103, %102 ], [ %106, %104 ]
store i8* %108, i8** %6
%109 = load i64, i64* %12
%110 = icmp eq i64 %109, 0
br i1 %110, label %111, label %149
111: ; preds = %107
%112 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%113 = call i32* @getcwd(i8* %112, i32 1024)
%114 = icmp eq i32* %113, null
br i1 %114, label %115, label %120
115: ; preds = %111
%116 = load i32, i32* @errno
%117 = call i32 @strerror(i32 %116)
%118 = call i32 @nonnull(i32 %117)
%119 = call i32 @lt_fatal(i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 465, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %118)
br label %120
120: ; preds = %115, %111
%121 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%122 = call i32 @strlen(i8* %121)
store i32 %122, i32* %8
%123 = load i32, i32* %8
%124 = add nsw i32 %123, 1
%125 = load i8*, i8** %3
%126 = call i32 @strlen(i8* %125)
%127 = add nsw i32 %124, %126
%128 = add nsw i32 %127, 1
%129 = sext i32 %128 to i64
%130 = mul i64 %129, 1
%131 = trunc i64 %130 to i32
%132 = call i64 @xmalloc(i32 %131)
%133 = inttoptr i64 %132 to i8*
store i8* %133, i8** %9
%134 = load i8*, i8** %9
%135 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%136 = load i32, i32* %8
%137 = call i32 @memcpy(i8* %134, i8* %135, i32 %136)
%138 = load i8*, i8** %9
%139 = load i32, i32* %8
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %138, i64 %140
store i8 47, i8* %141
%142 = load i8*, i8** %9
%143 = load i32, i32* %8
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds i8, i8* %142, i64 %144
%146 = getelementptr inbounds i8, i8* %145, i64 1
%147 = load i8*, i8** %3
%148 = call i32 @strcpy(i8* %146, i8* %147)
br label %175
149: ; preds = %107
%150 = load i64, i64* %12
%151 = add i64 %150, 1
%152 = load i8*, i8** %3
%153 = call i32 @strlen(i8* %152)
%154 = sext i32 %153 to i64
%155 = add i64 %151, %154
%156 = add i64 %155, 1
%157 = mul i64 %156, 1
%158 = trunc i64 %157 to i32
%159 = call i64 @xmalloc(i32 %158)
%160 = inttoptr i64 %159 to i8*
store i8* %160, i8** %9
%161 = load i8*, i8** %9
%162 = load i8*, i8** %5
%163 = load i64, i64* %12
%164 = trunc i64 %163 to i32
%165 = call i32 @memcpy(i8* %161, i8* %162, i32 %164)
%166 = load i8*, i8** %9
%167 = load i64, i64* %12
%168 = getelementptr inbounds i8, i8* %166, i64 %167
store i8 47, i8* %168
%169 = load i8*, i8** %9
%170 = load i64, i64* %12
%171 = getelementptr inbounds i8, i8* %169, i64 %170
%172 = getelementptr inbounds i8, i8* %171, i64 1
%173 = load i8*, i8** %3
%174 = call i32 @strcpy(i8* %172, i8* %173)
br label %175
175: ; preds = %149, %120
%176 = load i8*, i8** %9
%177 = call i64 @check_executable(i8* %176)
%178 = icmp ne i64 %177, 0
br i1 %178, label %179, label %181
179: ; preds = %175
%180 = load i8*, i8** %9
store i8* %180, i8** %2
br label %246
181: ; preds = %175
br label %182
182: ; preds = %181
%183 = load i8*, i8** %9
%184 = icmp ne i8* %183, null
br i1 %184, label %185, label %188
185: ; preds = %182
%186 = load i8*, i8** %9
%187 = call i32 @free(i8* %186)
store i8* null, i8** %9
br label %188
188: ; preds = %185, %182
br label %189
189: ; preds = %188
br label %190
190: ; preds = %189
%191 = load i8*, i8** %6
store i8* %191, i8** %5
br label %72
192: ; preds = %72
br label %193
193: ; preds = %192, %66
br label %194
194: ; preds = %193, %63
%195 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%196 = call i32* @getcwd(i8* %195, i32 1024)
%197 = icmp eq i32* %196, null
br i1 %197, label %198, label %203
198: ; preds = %194
%199 = load i32, i32* @errno
%200 = call i32 @strerror(i32 %199)
%201 = call i32 @nonnull(i32 %200)
%202 = call i32 @lt_fatal(i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 491, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %201)
br label %203
203: ; preds = %198, %194
%204 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%205 = call i32 @strlen(i8* %204)
store i32 %205, i32* %8
%206 = load i32, i32* %8
%207 = add nsw i32 %206, 1
%208 = load i8*, i8** %3
%209 = call i32 @strlen(i8* %208)
%210 = add nsw i32 %207, %209
%211 = add nsw i32 %210, 1
%212 = sext i32 %211 to i64
%213 = mul i64 %212, 1
%214 = trunc i64 %213 to i32
%215 = call i64 @xmalloc(i32 %214)
%216 = inttoptr i64 %215 to i8*
store i8* %216, i8** %9
%217 = load i8*, i8** %9
%218 = getelementptr inbounds [1025 x i8], [1025 x i8]* %7, i64 0, i64 0
%219 = load i32, i32* %8
%220 = call i32 @memcpy(i8* %217, i8* %218, i32 %219)
%221 = load i8*, i8** %9
%222 = load i32, i32* %8
%223 = sext i32 %222 to i64
%224 = getelementptr inbounds i8, i8* %221, i64 %223
store i8 47, i8* %224
%225 = load i8*, i8** %9
%226 = load i32, i32* %8
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds i8, i8* %225, i64 %227
%229 = getelementptr inbounds i8, i8* %228, i64 1
%230 = load i8*, i8** %3
%231 = call i32 @strcpy(i8* %229, i8* %230)
%232 = load i8*, i8** %9
%233 = call i64 @check_executable(i8* %232)
%234 = icmp ne i64 %233, 0
br i1 %234, label %235, label %237
235: ; preds = %203
%236 = load i8*, i8** %9
store i8* %236, i8** %2
br label %246
237: ; preds = %203
br label %238
238: ; preds = %237
%239 = load i8*, i8** %9
%240 = icmp ne i8* %239, null
br i1 %240, label %241, label %244
241: ; preds = %238
%242 = load i8*, i8** %9
%243 = call i32 @free(i8* %242)
store i8* null, i8** %9
br label %244
244: ; preds = %241, %238
br label %245
245: ; preds = %244
store i8* null, i8** %2
br label %246
246: ; preds = %245, %235, %179, %36, %23
%247 = load i8*, i8** %2
ret i8* %247
}

LLVM IR (-O2):
@.str = [176 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/JosenChareles/os-virt-viewer/refs/heads/master/src/.libs/lt-windows-cmdline-wrapper.c\00"
@.str.1 = [23 x i8] c"(find_executable): %s\0A\00"
@.str.2 = [5 x i8] c"PATH\00"
@.str.3 = [18 x i8] c"getcwd failed: %s\00"
@errno = global i32 0
define i8* @find_executable(i8* %0) {
%2 = alloca [1025 x i8]
%3 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @nonempty(i8* %0)
%5 = tail call i32 @lt_debugprintf(i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 411, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = icmp eq i8* %0, null
br i1 %6, label %110, label %7
7: ; preds = %1
%8 = load i8, i8* %0
switch i8 %8, label %17 [
i8 0, label %110
i8 47, label %9
]
9: ; preds = %7
%10 = tail call i8* @xstrdup(i8* %0)
%11 = tail call i64 @check_executable(i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %110
13: ; preds = %9
%14 = icmp eq i8* %10, null
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = tail call i32 @free(i8* %10)
br label %17
17: ; preds = %7, %13, %15
br label %18
18: ; preds = %17, %21
%19 = phi i8* [ %22, %21 ], [ %0, %17 ]
%20 = load i8, i8* %19
switch i8 %20, label %21 [
i8 0, label %23
i8 47, label %84
]
21: ; preds = %18
%22 = getelementptr inbounds i8, i8* %19, i64 1
br label %18
23: ; preds = %18
%24 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i8* %24, null
br i1 %25, label %84, label %26
26: ; preds = %23
%27 = load i8, i8* %24
%28 = icmp eq i8 %27, 0
br i1 %28, label %84, label %29
29: ; preds = %26, %80
%30 = phi i8 [ %82, %80 ], [ %27, %26 ]
%31 = phi i8* [ %44, %80 ], [ %24, %26 ]
br label %32
32: ; preds = %29, %35
%33 = phi i8 [ %37, %35 ], [ %30, %29 ]
%34 = phi i8* [ %36, %35 ], [ %31, %29 ]
switch i8 %33, label %35 [
i8 0, label %38
i8 58, label %38
]
35: ; preds = %32
%36 = getelementptr inbounds i8, i8* %34, i64 1
%37 = load i8, i8* %36
br label %32
38: ; preds = %32, %32
%39 = ptrtoint i8* %34 to i64
%40 = ptrtoint i8* %31 to i64
%41 = sub i64 %39, %40
%42 = icmp ne i8 %33, 0
%43 = zext i1 %42 to i64
%44 = getelementptr i8, i8* %34, i64 %43
%45 = icmp eq i64 %41, 0
br i1 %45, label %46, label %64
46: ; preds = %38
%47 = call i32* @getcwd(i8* %3, i32 1024)
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32, i32* @errno
%51 = call i32 @strerror(i32 %50)
%52 = call i32 @nonnull(i32 %51)
%53 = call i32 @lt_fatal(i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 465, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %49, %46
%55 = call i32 @strlen(i8* %3)
%56 = call i32 @strlen(i8* %0)
%57 = add i32 %55, 2
%58 = add i32 %57, %56
%59 = call i64 @xmalloc(i32 %58)
%60 = inttoptr i64 %59 to i8*
%61 = call i32 @memcpy(i8* %60, i8* %3, i32 %55)
%62 = sext i32 %55 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
br label %73
64: ; preds = %38
%65 = call i32 @strlen(i8* %0)
%66 = trunc i64 %41 to i32
%67 = add i32 %66, 2
%68 = add i32 %67, %65
%69 = call i64 @xmalloc(i32 %68)
%70 = inttoptr i64 %69 to i8*
%71 = call i32 @memcpy(i8* %70, i8* %31, i32 %66)
%72 = getelementptr inbounds i8, i8* %70, i64 %41
br label %73
73: ; preds = %64, %54
%74 = phi i8* [ %72, %64 ], [ %63, %54 ]
%75 = phi i8* [ %70, %64 ], [ %60, %54 ]
store i8 47, i8* %74
%76 = getelementptr inbounds i8, i8* %74, i64 1
%77 = call i32 @strcpy(i8* %76, i8* %0)
%78 = call i64 @check_executable(i8* %75)
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %110
80: ; preds = %73
%81 = call i32 @free(i8* %75)
%82 = load i8, i8* %44
%83 = icmp eq i8 %82, 0
br i1 %83, label %84, label %29
84: ; preds = %18, %80, %26, %23
%85 = call i32* @getcwd(i8* %3, i32 1024)
%86 = icmp eq i32* %85, null
br i1 %86, label %87, label %92
87: ; preds = %84
%88 = load i32, i32* @errno
%89 = call i32 @strerror(i32 %88)
%90 = call i32 @nonnull(i32 %89)
%91 = call i32 @lt_fatal(i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str, i64 0, i64 0), i32 491, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %90)
br label %92
92: ; preds = %87, %84
%93 = call i32 @strlen(i8* %3)
%94 = call i32 @strlen(i8* %0)
%95 = add i32 %93, 2
%96 = add i32 %95, %94
%97 = call i64 @xmalloc(i32 %96)
%98 = inttoptr i64 %97 to i8*
%99 = call i32 @memcpy(i8* %98, i8* %3, i32 %93)
%100 = sext i32 %93 to i64
%101 = getelementptr inbounds i8, i8* %98, i64 %100
store i8 47, i8* %101
%102 = getelementptr inbounds i8, i8* %101, i64 1
%103 = call i32 @strcpy(i8* %102, i8* %0)
%104 = call i64 @check_executable(i8* %98)
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %110
106: ; preds = %92
%107 = icmp eq i64 %97, 0
br i1 %107, label %110, label %108
108: ; preds = %106
%109 = call i32 @free(i8* %98)
br label %110
110: ; preds = %73, %106, %108, %92, %9, %7, %1
%111 = phi i8* [ null, %7 ], [ null, %1 ], [ %10, %9 ], [ %98, %92 ], [ null, %108 ], [ null, %106 ], [ %75, %73 ]
ret i8* %111
}