#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 */
struct strbuf {
  int dummy;
};

/* Variables and functions */
scalar_t__ is_absolute_path(char const *);
char const *make_nonrelative_path(char const *);
int /*<<< orphan*/ strbuf_addch(struct strbuf *, char);
int /*<<< orphan*/ strbuf_addstr(struct strbuf *, char const *);
void add_path(struct strbuf *out, const char *path) {
  if (path && *path) {
    if (is_absolute_path(path))
      strbuf_addstr(out, path);
    else
      strbuf_addstr(out, make_nonrelative_path(path));
    strbuf_addch(out, ':');
  }
}


x86 assembly (clang, -O0):
<add_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11bb <add_path+0x7b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11bb <add_path+0x7b>
mov    -0x10(%rbp),%rdi
call   1050 <is_absolute_path@plt>
cmp    $0x0,%rax
je     1190 <add_path+0x50>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strbuf_addstr@plt>
jmp    11ad <add_path+0x6d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <make_nonrelative_path@plt>
mov    -0x18(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strbuf_addstr@plt>
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1060 <strbuf_addch@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_path>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     1169 <add_path+0x29>
mov    %rsi,%rbx
cmpb   $0x0,(%rsi)
je     1169 <add_path+0x29>
mov    %rdi,%r14
mov    %rbx,%rdi
call   1050 <is_absolute_path@plt>
test   %rax,%rax
je     1171 <add_path+0x31>
mov    %r14,%rdi
mov    %rbx,%rsi
jmp    117f <add_path+0x3f>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %rbx,%rdi
call   1030 <make_nonrelative_path@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strbuf_addstr@plt>
mov    %r14,%rdi
mov    $0x3a,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <strbuf_addch@plt>

LLVM IR (-O0):
%struct.strbuf = type { i32 }
define void @add_path(%struct.strbuf* %0, i8* %1) {
%3 = alloca %struct.strbuf*
%4 = alloca i8*
store %struct.strbuf* %0, %struct.strbuf** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %28
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = call i64 @is_absolute_path(i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load %struct.strbuf*, %struct.strbuf** %3
%18 = load i8*, i8** %4
%19 = call i32 @strbuf_addstr(%struct.strbuf* %17, i8* %18)
br label %25
20: ; preds = %12
%21 = load %struct.strbuf*, %struct.strbuf** %3
%22 = load i8*, i8** %4
%23 = call i8* @make_nonrelative_path(i8* %22)
%24 = call i32 @strbuf_addstr(%struct.strbuf* %21, i8* %23)
br label %25
25: ; preds = %20, %16
%26 = load %struct.strbuf*, %struct.strbuf** %3
%27 = call i32 @strbuf_addch(%struct.strbuf* %26, i8 signext 58)
br label %28
28: ; preds = %25, %7, %2
ret void
}

LLVM IR (-O2):
%struct.strbuf = type { i32 }
define void @add_path(%struct.strbuf* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %17, label %4
4: ; preds = %2
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = tail call i64 @is_absolute_path(i8* %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @strbuf_addstr(%struct.strbuf* %0, i8* %1)
br label %15
12: ; preds = %7
%13 = tail call i8* @make_nonrelative_path(i8* %1)
%14 = tail call i32 @strbuf_addstr(%struct.strbuf* %0, i8* %13)
br label %15
15: ; preds = %12, %10
%16 = tail call i32 @strbuf_addch(%struct.strbuf* %0, i8 signext 58)
br label %17
17: ; preds = %15, %4, %2
ret void
}