#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*/ putchar(char);
int /*<<< orphan*/ strend_test(char *, char *);
int /*<<< orphan*/ strncat_test(char *, char *, int);
int /*<<< orphan*/ strncmp_test(char *, char *, int);
int /*<<< orphan*/ strncpy_test(char *, int);
int main(void) {
  strend_test("hello", "bye");
  strend_test("bye", "hello");
  strend_test("hello, world", "world");
  strend_test("hello, world", "hello");
  putchar('\n');
  strncpy_test("hello world", 100);
  strncpy_test("hello world", 12);
  strncpy_test("hello world", 11);
  strncpy_test("hello world", 5);
  putchar('\n');
  strncat_test("hello ", "world", 100);
  strncat_test("hello ", "world", 5);
  strncat_test("hello ", "world", 4);
  strncat_test("hello ", "world", 1);
  strncat_test("hello ", "world", 0);
  putchar('\n');
  strncmp_test("hello", "hello world", 10);
  strncmp_test("hello", "hello world", 6);
  strncmp_test("hello", "hello world", 5);
  strncmp_test("hello", "hello world", 4);
  strncmp_test("hello", "hello world", 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1050 <strend_test@plt>
lea    0xe8d(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1050 <strend_test@plt>
lea    0xe7e(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1050 <strend_test@plt>
lea    0xe6b(%rip),%rdi
lea    0xe5a(%rip),%rsi
call   1050 <strend_test@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe5b(%rip),%rdi
mov    $0x64,%esi
call   1040 <strncpy_test@plt>
lea    0xe4a(%rip),%rdi
mov    $0xc,%esi
call   1040 <strncpy_test@plt>
lea    0xe39(%rip),%rdi
mov    $0xb,%esi
call   1040 <strncpy_test@plt>
lea    0xe28(%rip),%rdi
mov    $0x5,%esi
call   1040 <strncpy_test@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe19(%rip),%rdi
lea    0xe00(%rip),%rsi
mov    $0x64,%edx
call   1070 <strncat_test@plt>
lea    0xe01(%rip),%rdi
lea    0xde8(%rip),%rsi
mov    $0x5,%edx
call   1070 <strncat_test@plt>
lea    0xde9(%rip),%rdi
lea    0xdd0(%rip),%rsi
mov    $0x4,%edx
call   1070 <strncat_test@plt>
lea    0xdd1(%rip),%rdi
lea    0xdb8(%rip),%rsi
mov    $0x1,%edx
call   1070 <strncat_test@plt>
lea    0xdb9(%rip),%rdi
lea    0xda0(%rip),%rsi
xor    %edx,%edx
call   1070 <strncat_test@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd77(%rip),%rdi
lea    0xd87(%rip),%rsi
mov    $0xa,%edx
call   1060 <strncmp_test@plt>
lea    0xd5f(%rip),%rdi
lea    0xd6f(%rip),%rsi
mov    $0x6,%edx
call   1060 <strncmp_test@plt>
lea    0xd47(%rip),%rdi
lea    0xd57(%rip),%rsi
mov    $0x5,%edx
call   1060 <strncmp_test@plt>
lea    0xd2f(%rip),%rdi
lea    0xd3f(%rip),%rsi
mov    $0x4,%edx
call   1060 <strncmp_test@plt>
lea    0xd17(%rip),%rdi
lea    0xd27(%rip),%rsi
xor    %edx,%edx
call   1060 <strncmp_test@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%r14
lea    0xea0(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strend_test@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strend_test@plt>
lea    0xe87(%rip),%rbx
lea    0xe87(%rip),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strend_test@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strend_test@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe66(%rip),%r12
mov    %r12,%rdi
mov    $0x64,%esi
call   1040 <strncpy_test@plt>
mov    %r12,%rdi
mov    $0xc,%esi
call   1040 <strncpy_test@plt>
mov    %r12,%rdi
mov    $0xb,%esi
call   1040 <strncpy_test@plt>
mov    %r12,%rdi
mov    $0x5,%esi
call   1040 <strncpy_test@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe2d(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x64,%edx
call   1070 <strncat_test@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x5,%edx
call   1070 <strncat_test@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1070 <strncat_test@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1070 <strncat_test@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1070 <strncat_test@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1060 <strncmp_test@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x6,%edx
call   1060 <strncmp_test@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x5,%edx
call   1060 <strncmp_test@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x4,%edx
call   1060 <strncmp_test@plt>
mov    %r14,%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   1060 <strncmp_test@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [4 x i8] c"bye\00"
@.str.2 = [13 x i8] c"hello, world\00"
@.str.3 = [6 x i8] c"world\00"
@.str.4 = [12 x i8] c"hello world\00"
@.str.5 = [7 x i8] c"hello \00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @strend_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 @strend_test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @strend_test(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 @strend_test(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @putchar(i8 signext 10)
%7 = call i32 @strncpy_test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 100)
%8 = call i32 @strncpy_test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 12)
%9 = call i32 @strncpy_test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 11)
%10 = call i32 @strncpy_test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 5)
%11 = call i32 @putchar(i8 signext 10)
%12 = call i32 @strncat_test(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 100)
%13 = call i32 @strncat_test(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%14 = call i32 @strncat_test(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 4)
%15 = call i32 @strncat_test(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 1)
%16 = call i32 @strncat_test(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 0)
%17 = call i32 @putchar(i8 signext 10)
%18 = call i32 @strncmp_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 10)
%19 = call i32 @strncmp_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 6)
%20 = call i32 @strncmp_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 5)
%21 = call i32 @strncmp_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 4)
%22 = call i32 @strncmp_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 0)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [4 x i8] c"bye\00"
@.str.2 = [13 x i8] c"hello, world\00"
@.str.3 = [6 x i8] c"world\00"
@.str.4 = [12 x i8] c"hello world\00"
@.str.5 = [7 x i8] c"hello \00"
define i32 @main() {
%1 = tail call i32 @strend_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @strend_test(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @strend_test(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%4 = tail call i32 @strend_test(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @putchar(i8 signext 10)
%6 = tail call i32 @strncpy_test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 100)
%7 = tail call i32 @strncpy_test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 12)
%8 = tail call i32 @strncpy_test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 11)
%9 = tail call i32 @strncpy_test(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 5)
%10 = tail call i32 @putchar(i8 signext 10)
%11 = tail call i32 @strncat_test(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 100)
%12 = tail call i32 @strncat_test(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 5)
%13 = tail call i32 @strncat_test(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 4)
%14 = tail call i32 @strncat_test(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 1)
%15 = tail call i32 @strncat_test(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 0)
%16 = tail call i32 @putchar(i8 signext 10)
%17 = tail call i32 @strncmp_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 10)
%18 = tail call i32 @strncmp_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 6)
%19 = tail call i32 @strncmp_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 5)
%20 = tail call i32 @strncmp_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 4)
%21 = tail call i32 @strncmp_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 0)
ret i32 0
}