#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*/ recent_file;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
char *getenv(char *);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char const *);
int /*<<< orphan*/ strchr(char const *, char);
int strlen(char const *);
const char *x_fib_recent_file(const char *appname) {
  static char recent_file[1024];
  assert(!strchr(appname, '/'));
  const char *xdg = getenv("XDG_DATA_HOME");
  if (xdg && (strlen(xdg) + strlen(appname) + 10) < sizeof(recent_file)) {
    sprintf(recent_file,
            "%s"
            "/"
            "%s"
            "/"
            "recent",
            xdg, appname);
    return recent_file;
  }
  const char *home = getenv("HOME");
  if (home && (strlen(home) + strlen(appname) + 22) < sizeof(recent_file)) {
    sprintf(recent_file, "%s/.local/share/%s/recent", home, appname);
    return recent_file;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<x_fib_recent_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe7d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ef <x_fib_recent_file+0x9f>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
add    $0xa,%eax
cltq
cmp    $0x400,%rax
jae    11ef <x_fib_recent_file+0x9f>
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0x2e8d(%rip),%rdi
lea    0xe34(%rip),%rsi
call   1070 <sprintf@plt>
lea    0x2e7a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126a <x_fib_recent_file+0x11a>
lea    0xe13(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1262 <x_fib_recent_file+0x112>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
add    $0x16,%eax
cltq
cmp    $0x400,%rax
jae    1262 <x_fib_recent_file+0x112>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0x2e1a(%rip),%rdi
lea    0xdce(%rip),%rsi
call   1070 <sprintf@plt>
lea    0x2e07(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126a <x_fib_recent_file+0x11a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x_fib_recent_file>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x2f,%esi
call   1050 <strchr@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xe8a(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11b3 <x_fib_recent_file+0x63>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %r15d,%eax
add    $0xa,%eax
cmp    $0x3ff,%eax
ja     11b3 <x_fib_recent_file+0x63>
lea    0x2eb6(%rip),%r15
lea    0xe5d(%rip),%rsi
jmp    11f5 <x_fib_recent_file+0xa5>
lea    0xe4f(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1205 <x_fib_recent_file+0xb5>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %r15d,%eax
add    $0x16,%eax
cmp    $0x3ff,%eax
ja     1205 <x_fib_recent_file+0xb5>
lea    0x2e72(%rip),%r15
lea    0xe26(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1070 <sprintf@plt>
jmp    1208 <x_fib_recent_file+0xb8>
xor    %r15d,%r15d
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@x_fib_recent_file.recent_file = internal global [1024 x i8] zeroinitializer
@.str = [14 x i8] c"XDG_DATA_HOME\00"
@.str.1 = [13 x i8] c"%s/%s/recent\00"
@.str.2 = [5 x i8] c"HOME\00"
@.str.3 = [26 x i8] c"%s/.local/share/%s/recent\00"
define i8* @x_fib_recent_file(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 i32 @strchr(i8* %6, i8 signext 47)
%8 = icmp ne i32 %7, 0
%9 = xor i1 %8, true
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i8* @getenv(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %28
15: ; preds = %1
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %17, %19
%21 = add nsw i32 %20, 10
%22 = sext i32 %21 to i64
%23 = icmp ult i64 %22, 1024
br i1 %23, label %24, label %28
24: ; preds = %15
%25 = load i8*, i8** %4
%26 = load i8*, i8** %3
%27 = call i32 @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @x_fib_recent_file.recent_file, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %26)
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @x_fib_recent_file.recent_file, i64 0, i64 0), i8** %2
br label %46
28: ; preds = %15, %1
%29 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i8* %29, i8** %5
%30 = load i8*, i8** %5
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %45
32: ; preds = %28
%33 = load i8*, i8** %5
%34 = call i32 @strlen(i8* %33)
%35 = load i8*, i8** %3
%36 = call i32 @strlen(i8* %35)
%37 = add nsw i32 %34, %36
%38 = add nsw i32 %37, 22
%39 = sext i32 %38 to i64
%40 = icmp ult i64 %39, 1024
br i1 %40, label %41, label %45
41: ; preds = %32
%42 = load i8*, i8** %5
%43 = load i8*, i8** %3
%44 = call i32 @sprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @x_fib_recent_file.recent_file, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %42, i8* %43)
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @x_fib_recent_file.recent_file, i64 0, i64 0), i8** %2
br label %46
45: ; preds = %32, %28
store i8* null, i8** %2
br label %46
46: ; preds = %45, %41, %24
%47 = load i8*, i8** %2
ret i8* %47
}

LLVM IR (-O2):
@x_fib_recent_file.recent_file = internal global [1024 x i8] zeroinitializer
@.str = [14 x i8] c"XDG_DATA_HOME\00"
@.str.1 = [13 x i8] c"%s/%s/recent\00"
@.str.2 = [5 x i8] c"HOME\00"
@.str.3 = [26 x i8] c"%s/.local/share/%s/recent\00"
define i8* @x_fib_recent_file(i8* %0) {
%2 = tail call i32 @strchr(i8* %0, i8 signext 47)
%3 = icmp eq i32 %2, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i8* @getenv(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %1
%9 = tail call i32 @strlen(i8* %6)
%10 = tail call i32 @strlen(i8* %0)
%11 = add i32 %9, 10
%12 = add i32 %11, %10
%13 = icmp ult i32 %12, 1024
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @x_fib_recent_file.recent_file, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %0)
br label %27
16: ; preds = %8, %1
%17 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i8* %17, null
br i1 %18, label %27, label %19
19: ; preds = %16
%20 = tail call i32 @strlen(i8* %17)
%21 = tail call i32 @strlen(i8* %0)
%22 = add i32 %20, 22
%23 = add i32 %22, %21
%24 = icmp ult i32 %23, 1024
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([1024 x i8], [1024 x i8]* @x_fib_recent_file.recent_file, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %17, i8* %0)
br label %27
27: ; preds = %25, %19, %16, %14
%28 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @x_fib_recent_file.recent_file, i64 0, i64 0), %14 ], [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @x_fib_recent_file.recent_file, i64 0, i64 0), %25 ], [ null, %19 ], [ null, %16 ]
ret i8* %28
}