#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 */
int /*<<< orphan*/ strbuf_add(struct strbuf *, char const *,
                              int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
void get_human_path_buf(struct strbuf *bf, const char *peg_path) {
  if (peg_path[0] == '.' && peg_path[1] == '/')
    strbuf_add(bf, peg_path + 2, strlen(peg_path));
  else
    strbuf_add(bf, peg_path, strlen(peg_path));
}


x86 assembly (clang, -O0):
<get_human_path_buf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1182 <get_human_path_buf+0x62>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2f,%eax
jne    1182 <get_human_path_buf+0x62>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1030 <strbuf_add@plt>
jmp    11aa <get_human_path_buf+0x8a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strbuf_add@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_human_path_buf>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
cmpb   $0x2e,(%rsi)
mov    %rsi,%rbx
jne    113c <get_human_path_buf+0x1c>
xor    %eax,%eax
cmpb   $0x2f,0x1(%rsi)
sete   %al
lea    (%rsi,%rax,2),%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strbuf_add@plt>

LLVM IR (-O0):
%struct.strbuf = type { i32 }
define void @get_human_path_buf(%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 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 46
br i1 %9, label %10, label %23
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 47
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = load %struct.strbuf*, %struct.strbuf** %3
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i64 2
%20 = load i8*, i8** %4
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @strbuf_add(%struct.strbuf* %17, i8* %19, i32 %21)
br label %29
23: ; preds = %10, %2
%24 = load %struct.strbuf*, %struct.strbuf** %3
%25 = load i8*, i8** %4
%26 = load i8*, i8** %4
%27 = call i32 @strlen(i8* %26)
%28 = call i32 @strbuf_add(%struct.strbuf* %24, i8* %25, i32 %27)
br label %29
29: ; preds = %23, %16
ret void
}

LLVM IR (-O2):
%struct.strbuf = type { i32 }
define void @get_human_path_buf(%struct.strbuf* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 46
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %1, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 47
%9 = select i1 %8, i64 2, i64 0
%10 = getelementptr i8, i8* %1, i64 %9
br label %11
11: ; preds = %5, %2
%12 = phi i8* [ %1, %2 ], [ %10, %5 ]
%13 = tail call i32 @strlen(i8* %1)
%14 = tail call i32 @strbuf_add(%struct.strbuf* %0, i8* %12, i32 %13)
ret void
}