int main(int argc, const char *argv[]) {
  const char *src = "Hello world!";
  const char *src2 = "Hello World!";
  char des[30];
  printf("[strncpy] %s\n", myStrncpy(des, src, 2));
  printf("[strcpy] %s\n", myStrcpy(des, src));
  printf("[strlen] %d\n", myStrlen(src));
  printf("[strcmp] %d\n", myStrcmp(src, src2));
  printf("[strcat] %s\n", myStrcat(des, src2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe85(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x2,%edx
mov    $0x0,%al
call   1070 <myStrncpy@plt>
mov    %eax,%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1060 <myStrcpy@plt>
mov    %eax,%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1080 <myStrlen@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1030 <myStrcmp@plt>
mov    %eax,%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1050 <myStrcat@plt>
mov    %eax,%esi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xe90(%rip),%r15
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
xor    %eax,%eax
call   1070 <myStrncpy@plt>
lea    0xe8e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <myStrcpy@plt>
lea    0xe7f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <myStrlen@plt>
lea    0xe72(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3a(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <myStrcmp@plt>
lea    0xe5b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <myStrcat@plt>
lea    0xe4b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Hello world!\00"
@.str.1 = [13 x i8] c"Hello World!\00"
@.str.2 = [14 x i8] c"[strncpy] %s\0A\00"
@.str.3 = [13 x i8] c"[strcpy] %s\0A\00"
@.str.4 = [13 x i8] c"[strlen] %d\0A\00"
@.str.5 = [13 x i8] c"[strcmp] %d\0A\00"
@.str.6 = [13 x i8] c"[strcat] %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [30 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %7
%9 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%10 = load i8*, i8** %6
%11 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @myStrncpy to i32 (i8*, i8*, i32, ...)*)(i8* %9, i8* %10, i32 2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%14 = load i8*, i8** %6
%15 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @myStrcpy to i32 (i8*, i8*, ...)*)(i8* %13, i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = load i8*, i8** %6
%18 = call i32 (i8*, ...) bitcast (i32 (...)* @myStrlen to i32 (i8*, ...)*)(i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %18)
%20 = load i8*, i8** %6
%21 = load i8*, i8** %7
%22 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @myStrcmp to i32 (i8*, i8*, ...)*)(i8* %20, i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%25 = load i8*, i8** %7
%26 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @myStrcat to i32 (i8*, i8*, ...)*)(i8* %24, i8* %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Hello world!\00"
@.str.1 = [13 x i8] c"Hello World!\00"
@.str.2 = [14 x i8] c"[strncpy] %s\0A\00"
@.str.3 = [13 x i8] c"[strcpy] %s\0A\00"
@.str.4 = [13 x i8] c"[strlen] %d\0A\00"
@.str.5 = [13 x i8] c"[strcmp] %d\0A\00"
@.str.6 = [13 x i8] c"[strcat] %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [30 x i8]
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%5 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @myStrncpy to i32 (i8*, i8*, i32, ...)*)(i8* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 2)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @myStrcpy to i32 (i8*, i8*, ...)*)(i8* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @myStrlen to i32 (i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @myStrcmp to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @myStrcat to i32 (i8*, i8*, ...)*)(i8* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %13)
ret i32 0
}