#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*/ __is_delimiter(char);
int /*<<< orphan*/ normalize_path(char *);
int /*<<< orphan*/ strcat(char *, char const *);
int strlen(char *);
void add_path(char *path, const char *addition) {
  if (!__is_delimiter(path[strlen(path) - 1]))
    strcat(path, "/");
  strcat(path, addition);
  normalize_path(path);
}


x86 assembly (clang, -O0):
<add_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <__is_delimiter@plt>
cmp    $0x0,%eax
jne    118f <add_path+0x4f>
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x8(%rbp),%rdi
call   1030 <normalize_path@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_path>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <strlen@plt>
cltq
movsbl -0x1(%rax,%rbx,1),%edi
call   1040 <__is_delimiter@plt>
test   %eax,%eax
jne    116e <add_path+0x2e>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <normalize_path@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define void @add_path(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = sub nsw i32 %7, 1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %5, i64 %9
%11 = load i8, i8* %10
%12 = call i32 @__is_delimiter(i8 signext %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i8*, i8** %3
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %2
%18 = load i8*, i8** %3
%19 = load i8*, i8** %4
%20 = call i32 @strcat(i8* %18, i8* %19)
%21 = load i8*, i8** %3
%22 = call i32 @normalize_path(i8* %21)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define void @add_path(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = add nsw i32 %3, -1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = tail call i32 @__is_delimiter(i8 signext %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = tail call i32 @strcat(i8* %0, i8* %1)
%14 = tail call i32 @normalize_path(i8* %0)
ret void
}