#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 *strchr(char *, char);
int strlen(char *);
char *parse_line(char *s, char **p) {
  if (*s) {
    char *sep = strchr(s, ':');
    if (sep) {
      *sep++ = '\0';
      *p = sep;
    } else
      *p = s + strlen(s);
  } else
    *p = s;
  return s;
}


x86 assembly (clang, -O0):
<parse_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a2 <parse_line+0x82>
mov    -0x8(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117c <parse_line+0x5c>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    119d <parse_line+0x7d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rcx
cltq
add    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11ad <parse_line+0x8d>
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_line>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
mov    %rdi,%rcx
je     115e <parse_line+0x3e>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1150 <parse_line+0x30>
mov    %rax,%rcx
add    $0x1,%rcx
movb   $0x0,(%rax)
jmp    115e <parse_line+0x3e>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
add    %rbx,%rcx
mov    %rcx,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @parse_line(i8* returned %0, i8** nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2
%6 = tail call i8* @strchr(i8* %0, i8 signext 58)
%7 = icmp eq i8* %6, null
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = getelementptr inbounds i8, i8* %6, i64 1
store i8 0, i8* %6
br label %14
10: ; preds = %5
%11 = tail call i32 @strlen(i8* %0)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
br label %14
14: ; preds = %2, %8, %10
%15 = phi i8* [ %13, %10 ], [ %9, %8 ], [ %0, %2 ]
store i8* %15, i8** %1
ret i8* %0
}