#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(int);
int /*<<< orphan*/ specialcat(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char const *);
const char *construct_from_dir_and_name(const char *dir, const char *name) {
  int truelen = 0;
  char *final = 0;
  truelen = strlen(dir) + strlen(name) + 1 + 1;
  final = (char *)malloc(truelen);
  if (!final) {
    return NULL;
  }
  final[0] = 0;
  specialcat(final, (char *)dir, 1);
  strcat(final, "/");
  specialcat(final, (char *)name, 0);
  return final;
}


x86 assembly (clang, -O0):
<construct_from_dir_and_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a8 <construct_from_dir_and_name+0x68>
movq   $0x0,-0x8(%rbp)
jmp    11e8 <construct_from_dir_and_name+0xa8>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1050 <specialcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1050 <specialcat@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<construct_from_dir_and_name>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x2,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     119e <construct_from_dir_and_name+0x5e>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <specialcat@plt>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1050 <specialcat@plt>
jmp    11a0 <construct_from_dir_and_name+0x60>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i8* @construct_from_dir_and_name(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = add i32 %3, 2
%6 = add i32 %5, %4
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i64 %7, 0
br i1 %9, label %14, label %10
10: ; preds = %2
store i8 0, i8* %8
%11 = tail call i32 @specialcat(i8* %8, i8* %0, i32 1)
%12 = tail call i32 @strcat(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @specialcat(i8* %8, i8* %1, i32 0)
br label %14
14: ; preds = %2, %10
%15 = phi i8* [ %8, %10 ], [ null, %2 ]
ret i8* %15
}