#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 *strrchr(char *, char);
int split(char *name, char **user, char **host, char **file) {
  char *colon, *slash, *at;
  colon = strrchr(name, ':');
  slash = strrchr(name, '/');
  if (!colon || (slash && slash < colon))
    return 0;
  at = strrchr(name, '@');
  if (at && at > colon)
    at = NULL;
  *colon++ = '\0';
  *file = colon;
  if (at) {
    *at++ = '\0';
    *user = name;
    *host = at;
  } else
    *host = name;
  return 1;
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1170 <split+0x60>
cmpq   $0x0,-0x38(%rbp)
je     117c <split+0x6c>
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    117c <split+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    1216 <split+0x106>
mov    -0x10(%rbp),%rdi
mov    $0x40,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     11af <split+0x9f>
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
jbe    11af <split+0x9f>
movq   $0x0,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x0,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x40(%rbp)
je     1204 <split+0xf4>
mov    -0x40(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x40(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    120f <split+0xff>
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
mov    $0x3a,%esi
call   1030 <strrchr@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rbx,%rbx
je     118a <split+0x7a>
test   %rcx,%rcx
je     1153 <split+0x43>
cmp    %rbx,%rcx
jb     118a <split+0x7a>
mov    %r13,%rdi
mov    $0x40,%esi
call   1030 <strrchr@plt>
lea    0x1(%rbx),%rcx
movb   $0x0,(%rbx)
mov    %rcx,(%r12)
test   %rax,%rax
je     1182 <split+0x72>
cmp    %rbx,%rax
ja     1182 <split+0x72>
movb   $0x0,(%rax)
mov    %r13,(%r15)
mov    %rax,%r13
add    $0x1,%r13
mov    %r13,(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @split(i8* %0, i8** %1, i8** %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %6
store i8** %1, i8*** %7
store i8** %2, i8*** %8
store i8** %3, i8*** %9
%13 = load i8*, i8** %6
%14 = call i8* @strrchr(i8* %13, i8 signext 58)
store i8* %14, i8** %10
%15 = load i8*, i8** %6
%16 = call i8* @strrchr(i8* %15, i8 signext 47)
store i8* %16, i8** %11
%17 = load i8*, i8** %10
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %26
19: ; preds = %4
%20 = load i8*, i8** %11
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i8*, i8** %11
%24 = load i8*, i8** %10
%25 = icmp ult i8* %23, %24
br i1 %25, label %26, label %27
26: ; preds = %22, %4
store i32 0, i32* %5
br label %55
27: ; preds = %22, %19
%28 = load i8*, i8** %6
%29 = call i8* @strrchr(i8* %28, i8 signext 64)
store i8* %29, i8** %12
%30 = load i8*, i8** %12
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = load i8*, i8** %12
%34 = load i8*, i8** %10
%35 = icmp ugt i8* %33, %34
br i1 %35, label %36, label %37
36: ; preds = %32
store i8* null, i8** %12
br label %37
37: ; preds = %36, %32, %27
%38 = load i8*, i8** %10
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %10
store i8 0, i8* %38
%40 = load i8*, i8** %10
%41 = load i8**, i8*** %9
store i8* %40, i8** %41
%42 = load i8*, i8** %12
%43 = icmp ne i8* %42, null
br i1 %43, label %44, label %51
44: ; preds = %37
%45 = load i8*, i8** %12
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %12
store i8 0, i8* %45
%47 = load i8*, i8** %6
%48 = load i8**, i8*** %7
store i8* %47, i8** %48
%49 = load i8*, i8** %12
%50 = load i8**, i8*** %8
store i8* %49, i8** %50
br label %54
51: ; preds = %37
%52 = load i8*, i8** %6
%53 = load i8**, i8*** %8
store i8* %52, i8** %53
br label %54
54: ; preds = %51, %44
store i32 1, i32* %5
br label %55
55: ; preds = %54, %26
%56 = load i32, i32* %5
ret i32 %56
}

LLVM IR (-O2):
define i32 @split(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2, i8** nocapture writeonly %3) {
%5 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 58)
%6 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%7 = icmp eq i8* %5, null
br i1 %7, label %22, label %8
8: ; preds = %4
%9 = icmp ne i8* %6, null
%10 = icmp ult i8* %6, %5
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %22, label %12
12: ; preds = %8
%13 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 64)
%14 = icmp ugt i8* %13, %5
%15 = getelementptr inbounds i8, i8* %5, i64 1
store i8 0, i8* %5
store i8* %15, i8** %3
%16 = icmp eq i8* %13, null
%17 = select i1 %16, i1 true, i1 %14
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = getelementptr inbounds i8, i8* %13, i64 1
store i8 0, i8* %13
store i8* %0, i8** %1
br label %20
20: ; preds = %12, %18
%21 = phi i8* [ %19, %18 ], [ %0, %12 ]
store i8* %21, i8** %2
br label %22
22: ; preds = %4, %8, %20
%23 = phi i32 [ 1, %20 ], [ 0, %8 ], [ 0, %4 ]
ret i32 %23
}