#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*/ memcpy(char *, unsigned char const *, int);
void name_copy(char *dst, const unsigned char *src, int len) {
  memcpy(dst, src, len);
  do {
    dst[len--] = 0;
  } while (len >= 0 && dst[len] == 32);
}


x86 assembly (clang, -O0):
<name_copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0xffffffff,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x15(%rbp)
jl     116d <name_copy+0x5d>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1133 <name_copy+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<name_copy>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
call   1030 <memcpy@plt>
movslq %ebp,%rax
movb   $0x0,(%rbx,%rax,1)
test   %rax,%rax
jle    1135 <name_copy+0x25>
add    $0xffffffffffffffff,%rax
mov    %eax,%ecx
cmpb   $0x20,(%rbx,%rcx,1)
je     1120 <name_copy+0x10>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @name_copy(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = load i32, i32* %6
%10 = call i32 @memcpy(i8* %7, i8* %8, i32 %9)
br label %11
11: ; preds = %28, %3
%12 = load i8*, i8** %4
%13 = load i32, i32* %6
%14 = add nsw i32 %13, -1
store i32 %14, i32* %6
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
store i8 0, i8* %16
br label %17
17: ; preds = %11
%18 = load i32, i32* %6
%19 = icmp sge i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 32
br label %28
28: ; preds = %20, %17
%29 = phi i1 [ false, %17 ], [ %27, %20 ]
br i1 %29, label %11, label %30
30: ; preds = %28
ret void
}

LLVM IR (-O2):
define void @name_copy(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @memcpy(i8* %0, i8* %1, i32 %2)
%5 = sext i32 %2 to i64
br label %6
6: ; preds = %11, %3
%7 = phi i64 [ %8, %11 ], [ %5, %3 ]
%8 = add nsw i64 %7, -1
%9 = getelementptr inbounds i8, i8* %0, i64 %7
store i8 0, i8* %9
%10 = icmp sgt i64 %7, 0
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = and i64 %8, 4294967295
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 32
br i1 %15, label %6, label %16
16: ; preds = %6, %11
ret void
}