#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 */
char *flon_exid_path(char *);
char flu_fstat(char *);
char *flu_sprintf(char *, char *);
int /*<<< orphan*/ free(char *);
char *find_path(char *exid) {
  char *fep = flon_exid_path(exid);
  char *path = flu_sprintf("var/archive/%s", fep);
  if (flu_fstat(path) == 'd') {
    free(fep);
    return path;
  }
  free(path);
  path = flu_sprintf("var/run/%s", fep);
  if (flu_fstat(path) == 'd') {
    free(fep);
    return path;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<find_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <flon_exid_path@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe9c(%rip),%rdi
call   1050 <flu_sprintf@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <flu_fstat@plt>
movsbl %al,%eax
cmp    $0x64,%eax
jne    1198 <find_path+0x58>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <find_path+0xa8>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rsi
lea    0xe63(%rip),%rdi
call   1050 <flu_sprintf@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <flu_fstat@plt>
movsbl %al,%eax
cmp    $0x64,%eax
jne    11e0 <find_path+0xa0>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <find_path+0xa8>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_path>:
push   %r14
push   %rbx
push   %rax
call   1040 <flon_exid_path@plt>
mov    %rax,%r14
lea    0xead(%rip),%rdi
mov    %rax,%rsi
call   1050 <flu_sprintf@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <flu_fstat@plt>
cmp    $0x64,%al
je     1190 <find_path+0x50>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe96(%rip),%rdi
mov    %r14,%rsi
call   1050 <flu_sprintf@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <flu_fstat@plt>
cmp    $0x64,%al
jne    119a <find_path+0x5a>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    119c <find_path+0x5c>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"var/archive/%s\00"
@.str.1 = [11 x i8] c"var/run/%s\00"
define i8* @find_path(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 i8* @flon_exid_path(i8* %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = call i8* @flu_sprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %8)
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = call signext i8 @flu_fstat(i8* %10)
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 100
br i1 %13, label %14, label %18
14: ; preds = %1
%15 = load i8*, i8** %4
%16 = call i32 @free(i8* %15)
%17 = load i8*, i8** %5
store i8* %17, i8** %2
br label %32
18: ; preds = %1
%19 = load i8*, i8** %5
%20 = call i32 @free(i8* %19)
%21 = load i8*, i8** %4
%22 = call i8* @flu_sprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i8* %22, i8** %5
%23 = load i8*, i8** %5
%24 = call signext i8 @flu_fstat(i8* %23)
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 100
br i1 %26, label %27, label %31
27: ; preds = %18
%28 = load i8*, i8** %4
%29 = call i32 @free(i8* %28)
%30 = load i8*, i8** %5
store i8* %30, i8** %2
br label %32
31: ; preds = %18
store i8* null, i8** %2
br label %32
32: ; preds = %31, %27, %14
%33 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
@.str = [15 x i8] c"var/archive/%s\00"
@.str.1 = [11 x i8] c"var/run/%s\00"
define i8* @find_path(i8* %0) {
%2 = tail call i8* @flon_exid_path(i8* %0)
%3 = tail call i8* @flu_sprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = tail call signext i8 @flu_fstat(i8* %3)
%5 = icmp eq i8 %4, 100
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = tail call i32 @free(i8* %3)
%8 = tail call i8* @flu_sprintf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%9 = tail call signext i8 @flu_fstat(i8* %8)
%10 = icmp eq i8 %9, 100
br i1 %10, label %11, label %14
11: ; preds = %6, %1
%12 = phi i8* [ %3, %1 ], [ %8, %6 ]
%13 = tail call i32 @free(i8* %2)
br label %14
14: ; preds = %11, %6
%15 = phi i8* [ null, %6 ], [ %12, %11 ]
ret i8* %15
}