#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 */
scalar_t__ assert(int, char *);
int /*<<< orphan*/ copy(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int test() {
  char output_array[80 + 1] = "";
  char testline1[] = "A";
  char testline2[] = "";
  char testline3[] = "Typical line to be copied.";
  char testline4[] = "\n\n\n";
  int passcount = 0;
  int failcount = 0;
  int result;
  printf("\nExecuting unit tests\n");
  copy(output_array, testline1);
  if (assert(!strcmp(output_array, testline1),
             "Unit test for one character string"))
    passcount++;
  else
    failcount++;
  copy(output_array, testline2);
  if (assert(!strcmp(output_array, testline2),
             "Unit test for copying empty string"))
    passcount++;
  else
    failcount++;
  copy(output_array, testline3);
  if (assert(!strcmp(output_array, testline3), "Unit test for typical string"))
    passcount++;
  else
    failcount++;
  copy(output_array, testline4);
  if (assert(!strcmp(output_array, testline4),
             "Unit test for string with only newlines"))
    passcount++;
  else
    failcount++;
  printf("\nSummary of unit tests:\n%d tests passed\n%d tests failed\n\n",
         passcount, failcount);
  return failcount;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x51,%edx
call   1040 <memset@plt>
mov    0xe8e(%rip),%ax
mov    %ax,-0x62(%rbp)
lea    -0x63(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <memset@plt>
mov    0xf63(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xf60(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xf5d(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xf5a(%rip),%ax
mov    %ax,-0x68(%rbp)
mov    0xf52(%rip),%al
mov    %al,-0x66(%rbp)
mov    0xe41(%rip),%eax
mov    %eax,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
movl   $0x0,-0x8c(%rbp)
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0x62(%rbp),%rsi
call   1050 <copy@plt>
lea    -0x60(%rbp),%rdi
lea    -0x62(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
lea    0xe06(%rip),%rsi
call   1070 <assert@plt>
cmp    $0x0,%rax
je     123a <test+0xea>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1249 <test+0xf9>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x63(%rbp),%rsi
call   1050 <copy@plt>
lea    -0x60(%rbp),%rdi
lea    -0x63(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
lea    0xdc9(%rip),%rsi
call   1070 <assert@plt>
cmp    $0x0,%rax
je     129a <test+0x14a>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    12a9 <test+0x159>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1050 <copy@plt>
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
lea    0xd8c(%rip),%rsi
call   1070 <assert@plt>
cmp    $0x0,%rax
je     12fa <test+0x1aa>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1309 <test+0x1b9>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x84(%rbp),%rsi
call   1050 <copy@plt>
lea    -0x60(%rbp),%rdi
lea    -0x84(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
lea    0xd43(%rip),%rsi
call   1070 <assert@plt>
cmp    $0x0,%rax
je     1360 <test+0x210>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    136f <test+0x21f>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
mov    -0x88(%rbp),%esi
mov    -0x8c(%rbp),%edx
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8c(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movb   $0x0,0x80(%rsp)
movw   $0x41,0xa(%rsp)
movb   $0x0,0x9(%rsp)
movups 0xe75(%rip),%xmm0
movups %xmm0,0x1b(%rsp)
movaps 0xe5e(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0xa0a0a,0xc(%rsp)
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
lea    0x30(%rsp),%r14
lea    0xa(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <copy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xe31(%rip),%rsi
call   1070 <assert@plt>
xor    %r15d,%r15d
xor    %ebp,%ebp
test   %rax,%rax
setne  %r15b
sete   %bpl
lea    0x9(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <copy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xe15(%rip),%rsi
call   1070 <assert@plt>
mov    $0x2,%ebx
sub    %ebp,%ebx
lea    0x1(%rbp),%r12d
test   %rax,%rax
cmovne %ebp,%r12d
cmove  %r15d,%ebx
lea    0x10(%rsp),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <copy@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xdf3(%rip),%rsi
call   1070 <assert@plt>
xor    %r15d,%r15d
xor    %ebp,%ebp
test   %rax,%rax
setne  %r15b
sete   %bpl
add    %r12d,%ebp
add    %ebx,%r15d
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <copy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <strcmp@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xdcb(%rip),%rsi
call   1070 <assert@plt>
xor    %esi,%esi
xor    %ebx,%ebx
test   %rax,%rax
setne  %sil
sete   %bl
add    %ebp,%ebx
add    %r15d,%esi
lea    0xdd4(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.test.testline1 = [2 x i8] c"A\00"
@__const.test.testline3 = [27 x i8] c"Typical line to be copied.\00"
@__const.test.testline4 = [4 x i8] c"\0A\0A\0A\00"
@.str = [23 x i8] c"\0AExecuting unit tests\0A\00"
@.str.1 = [35 x i8] c"Unit test for one character string\00"
@.str.2 = [35 x i8] c"Unit test for copying empty string\00"
@.str.3 = [29 x i8] c"Unit test for typical string\00"
@.str.4 = [40 x i8] c"Unit test for string with only newlines\00"
@.str.5 = [58 x i8] c"\0ASummary of unit tests:\0A%d tests passed\0A%d tests failed\0A\0A\00"
define i32 @test() {
%1 = alloca [81 x i8]
%2 = alloca [2 x i8]
%3 = alloca [1 x i8]
%4 = alloca [27 x i8]
%5 = alloca [4 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast [81 x i8]* %1 to i8*
%10 = bitcast [2 x i8]* %2 to i8*
%11 = bitcast [1 x i8]* %3 to i8*
%12 = bitcast [27 x i8]* %4 to i8*
%13 = bitcast [4 x i8]* %5 to i8*
store i32 0, i32* %6
store i32 0, i32* %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%17 = call i32 @copy(i8* %15, i8* %16)
%18 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%20 = call i32 @strcmp(i8* %18, i8* %19)
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
%23 = zext i1 %22 to i32
%24 = call i64 @assert(i32 %23, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %0
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %32
29: ; preds = %0
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %32
32: ; preds = %29, %26
%33 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%34 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%35 = call i32 @copy(i8* %33, i8* %34)
%36 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%37 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%38 = call i32 @strcmp(i8* %36, i8* %37)
%39 = icmp ne i32 %38, 0
%40 = xor i1 %39, true
%41 = zext i1 %40 to i32
%42 = call i64 @assert(i32 %41, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %32
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %50
47: ; preds = %32
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %50
50: ; preds = %47, %44
%51 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%52 = getelementptr inbounds [27 x i8], [27 x i8]* %4, i64 0, i64 0
%53 = call i32 @copy(i8* %51, i8* %52)
%54 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%55 = getelementptr inbounds [27 x i8], [27 x i8]* %4, i64 0, i64 0
%56 = call i32 @strcmp(i8* %54, i8* %55)
%57 = icmp ne i32 %56, 0
%58 = xor i1 %57, true
%59 = zext i1 %58 to i32
%60 = call i64 @assert(i32 %59, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %50
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %68
65: ; preds = %50
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %68
68: ; preds = %65, %62
%69 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%70 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%71 = call i32 @copy(i8* %69, i8* %70)
%72 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%73 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%74 = call i32 @strcmp(i8* %72, i8* %73)
%75 = icmp ne i32 %74, 0
%76 = xor i1 %75, true
%77 = zext i1 %76 to i32
%78 = call i64 @assert(i32 %77, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %68
%81 = load i32, i32* %6
%82 = add nsw i32 %81, 1
store i32 %82, i32* %6
br label %86
83: ; preds = %68
%84 = load i32, i32* %7
%85 = add nsw i32 %84, 1
store i32 %85, i32* %7
br label %86
86: ; preds = %83, %80
%87 = load i32, i32* %6
%88 = load i32, i32* %7
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i32 %87, i32 %88)
%90 = load i32, i32* %7
ret i32 %90
}

LLVM IR (-O2):
@__const.test.testline3 = [27 x i8] c"Typical line to be copied.\00"
@.str.1 = [35 x i8] c"Unit test for one character string\00"
@.str.2 = [35 x i8] c"Unit test for copying empty string\00"
@.str.3 = [29 x i8] c"Unit test for typical string\00"
@.str.4 = [40 x i8] c"Unit test for string with only newlines\00"
@.str.5 = [58 x i8] c"\0ASummary of unit tests:\0A%d tests passed\0A%d tests failed\0A\0A\00"
@str = [22 x i8] c"\0AExecuting unit tests\00"
define i32 @test() {
%1 = alloca [81 x i8]
%2 = alloca i16
%3 = alloca [1 x i8]
%4 = alloca [27 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%7 = bitcast i16* %2 to i8*
store i16 65, i16* %2
%8 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
store i8 0, i8* %8
%9 = getelementptr inbounds [27 x i8], [27 x i8]* %4, i64 0, i64 0
%10 = bitcast i32* %5 to i8*
store i32 657930, i32* %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%12 = call i32 @copy(i8* %6, i8* %7)
%13 = call i32 @strcmp(i8* %6, i8* %7)
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = call i64 @assert(i32 %15, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = xor i1 %17, true
%20 = zext i1 %19 to i32
%21 = call i32 @copy(i8* %6, i8* %8)
%22 = call i32 @strcmp(i8* %6, i8* %8)
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = call i64 @assert(i32 %24, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
%27 = select i1 %17, i32 1, i32 2
%28 = select i1 %17, i32 2, i32 1
%29 = select i1 %26, i32 %28, i32 %18
%30 = select i1 %26, i32 %20, i32 %27
%31 = call i32 @copy(i8* %6, i8* %9)
%32 = call i32 @strcmp(i8* %6, i8* %9)
%33 = icmp eq i32 %32, 0
%34 = zext i1 %33 to i32
%35 = call i64 @assert(i32 %34, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
%37 = zext i1 %36 to i32
%38 = add nuw nsw i32 %29, %37
%39 = xor i1 %36, true
%40 = zext i1 %39 to i32
%41 = add nuw nsw i32 %30, %40
%42 = call i32 @copy(i8* %6, i8* %10)
%43 = call i32 @strcmp(i8* %6, i8* %10)
%44 = icmp eq i32 %43, 0
%45 = zext i1 %44 to i32
%46 = call i64 @assert(i32 %45, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
%48 = zext i1 %47 to i32
%49 = add nuw nsw i32 %38, %48
%50 = xor i1 %47, true
%51 = zext i1 %50 to i32
%52 = add nuw nsw i32 %41, %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i32 %52, i32 %49)
ret i32 %49
}