#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 */
scalar_t__ malloc(unsigned int);
int /*<<< orphan*/ strcat(char *, char const *);
unsigned int strlen(char const *);
char *get_match_path(const char *dir_name, const char *key) {
  const char *seperator = "/";
  unsigned path_len = strlen(dir_name) + strlen(seperator) + strlen(key);
  char *path = (char *)malloc((path_len + 1) * sizeof(char));
  *path = '\0';
  strcat(path, dir_name);
  strcat(path, seperator);
  strcat(path, key);
  return path;
}


x86 assembly (clang, -O0):
<get_match_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb9(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,%eax
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_match_path>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%r12d
lea    0xeb3(%rip),%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %r12d,%ebp
lea    (%rax,%rbp,1),%edi
add    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,%rbp
movb   $0x0,(%rax)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1050 <strcat@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i8* @get_match_path(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = add i32 %9, %11
%13 = load i8*, i8** %4
%14 = call i32 @strlen(i8* %13)
%15 = add i32 %12, %14
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = add i32 %16, 1
%18 = zext i32 %17 to i64
%19 = mul i64 %18, 1
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %7
%23 = load i8*, i8** %7
store i8 0, i8* %23
%24 = load i8*, i8** %7
%25 = load i8*, i8** %3
%26 = call i32 @strcat(i8* %24, i8* %25)
%27 = load i8*, i8** %7
%28 = load i8*, i8** %5
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = load i8*, i8** %7
%31 = load i8*, i8** %4
%32 = call i32 @strcat(i8* %30, i8* %31)
%33 = load i8*, i8** %7
ret i8* %33
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i8* @get_match_path(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* %1)
%6 = add i32 %3, 1
%7 = add i32 %6, %4
%8 = add i32 %7, %5
%9 = tail call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8*
store i8 0, i8* %10
%11 = tail call i32 @strcat(i8* %10, i8* %0)
%12 = tail call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @strcat(i8* %10, i8* %1)
ret i8* %10
}