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


x86 assembly (clang, -O0):
<flon_var_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)
cmpq   $0x0,-0x18(%rbp)
jne    1171 <flon_var_path+0x31>
movq   $0x0,-0x8(%rbp)
jmp    11cd <flon_var_path+0x8d>
mov    -0x18(%rbp),%rsi
lea    0xe84(%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    119f <flon_var_path+0x5f>
jmp    11bc <flon_var_path+0x7c>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rsi
lea    0xe58(%rip),%rdi
call   1050 <flu_sprintf@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flon_var_path>:
push   %r14
push   %rbx
push   %rax
call   1040 <flon_exid_path@plt>
test   %rax,%rax
je     1193 <flon_var_path+0x53>
mov    %rax,%r14
lea    0xea8(%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     1189 <flon_var_path+0x49>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe8d(%rip),%rdi
mov    %r14,%rsi
call   1050 <flu_sprintf@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <free@plt>
jmp    1195 <flon_var_path+0x55>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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