#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*/ fail_test(int);
scalar_t__ str_cmp(char *, char *);
int str_cpy(char *, char *);
void test_cpy() {
  int i;
  char dest[16];
  for (i = 0; i < 16; ++i)
    dest[i] = '\0';
  if (str_cpy(dest, "hello") != 5)
    fail_test(32);
  ;
  if (str_cmp("hello", dest) != 0)
    fail_test(35);
  ;
  if (str_cpy(dest, "he") != 2)
    fail_test(38);
  ;
  if (str_cmp("he", dest) != 0)
    fail_test(41);
  ;
}


x86 assembly (clang, -O0):
<test_cpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    1160 <test_cpy+0x30>
movslq -0x4(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113f <test_cpy+0xf>
lea    -0x20(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1050 <str_cpy@plt>
cmp    $0x5,%eax
je     1183 <test_cpy+0x53>
mov    $0x20,%edi
call   1030 <fail_test@plt>
lea    -0x20(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1040 <str_cmp@plt>
cmp    $0x0,%rax
je     11a7 <test_cpy+0x77>
mov    $0x23,%edi
call   1030 <fail_test@plt>
lea    -0x20(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1050 <str_cpy@plt>
cmp    $0x2,%eax
je     11ca <test_cpy+0x9a>
mov    $0x26,%edi
call   1030 <fail_test@plt>
lea    -0x20(%rbp),%rsi
lea    0xe31(%rip),%rdi
call   1040 <str_cmp@plt>
cmp    $0x0,%rax
je     11ee <test_cpy+0xbe>
mov    $0x29,%edi
call   1030 <fail_test@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_cpy>:
sub    $0x18,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
lea    0xebe(%rip),%rsi
mov    %rsp,%rdi
call   1050 <str_cpy@plt>
cmp    $0x5,%eax
je     1159 <test_cpy+0x29>
mov    $0x20,%edi
call   1030 <fail_test@plt>
lea    0xea0(%rip),%rdi
mov    %rsp,%rsi
call   1040 <str_cmp@plt>
test   %rax,%rax
je     1177 <test_cpy+0x47>
mov    $0x23,%edi
call   1030 <fail_test@plt>
lea    0xe88(%rip),%rsi
mov    %rsp,%rdi
call   1050 <str_cpy@plt>
cmp    $0x2,%eax
je     1195 <test_cpy+0x65>
mov    $0x26,%edi
call   1030 <fail_test@plt>
lea    0xe6a(%rip),%rdi
mov    %rsp,%rsi
call   1040 <str_cmp@plt>
test   %rax,%rax
je     11b3 <test_cpy+0x83>
mov    $0x29,%edi
call   1030 <fail_test@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [3 x i8] c"he\00"
define void @test_cpy() {
%1 = alloca i32
%2 = alloca [16 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %10, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 16
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = load i32, i32* %1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %8
store i8 0, i8* %9
br label %10
10: ; preds = %6
%11 = load i32, i32* %1
%12 = add nsw i32 %11, 1
store i32 %12, i32* %1
br label %3
13: ; preds = %3
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%15 = call i32 @str_cpy(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 5
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @fail_test(i32 32)
br label %19
19: ; preds = %17, %13
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%21 = call i64 @str_cmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = call i32 @fail_test(i32 35)
br label %25
25: ; preds = %23, %19
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%27 = call i32 @str_cpy(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp ne i32 %27, 2
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @fail_test(i32 38)
br label %31
31: ; preds = %29, %25
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%33 = call i64 @str_cmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 @fail_test(i32 41)
br label %37
37: ; preds = %35, %31
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [3 x i8] c"he\00"
define void @test_cpy() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%4 = call i32 @str_cpy(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 5
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @fail_test(i32 32)
br label %8
8: ; preds = %6, %0
%9 = call i64 @str_cmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @fail_test(i32 35)
br label %13
13: ; preds = %11, %8
%14 = call i32 @str_cpy(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32 %14, 2
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 @fail_test(i32 38)
br label %18
18: ; preds = %16, %13
%19 = call i64 @str_cmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = call i32 @fail_test(i32 41)
br label %23
23: ; preds = %21, %18
ret void
}