#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 */
scalar_t__ isspace(char);
char *strcpy(char *, char *);
char *fieldcpy(char *dst, char *fld) {
  while (*fld && *fld != ':')
    fld++;
  if (!*(fld++))
    return NULL;
  while (isspace(*fld))
    fld++;
  return strcpy(dst, fld);
}


x86 assembly (clang, -O0):
<fieldcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1155 <fieldcpy+0x35>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1165 <fieldcpy+0x45>
jmp    1176 <fieldcpy+0x56>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1130 <fieldcpy+0x10>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
cmpb   $0x0,(%rax)
jne    119b <fieldcpy+0x7b>
movq   $0x0,-0x8(%rbp)
jmp    11d8 <fieldcpy+0xb8>
jmp    11a0 <fieldcpy+0x80>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11c7 <fieldcpy+0xa7>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11a0 <fieldcpy+0x80>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fieldcpy>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
test   %al,%al
je     116f <fieldcpy+0x4f>
cmp    $0x3a,%al
je     1150 <fieldcpy+0x30>
add    $0x1,%rbx
jmp    1130 <fieldcpy+0x10>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
jne    1150 <fieldcpy+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
jmp    1172 <fieldcpy+0x52>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @fieldcpy(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
br label %6
6: ; preds = %18, %2
%7 = load i8*, i8** %5
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = load i8*, i8** %5
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 58
br label %16
16: ; preds = %11, %6
%17 = phi i1 [ false, %6 ], [ %15, %11 ]
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %5
br label %6
21: ; preds = %16
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
%24 = load i8, i8* %22
%25 = icmp ne i8 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21
store i8* null, i8** %3
br label %40
27: ; preds = %21
br label %28
28: ; preds = %33, %27
%29 = load i8*, i8** %5
%30 = load i8, i8* %29
%31 = call i64 @isspace(i8 signext %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
br label %28
36: ; preds = %28
%37 = load i8*, i8** %4
%38 = load i8*, i8** %5
%39 = call i8* @strcpy(i8* %37, i8* %38)
store i8* %39, i8** %3
br label %40
40: ; preds = %36, %26
%41 = load i8*, i8** %3
ret i8* %41
}

LLVM IR (-O2):
define i8* @fieldcpy(i8* %0, i8* nocapture %1) {
br label %3
3: ; preds = %6, %2
%4 = phi i8* [ %1, %2 ], [ %7, %6 ]
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 0, label %16
i8 58, label %8
]
6: ; preds = %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
8: ; preds = %3, %8
%9 = phi i8* [ %10, %8 ], [ %4, %3 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = tail call i64 @isspace(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %8
14: ; preds = %8
%15 = tail call i8* @strcpy(i8* dereferenceable(1) %0, i8* %10)
br label %16
16: ; preds = %3, %14
%17 = phi i8* [ %0, %14 ], [ null, %3 ]
ret i8* %17
}