#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*/ printf(char *);
int /*<<< orphan*/ test_ncat(char *, char *);
int /*<<< orphan*/ test_ncmp(char *, char *);
int /*<<< orphan*/ test_ncpy(char *);
int main(void) {
  test_ncpy("");
  test_ncpy("a");
  test_ncpy("ab");
  test_ncpy("abcdefghijklmnopqrstuvwxyz");
  test_ncat("", "a");
  test_ncat("a", "bc");
  test_ncat("ab", "cde");
  test_ncat("ab", "cdefghijklmnopqrstuvwxyz");
  test_ncmp("", "");
  test_ncmp("", "a");
  test_ncmp("a", "a");
  test_ncmp("a", "ab");
  test_ncmp("abc", "ab");
  printf("All tests pass.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
call   1050 <test_ncpy@plt>
lea    0xe9e(%rip),%rdi
call   1050 <test_ncpy@plt>
lea    0xe94(%rip),%rdi
call   1050 <test_ncpy@plt>
lea    0xe8b(%rip),%rdi
call   1050 <test_ncpy@plt>
lea    0xeb2(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1040 <test_ncat@plt>
lea    0xe67(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1040 <test_ncat@plt>
lea    0xe56(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   1040 <test_ncat@plt>
lea    0xe43(%rip),%rdi
lea    0xe41(%rip),%rsi
call   1040 <test_ncat@plt>
lea    0xe66(%rip),%rsi
mov    %rsi,%rdi
call   1060 <test_ncmp@plt>
lea    0xe57(%rip),%rdi
lea    0xe18(%rip),%rsi
call   1060 <test_ncmp@plt>
lea    0xe0c(%rip),%rsi
mov    %rsi,%rdi
call   1060 <test_ncmp@plt>
lea    0xdfd(%rip),%rdi
lea    0xdf8(%rip),%rsi
call   1060 <test_ncmp@plt>
lea    0xe0e(%rip),%rdi
lea    0xde5(%rip),%rsi
call   1060 <test_ncmp@plt>
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xeeb(%rip),%r15
mov    %r15,%rdi
call   1050 <test_ncpy@plt>
lea    0xea5(%rip),%rbx
mov    %rbx,%rdi
call   1050 <test_ncpy@plt>
lea    0xe98(%rip),%r14
mov    %r14,%rdi
call   1050 <test_ncpy@plt>
lea    0xe8c(%rip),%rdi
call   1050 <test_ncpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <test_ncat@plt>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1040 <test_ncat@plt>
lea    0xe81(%rip),%rsi
mov    %r14,%rdi
call   1040 <test_ncat@plt>
lea    0xe59(%rip),%rsi
mov    %r14,%rdi
call   1040 <test_ncat@plt>
mov    %r15,%rdi
mov    %r15,%rsi
call   1060 <test_ncmp@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <test_ncmp@plt>
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1060 <test_ncmp@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <test_ncmp@plt>
lea    0xe3b(%rip),%rdi
mov    %r14,%rsi
call   1060 <test_ncmp@plt>
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [3 x i8] c"ab\00"
@.str.3 = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str.4 = [3 x i8] c"bc\00"
@.str.5 = [4 x i8] c"cde\00"
@.str.6 = [25 x i8] c"cdefghijklmnopqrstuvwxyz\00"
@.str.7 = [4 x i8] c"abc\00"
@.str.8 = [17 x i8] c"All tests pass.\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @test_ncpy(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @test_ncpy(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @test_ncpy(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @test_ncpy(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @test_ncat(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @test_ncat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @test_ncat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @test_ncat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @test_ncmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @test_ncmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @test_ncmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @test_ncmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @test_ncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [3 x i8] c"ab\00"
@.str.3 = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str.4 = [3 x i8] c"bc\00"
@.str.5 = [4 x i8] c"cde\00"
@.str.6 = [25 x i8] c"cdefghijklmnopqrstuvwxyz\00"
@.str.7 = [4 x i8] c"abc\00"
@str = [16 x i8] c"All tests pass.\00"
define i32 @main() {
%1 = tail call i32 @test_ncpy(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @test_ncpy(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @test_ncpy(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @test_ncpy(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 @test_ncat(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @test_ncat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @test_ncat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%8 = tail call i32 @test_ncat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%9 = tail call i32 @test_ncmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @test_ncmp(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @test_ncmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32 @test_ncmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @test_ncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
ret i32 0
}