#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*/ my_strncat(char *, char *, int /*<<< orphan*/);
int my_strncmp(char *, char *, int);
int /*<<< orphan*/ my_strncpy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int main() {
  char s[] = "____ is a test";
  char t[] = "Thisss";
  puts(my_strncpy(s, t, strlen(t)));
  char u[50] = "This is a what? ";
  char v[] = "A test.";
  puts(my_strncat(u, v, strlen(v)));
  char a[] = "this";
  char b[] = "bcd";
  printf("%d\n", my_strncmp(a, b, 3));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe77(%rip),%rax
mov    %rax,-0x13(%rbp)
mov    0xe75(%rip),%eax
mov    %eax,-0xb(%rbp)
mov    0xe6f(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xe67(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xe5f(%rip),%eax
mov    %eax,-0x1a(%rbp)
mov    0xe59(%rip),%ax
mov    %ax,-0x16(%rbp)
mov    0xe51(%rip),%al
mov    %al,-0x14(%rbp)
lea    -0x13(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x1a(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0x1a(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    %eax,%edx
call   1070 <my_strncpy@plt>
mov    %eax,%edi
call   1030 <puts@plt>
lea    -0x50(%rbp),%rdi
lea    0xe29(%rip),%rsi
mov    $0x32,%edx
call   1080 <memcpy@plt>
mov    0xdfe(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    -0x58(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x58(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    %eax,%edx
call   1090 <my_strncat@plt>
mov    %eax,%edi
call   1030 <puts@plt>
mov    0xdcd(%rip),%eax
mov    %eax,-0x5d(%rbp)
mov    0xdc8(%rip),%al
mov    %al,-0x59(%rbp)
mov    0xdc0(%rip),%eax
mov    %eax,-0x61(%rbp)
lea    -0x5d(%rbp),%rdi
lea    -0x61(%rbp),%rsi
mov    $0x3,%edx
call   1040 <my_strncmp@plt>
mov    %eax,%esi
lea    0xda6(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
movabs $0x74736574206120,%rax
mov    %rax,0x27(%rsp)
movabs $0x207369205f5f5f5f,%rax
69 73 20
mov    %rax,0x20(%rsp)
movl   $0x737373,0x13(%rsp)
movl   $0x73696854,0x10(%rsp)
73
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <my_strncpy@plt>
mov    %eax,%edi
call   1030 <puts@plt>
movaps 0xe83(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe67(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe4b(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movw   $0x0,0x60(%rsp)
movabs $0x2e747365742041,%rax
mov    %rax,0x18(%rsp)
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0x30(%rsp),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1080 <my_strncat@plt>
mov    %eax,%edi
call   1030 <puts@plt>
movb   $0x0,0x8(%rsp)
movl   $0x73696874,0x4(%rsp)
73
movl   $0x646362,0xc(%rsp)
lea    0x4(%rsp),%rdi
lea    0xc(%rsp),%rsi
mov    $0x3,%edx
call   1040 <my_strncmp@plt>
lea    0xdd8(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.s = [15 x i8] c"____ is a test\00"
@__const.main.t = [7 x i8] c"Thisss\00"
@__const.main.u = [50 x i8] c"This is a what? \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.v = [8 x i8] c"A test.\00"
@__const.main.a = [5 x i8] c"this\00"
@__const.main.b = [4 x i8] c"bcd\00"
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca [7 x i8]
%4 = alloca [50 x i8]
%5 = alloca [8 x i8]
%6 = alloca [5 x i8]
%7 = alloca [4 x i8]
store i32 0, i32* %1
%8 = bitcast [15 x i8]* %2 to i8*
%9 = bitcast [7 x i8]* %3 to i8*
%10 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @my_strncpy(i8* %10, i8* %11, i32 %13)
%15 = call i32 @puts(i32 %14)
%16 = bitcast [50 x i8]* %4 to i8*
%17 = bitcast [8 x i8]* %5 to i8*
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @my_strncat(i8* %18, i8* %19, i32 %21)
%23 = call i32 @puts(i32 %22)
%24 = bitcast [5 x i8]* %6 to i8*
%25 = bitcast [4 x i8]* %7 to i8*
%26 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%28 = call i32 @my_strncmp(i8* %26, i8* %27, i32 3)
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [15 x i8] c"____ is a test\00"
@__const.main.t = [7 x i8] c"Thisss\00"
@__const.main.u = [50 x i8] c"This is a what? \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.a = [5 x i8] c"this\00"
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = alloca [7 x i8]
%3 = alloca [50 x i8]
%4 = alloca i64
%5 = alloca [5 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
%10 = call i32 @my_strncpy(i8* %7, i8* %8, i32 %9)
%11 = call i32 @puts(i32 %10)
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%13 = bitcast i64* %4 to i8*
store i64 13075887900860481, i64* %4
%14 = call i32 @strlen(i8* %13)
%15 = call i32 @my_strncat(i8* %12, i8* %13, i32 %14)
%16 = call i32 @puts(i32 %15)
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%18 = bitcast i32* %6 to i8*
store i32 6579042, i32* %6
%19 = call i32 @my_strncmp(i8* %17, i8* %18, i32 3)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}