#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*/ snprintf(char *, size_t, char const *, char const *,
                            char const *);
int strlen(char const *);
char *mutt_concat_path(char *d, const char *dir, const char *fname, size_t l) {
  const char *fmt = "%s/%s";
  if (!*fname || (*dir && dir[strlen(dir) - 1] == '/'))
    fmt = "%s%s";
  snprintf(d, l, fmt, dir, fname);
  return d;
}


x86 assembly (clang, -O0):
<mutt_concat_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xec1(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     118a <mutt_concat_path+0x6a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1195 <mutt_concat_path+0x75>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1195 <mutt_concat_path+0x75>
lea    0xe75(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mutt_concat_path>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
cmpb   $0x0,(%rdx)
je     1157 <mutt_concat_path+0x37>
lea    0xebf(%rip),%r13
cmpb   $0x0,(%rbx)
je     115e <mutt_concat_path+0x3e>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
jne    115e <mutt_concat_path+0x3e>
lea    0xea8(%rip),%r13
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
call   1040 <snprintf@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [5 x i8] c"%s%s\00"
define i8* @mutt_concat_path(i8* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = load i8*, i8** %7
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %13
%19 = load i8*, i8** %6
%20 = load i8*, i8** %6
%21 = call i32 @strlen(i8* %20)
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %19, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 47
br i1 %27, label %28, label %29
28: ; preds = %18, %4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %9
br label %29
29: ; preds = %28, %18, %13
%30 = load i8*, i8** %5
%31 = load i64, i64* %8
%32 = load i8*, i8** %9
%33 = load i8*, i8** %6
%34 = load i8*, i8** %7
%35 = call i32 @snprintf(i8* %30, i64 %31, i8* %32, i8* %33, i8* %34)
%36 = load i8*, i8** %5
ret i8* %36
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [5 x i8] c"%s%s\00"
define i8* @mutt_concat_path(i8* returned %0, i8* %1, i8* %2, i64 %3) {
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = load i8, i8* %1
%9 = icmp eq i8 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %7
%11 = tail call i32 @strlen(i8* %1)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 47
br i1 %16, label %17, label %18
17: ; preds = %10, %4
br label %18
18: ; preds = %17, %10, %7
%19 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %17 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %10 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %7 ]
%20 = tail call i32 @snprintf(i8* %0, i64 %3, i8* %19, i8* %1, i8* %2)
ret i8* %0
}