#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 /*<<< orphan*/ strncpy(char *, char *, int);
int auth_parsetoken(char **line, char *buf, int len) {
  char *colon;
  colon = strchr(*line, ':');
  if (colon == NULL)
    return (1);
  *colon = 0;
  buf[len - 1] = 0;
  strncpy(buf, *line, len - 1);
  *line = colon + 1;
  return (0);
}


x86 assembly (clang, -O0):
<auth_parsetoken>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    115f <auth_parsetoken+0x3f>
movl   $0x1,-0x4(%rbp)
jmp    11a3 <auth_parsetoken+0x83>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<auth_parsetoken>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     116a <auth_parsetoken+0x4a>
mov    %rax,%rbx
movb   $0x0,(%rax)
movslq %ebp,%rdx
movb   $0x0,-0x1(%r14,%rdx,1)
add    $0xffffffffffffffff,%rdx
mov    (%r15),%rsi
mov    %r14,%rdi
call   1030 <strncpy@plt>
add    $0x1,%rbx
mov    %rbx,(%r15)
xor    %eax,%eax
jmp    116f <auth_parsetoken+0x4f>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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