#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 const *, char const *);
int strlen(char const *);
char *xmalloc(int);
char *full_path(const char *path, const char *lang) {
  int len = strlen(path) + strlen("/nine-") + strlen(lang) + strlen(".db");
  char *result = xmalloc(len + 1);
  sprintf("%s/nine-%s.db", path, lang);
  return result;
}


x86 assembly (clang, -O0):
<full_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
lea    0xead(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
lea    0xe95(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
call   1040 <xmalloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe5e(%rip),%rdi
call   1050 <sprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<full_path>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %eax,%r15d
lea    0xeb3(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
lea    0xeac(%rip),%rdi
call   1030 <strlen@plt>
add    %r15d,%ebp
add    %ebx,%ebp
lea    (%rax,%rbp,1),%edi
add    $0x1,%edi
call   1040 <xmalloc@plt>
mov    %rax,%rbx
lea    0xe83(%rip),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"/nine-\00"
@.str.1 = [4 x i8] c".db\00"
@.str.2 = [14 x i8] c"%s/nine-%s.db\00"
define i8* @full_path(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = add nsw i32 %8, %9
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %10, %12
%14 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = add nsw i32 %13, %14
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
%18 = call i8* @xmalloc(i32 %17)
store i8* %18, i8** %6
%19 = load i8*, i8** %3
%20 = load i8*, i8** %4
%21 = call i32 @sprintf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %19, i8* %20)
%22 = load i8*, i8** %6
ret i8* %22
}

LLVM IR (-O2):
@.str = [7 x i8] c"/nine-\00"
@.str.1 = [4 x i8] c".db\00"
@.str.2 = [14 x i8] c"%s/nine-%s.db\00"
define i8* @full_path(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strlen(i8* %1)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = add i32 %3, 1
%8 = add i32 %7, %4
%9 = add i32 %8, %5
%10 = add i32 %9, %6
%11 = tail call i8* @xmalloc(i32 %10)
%12 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(1) %0, i8* %1)
ret i8* %11
}