#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 *malloc(int);
int /*<<< orphan*/ sm_add_part(char *, char const *, int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
char *mycombinepath(const char *drawer, const char *file) {
  int len;
  char *dest;
  len = strlen(drawer) + strlen(file) + 4;
  if ((dest = malloc(len))) {
    strcpy(dest, drawer);
    sm_add_part(dest, file, len);
  }
  return dest;
}


x86 assembly (clang, -O0):
<mycombinepath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
add    $0x4,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11a5 <mycombinepath+0x65>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <sm_add_part@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mycombinepath>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%ebp
add    $0x4,%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1189 <mycombinepath+0x49>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <sm_add_part@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @mycombinepath(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 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %8, %10
%12 = add nsw i32 %11, 4
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = call i8* @malloc(i32 %13)
store i8* %14, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %24
16: ; preds = %2
%17 = load i8*, i8** %6
%18 = load i8*, i8** %3
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = load i8*, i8** %6
%21 = load i8*, i8** %4
%22 = load i32, i32* %5
%23 = call i32 @sm_add_part(i8* %20, i8* %21, i32 %22)
br label %24
24: ; preds = %16, %2
%25 = load i8*, i8** %6
ret i8* %25
}

LLVM IR (-O2):
define i8* @mycombinepath(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @strlen(i8* %1)
%5 = add i32 %3, 4
%6 = add i32 %5, %4
%7 = tail call i8* @malloc(i32 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = tail call i32 @strcpy(i8* %7, i8* %0)
%11 = tail call i32 @sm_add_part(i8* %7, i8* %1, i32 %6)
br label %12
12: ; preds = %9, %2
ret i8* %7
}