#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*/ clearstr(unsigned char *);
void copy_str(unsigned char *s1, unsigned char *s2) {
  int i;
  clearstr(s2);
  for (i = 0; i < 256 && s1[i] != 0; i++)
    s2[i] = s1[i];
  return;
}


x86 assembly (clang, -O0):
<copy_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <clearstr@plt>
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x100,-0x14(%rbp)
mov    %al,-0x15(%rbp)
jge    1157 <copy_str+0x47>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1167 <copy_str+0x57>
jmp    118b <copy_str+0x7b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <copy_str+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_str>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <clearstr@plt>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx,%rax,1),%ecx
test   %cl,%cl
je     1172 <copy_str+0x62>
mov    %cl,(%r14,%rax,1)
movzbl 0x1(%rbx,%rax,1),%ecx
test   %cl,%cl
je     1172 <copy_str+0x62>
mov    %cl,0x1(%r14,%rax,1)
movzbl 0x2(%rbx,%rax,1),%ecx
test   %cl,%cl
je     1172 <copy_str+0x62>
mov    %cl,0x2(%r14,%rax,1)
movzbl 0x3(%rbx,%rax,1),%ecx
test   %cl,%cl
je     1172 <copy_str+0x62>
mov    %cl,0x3(%r14,%rax,1)
add    $0x4,%rax
cmp    $0x100,%rax
jne    1130 <copy_str+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @copy_str(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 = call i32 @clearstr(i8* %6)
store i32 0, i32* %5
br label %8
8: ; preds = %31, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 256
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = load i8*, i8** %3
%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 = zext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br label %19
19: ; preds = %11, %8
%20 = phi i1 [ false, %8 ], [ %18, %11 ]
br i1 %20, label %21, label %34
21: ; preds = %19
%22 = load i8*, i8** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = load i8*, i8** %4
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 %26, i8* %30
br label %31
31: ; preds = %21
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %8
34: ; preds = %19
ret void
}

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