#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 zstrlen(char *);
void zstrcpy(char *src, char *str) {
  int len = zstrlen(src);
  for (int i = 1; i <= zstrlen(str); i++) {
    src[len + i] = str[i];
  }
}


x86 assembly (clang, -O0):
<zstrcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <zstrlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <zstrlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jg     1178 <zstrcpy+0x68>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1133 <zstrcpy+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zstrcpy>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <zstrlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <zstrlen@plt>
test   %eax,%eax
jle    115c <zstrcpy+0x4c>
movslq %ebp,%rax
add    %rax,%r14
add    $0x1,%r14
xor    %ebp,%ebp
nopl   0x0(%rax)
movzbl 0x1(%rbx,%rbp,1),%eax
mov    %al,(%r14,%rbp,1)
mov    %rbx,%rdi
call   1030 <zstrlen@plt>
cltq
add    $0x1,%rbp
cmp    %rax,%rbp
jl     1140 <zstrcpy+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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