#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 *brain_alloc_(size_t, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char const *);
size_t strlen(char const *);
char const *make_name(char const *in_path, char const *in_name) {
  static char *result = NULL;
  if (result)
    free(result);
  size_t path_len = strlen(in_path);
  result = brain_alloc_(path_len + 1 + strlen(in_name) + 1, 0);
  if (!result)
    return NULL;
  if ((path_len == 0) || (in_path[path_len - 1] == '/'))
    sprintf(result, "%s%s", in_path, in_name);
  else
    sprintf(result, "%s/%s", in_path, in_name);
  return result;
}


x86 assembly (clang, -O0):
<make_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,0x2ef0(%rip)
je     116a <make_name+0x2a>
mov    0x2ee3(%rip),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
xor    %esi,%esi
call   1050 <brain_alloc_@plt>
mov    %rax,0x2ea3(%rip)
cmpq   $0x0,0x2e9b(%rip)
jne    11c0 <make_name+0x80>
movq   $0x0,-0x8(%rbp)
jmp    122a <make_name+0xea>
cmpq   $0x0,-0x20(%rbp)
je     11e4 <make_name+0xa4>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1204 <make_name+0xc4>
mov    0x2e5d(%rip),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe06(%rip),%rsi
call   1060 <sprintf@plt>
jmp    121f <make_name+0xdf>
mov    0x2e3d(%rip),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xdeb(%rip),%rsi
call   1060 <sprintf@plt>
mov    0x2e22(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2ef3(%rip),%rdi
test   %rdi,%rdi
je     115f <make_name+0x1f>
call   1030 <free@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%r12,%rax,1),%rdi
add    $0x2,%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1050 <brain_alloc_@plt>
mov    %rax,0x2ebe(%rip)
test   %rax,%rax
je     11c1 <make_name+0x81>
test   %r12,%r12
je     119c <make_name+0x5c>
cmpb   $0x2f,-0x1(%r12,%r15,1)
jne    11a5 <make_name+0x65>
lea    0xe5d(%rip),%rsi
jmp    11ac <make_name+0x6c>
lea    0xe59(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1060 <sprintf@plt>
mov    0x2e87(%rip),%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@make_name.result = internal global i8* null
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i8* @make_name(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** @make_name.result
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** @make_name.result
%11 = call i32 @free(i8* %10)
br label %12
12: ; preds = %9, %2
%13 = load i8*, i8** %4
%14 = call i64 @strlen(i8* %13)
store i64 %14, i64* %6
%15 = load i64, i64* %6
%16 = add i64 %15, 1
%17 = load i8*, i8** %5
%18 = call i64 @strlen(i8* %17)
%19 = add i64 %16, %18
%20 = add i64 %19, 1
%21 = call i8* @brain_alloc_(i64 %20, i32 0)
store i8* %21, i8** @make_name.result
%22 = load i8*, i8** @make_name.result
%23 = icmp ne i8* %22, null
br i1 %23, label %25, label %24
24: ; preds = %12
store i8* null, i8** %3
br label %48
25: ; preds = %12
%26 = load i64, i64* %6
%27 = icmp eq i64 %26, 0
br i1 %27, label %36, label %28
28: ; preds = %25
%29 = load i8*, i8** %4
%30 = load i64, i64* %6
%31 = sub i64 %30, 1
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 47
br i1 %35, label %36, label %41
36: ; preds = %28, %25
%37 = load i8*, i8** @make_name.result
%38 = load i8*, i8** %4
%39 = load i8*, i8** %5
%40 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %38, i8* %39)
br label %46
41: ; preds = %28
%42 = load i8*, i8** @make_name.result
%43 = load i8*, i8** %4
%44 = load i8*, i8** %5
%45 = call i32 @sprintf(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %43, i8* %44)
br label %46
46: ; preds = %41, %36
%47 = load i8*, i8** @make_name.result
store i8* %47, i8** %3
br label %48
48: ; preds = %46, %24
%49 = load i8*, i8** %3
ret i8* %49
}

LLVM IR (-O2):
@make_name.result = internal unnamed_addr global i8* null
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define i8* @make_name(i8* %0, i8* %1) {
%3 = load i8*, i8** @make_name.result
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @free(i8* %3)
br label %7
7: ; preds = %5, %2
%8 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%9 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%10 = add i64 %8, 2
%11 = add i64 %10, %9
%12 = tail call i8* @brain_alloc_(i64 %11, i32 0)
store i8* %12, i8** @make_name.result
%13 = icmp eq i8* %12, null
br i1 %13, label %27, label %14
14: ; preds = %7
%15 = icmp eq i64 %8, 0
br i1 %15, label %21, label %16
16: ; preds = %14
%17 = add i64 %8, -1
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 47
br i1 %20, label %21, label %23
21: ; preds = %16, %14
%22 = tail call i32 @sprintf(i8* dereferenceable(1) %12, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
br label %25
23: ; preds = %16
%24 = tail call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
br label %25
25: ; preds = %23, %21
%26 = load i8*, i8** @make_name.result
br label %27
27: ; preds = %7, %25
%28 = phi i8* [ %26, %25 ], [ null, %7 ]
ret i8* %28
}