#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 */
int /*<<< orphan*/ is_end(char const);
int /*<<< orphan*/ is_sep(char const);
void cpy(const char *in, char *out) {
  while (!is_end(*in) && !is_sep(*in)) {
    *out = *in;
    ++in;
    ++out;
  }
  *out = '\0';
}


x86 assembly (clang, -O0):
<cpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <is_end@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
jne    1163 <cpy+0x43>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <is_sep@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1173 <cpy+0x53>
jmp    119c <cpy+0x7c>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <cpy+0x10>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpy>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl (%rdi),%edi
nopl   (%rax)
call   1040 <is_end@plt>
test   %eax,%eax
jne    1159 <cpy+0x39>
movsbl (%rbx),%edi
call   1030 <is_sep@plt>
test   %eax,%eax
jne    1159 <cpy+0x39>
movzbl (%rbx),%eax
mov    %al,(%r14)
add    $0x1,%r14
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
jmp    1130 <cpy+0x10>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @cpy(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = tail call i32 @is_end(i8 signext %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %2, %12
%7 = phi i8* [ %15, %12 ], [ %1, %2 ]
%8 = phi i8* [ %14, %12 ], [ %0, %2 ]
%9 = load i8, i8* %8
%10 = tail call i32 @is_sep(i8 signext %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %6
%13 = load i8, i8* %8
store i8 %13, i8* %7
%14 = getelementptr inbounds i8, i8* %8, i64 1
%15 = getelementptr inbounds i8, i8* %7, i64 1
%16 = load i8, i8* %14
%17 = tail call i32 @is_end(i8 signext %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %6, label %19
19: ; preds = %6, %12, %2
%20 = phi i8* [ %1, %2 ], [ %15, %12 ], [ %7, %6 ]
store i8 0, i8* %20
ret void
}