#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 *lib_strchr(char *, char);
void lib_chop_filename(char *str, char **host, char **file) {
  char *p;
  *host = str;
  p = lib_strchr(str, ':');
  if (!p)
    p = lib_strchr(str, '/');
  if (p) {
    *p++ = '\0';
    *file = p;
  } else {
    *file = 0;
  }
}


x86 assembly (clang, -O0):
<lib_chop_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <lib_strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    115e <lib_chop_filename+0x4e>
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <lib_strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     118b <lib_chop_filename+0x7b>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    1196 <lib_chop_filename+0x86>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lib_chop_filename>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
mov    %rdi,(%rsi)
mov    $0x3a,%esi
call   1030 <lib_strchr@plt>
test   %rax,%rax
jne    113e <lib_chop_filename+0x2e>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <lib_strchr@plt>
test   %rax,%rax
je     1150 <lib_chop_filename+0x40>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
jmp    1145 <lib_chop_filename+0x35>

LLVM IR (-O0):
define void @lib_chop_filename(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%8 = load i8*, i8** %4
%9 = load i8**, i8*** %5
store i8* %8, i8** %9
%10 = load i8*, i8** %4
%11 = call i8* @lib_strchr(i8* %10, i8 signext 58)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i8* @lib_strchr(i8* %15, i8 signext 47)
store i8* %16, i8** %7
br label %17
17: ; preds = %14, %3
%18 = load i8*, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %7
store i8 0, i8* %21
%23 = load i8*, i8** %7
%24 = load i8**, i8*** %6
store i8* %23, i8** %24
br label %27
25: ; preds = %17
%26 = load i8**, i8*** %6
store i8* null, i8** %26
br label %27
27: ; preds = %25, %20
ret void
}

LLVM IR (-O2):
define void @lib_chop_filename(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
store i8* %0, i8** %1
%4 = tail call i8* @lib_strchr(i8* %0, i8 signext 58)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i8* @lib_strchr(i8* %0, i8 signext 47)
%8 = icmp eq i8* %7, null
br i1 %8, label %12, label %9
9: ; preds = %3, %6
%10 = phi i8* [ %7, %6 ], [ %4, %3 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
store i8 0, i8* %10
br label %12
12: ; preds = %6, %9
%13 = phi i8* [ %11, %9 ], [ null, %6 ]
store i8* %13, i8** %2
ret void
}