#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 */
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int strlen(char *);
char *strrchr(char *, char);
char *CONFIG_make_filename(const char *path, const char *filename) {
  static char result[256];
  char *cp;
  sprintf(result, "%s", path);
  cp = strrchr(result, '/');
  if (!cp) {
    cp = strrchr(result, '\\');
  }
  cp[1] = '\0';
  sprintf(result + strlen(result), "%s", filename);
  return result;
}


x86 assembly (clang, -O0):
<CONFIG_make_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdx
lea    0x2f05(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1050 <sprintf@plt>
lea    0x2ef2(%rip),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118c <CONFIG_make_filename+0x5c>
lea    0x2ed2(%rip),%rdi
mov    $0x5c,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,0x1(%rax)
lea    0x2eb5(%rip),%rdi
call   1030 <strlen@plt>
cltq
lea    0x2ea7(%rip),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rdx
lea    0xe49(%rip),%rsi
call   1050 <sprintf@plt>
lea    0x2e8d(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CONFIG_make_filename>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0x2f0f(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
jne    116c <CONFIG_make_filename+0x3c>
lea    0x2eee(%rip),%rdi
mov    $0x5c,%esi
call   1050 <strrchr@plt>
movb   $0x0,0x1(%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@CONFIG_make_filename.result = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"%s\00"
define i8* @CONFIG_make_filename(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i8* @strrchr(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0), i8 signext 47)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i8* @strrchr(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0), i8 signext 92)
store i8* %12, i8** %5
br label %13
13: ; preds = %11, %2
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8 0, i8* %15
%16 = call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0))
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0), i64 %17
%19 = load i8*, i8** %4
%20 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0)
}

LLVM IR (-O2):
@CONFIG_make_filename.result = internal global [256 x i8] zeroinitializer
define i8* @CONFIG_make_filename(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i8* @strcpy(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0), i8* dereferenceable(1) %0)
%4 = tail call i8* @strrchr(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0), i8 signext 47)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i8* @strrchr(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0), i8 signext 92)
br label %8
8: ; preds = %6, %2
%9 = phi i8* [ %4, %2 ], [ %7, %6 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
store i8 0, i8* %10
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0))
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 %12
%14 = tail call i8* @strcpy(i8* %13, i8* dereferenceable(1) %1)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @CONFIG_make_filename.result, i64 0, i64 0)
}