#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*/ strcpy(char *, char const *);
void cp_pname_field(char *dest, const char *src) {
  ++src;
  strcpy(dest, src);
  int i = 0;
  while (src[i] != '\0') {
    dest[i] = src[i];
    ++i;
  }
  dest[i - 1] = '\0';
}


x86 assembly (clang, -O0):
<cp_pname_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1179 <cp_pname_field+0x69>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <cp_pname_field+0x30>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cp_pname_field>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x1,%rsi
call   1030 <strcpy@plt>
mov    0x1(%rbx),%cl
test   %cl,%cl
je     115a <cp_pname_field+0x4a>
movabs $0xffffffff00000000,%rax
ff ff ff
xor    %edx,%edx
movabs $0x100000000,%rsi
add    %rsi,%rax
mov    %cl,(%r14,%rdx,1)
movzbl 0x2(%rbx,%rdx,1),%ecx
add    $0x1,%rdx
test   %cl,%cl
jne    1140 <cp_pname_field+0x30>
sar    $0x20,%rax
jmp    1161 <cp_pname_field+0x51>
mov    $0xffffffffffffffff,%rax
movb   $0x0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @cp_pname_field(i8* %0, i8* %1) {
%3 = getelementptr inbounds i8, i8* %1, i64 1
%4 = tail call i32 @strcpy(i8* %0, i8* %3)
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %11, %7 ], [ 0, %2 ]
%9 = phi i8 [ %13, %7 ], [ %5, %2 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %8
store i8 %9, i8* %10
%11 = add nuw nsw i64 %8, 1
%12 = getelementptr inbounds i8, i8* %3, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = shl i64 %8, 32
%17 = ashr exact i64 %16, 32
br label %18
18: ; preds = %15, %2
%19 = phi i64 [ -1, %2 ], [ %17, %15 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 0, i8* %20
ret void
}