#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*/ PrintError(unsigned long, char *);
void CopyValue(char *d, char *s, size_t size, int printerror) {
  while (size--) {
    if (*s)
      *d++ = *s;
    else if (printerror)
      PrintError((22UL | 0x10000000UL | 0x00020000UL), s);
    s++;
  }
  *d = 0;
}


x86 assembly (clang, -O0):
<CopyValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     1197 <CopyValue+0x87>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1169 <CopyValue+0x59>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1186 <CopyValue+0x76>
cmpl   $0x0,-0x1c(%rbp)
je     1181 <CopyValue+0x71>
mov    -0x10(%rbp),%rsi
mov    $0x10020016,%edi
call   1030 <PrintError@plt>
jmp    1186 <CopyValue+0x76>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1127 <CopyValue+0x17>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CopyValue>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
test   %rdx,%rdx
je     115f <CopyValue+0x4f>
mov    %ecx,%r14d
mov    %rdx,%rbp
mov    %rsi,%rbx
jmp    1140 <CopyValue+0x30>
nopw   0x0(%rax,%rax,1)
mov    %al,(%r15)
add    $0x1,%r15
add    $0x1,%rbx
test   %rbp,%rbp
je     115f <CopyValue+0x4f>
add    $0xffffffffffffffff,%rbp
movzbl (%rbx),%eax
test   %al,%al
jne    1130 <CopyValue+0x20>
test   %r14d,%r14d
je     1137 <CopyValue+0x27>
mov    $0x10020016,%edi
mov    %rbx,%rsi
call   1030 <PrintError@plt>
jmp    1137 <CopyValue+0x27>
movb   $0x0,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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