#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*/ hz_assert_char(char *, int, char);
int /*<<< orphan*/ hz_assert_strncpy_ok(char *, char *, int);
void test_utils_strncpy_basic(void) {
  char buf[100] = "Some very long string";
  hz_assert_strncpy_ok(buf, "Test", 100);
  hz_assert_char(buf, 0, 'T');
  hz_assert_char(buf, 3, 't');
  hz_assert_char(buf, 4, '\0');
  hz_assert_char(buf, 5, 'v');
  hz_assert_char(buf, 6, 'e');
}


x86 assembly (clang, -O0):
<test_utils_strncpy_basic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x70(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x64,%edx
call   1030 <memcpy@plt>
lea    -0x70(%rbp),%rdi
lea    0xf0c(%rip),%rsi
mov    $0x64,%edx
call   1050 <hz_assert_strncpy_ok@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x54,%edx
call   1040 <hz_assert_char@plt>
lea    -0x70(%rbp),%rdi
mov    $0x3,%esi
mov    $0x74,%edx
call   1040 <hz_assert_char@plt>
lea    -0x70(%rbp),%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1040 <hz_assert_char@plt>
lea    -0x70(%rbp),%rdi
mov    $0x5,%esi
mov    $0x76,%edx
call   1040 <hz_assert_char@plt>
lea    -0x70(%rbp),%rdi
mov    $0x6,%esi
mov    $0x65,%edx
call   1040 <hz_assert_char@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_utils_strncpy_basic>:
push   %rbx
sub    $0x70,%rsp
movaps 0xf24(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xf08(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeec(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xee9(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%edx
call   1040 <hz_assert_strncpy_ok@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x54,%edx
call   1030 <hz_assert_char@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x74,%edx
call   1030 <hz_assert_char@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %edx,%edx
call   1030 <hz_assert_char@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x76,%edx
call   1030 <hz_assert_char@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x65,%edx
call   1030 <hz_assert_char@plt>
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_utils_strncpy_basic.buf = [100 x i8] c"Some very long string\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\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\00\00\00\00\00\00\00\00\00\00\00"
@.str = [5 x i8] c"Test\00"
define void @test_utils_strncpy_basic() {
%1 = alloca [100 x i8]
%2 = bitcast [100 x i8]* %1 to i8*
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = call i32 @hz_assert_strncpy_ok(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 100)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = call i32 @hz_assert_char(i8* %5, i32 0, i8 signext 84)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%8 = call i32 @hz_assert_char(i8* %7, i32 3, i8 signext 116)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%10 = call i32 @hz_assert_char(i8* %9, i32 4, i8 signext 0)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%12 = call i32 @hz_assert_char(i8* %11, i32 5, i8 signext 118)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%14 = call i32 @hz_assert_char(i8* %13, i32 6, i8 signext 101)
ret void
}

LLVM IR (-O2):
@__const.test_utils_strncpy_basic.buf = [100 x i8] c"Some very long string\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\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\00\00\00\00\00\00\00\00\00\00\00"
@.str = [5 x i8] c"Test\00"
define void @test_utils_strncpy_basic() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @hz_assert_strncpy_ok(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 100)
%4 = call i32 @hz_assert_char(i8* %2, i32 0, i8 signext 84)
%5 = call i32 @hz_assert_char(i8* %2, i32 3, i8 signext 116)
%6 = call i32 @hz_assert_char(i8* %2, i32 4, i8 signext 0)
%7 = call i32 @hz_assert_char(i8* %2, i32 5, i8 signext 118)
%8 = call i32 @hz_assert_char(i8* %2, i32 6, i8 signext 101)
ret void
}