#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_str_eq(char *, char *);
char *hz_assert_strncpy_ok(char *, char *, int);
void test_utils_strncpy_concat(void) {
  char buf[10] = "ABCDEFGHI";
  char *next = hz_assert_strncpy_ok(buf, "Megane", 10);
  hz_assert_strncpy_ok(next, "Poi", 10 - (next - buf));
  hz_assert_str_eq(buf, "MeganePoi");
}


x86 assembly (clang, -O0):
<test_utils_strncpy_concat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xa(%rbp)
mov    0xece(%rip),%ax
mov    %ax,-0x2(%rbp)
lea    -0xa(%rbp),%rdi
lea    0xec1(%rip),%rsi
mov    $0xa,%edx
call   1040 <hz_assert_strncpy_ok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rcx
lea    -0xa(%rbp),%rax
sub    %rax,%rcx
mov    $0xa,%eax
sub    %rcx,%rax
mov    %eax,%edx
lea    0xea0(%rip),%rsi
call   1040 <hz_assert_strncpy_ok@plt>
lea    -0xa(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1030 <hz_assert_str_eq@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_utils_strncpy_concat>:
push   %rbx
sub    $0x10,%rsp
movabs $0x4847464544434241,%rax
46 47 48
mov    %rax,(%rsp)
movw   $0x49,0x8(%rsp)
lea    0xec9(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%edx
call   1040 <hz_assert_strncpy_ok@plt>
mov    %ebx,%edx
sub    %eax,%edx
add    $0xa,%edx
lea    0xeb8(%rip),%rsi
mov    %rax,%rdi
call   1040 <hz_assert_strncpy_ok@plt>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <hz_assert_str_eq@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_utils_strncpy_concat.buf = [10 x i8] c"ABCDEFGHI\00"
@.str = [7 x i8] c"Megane\00"
@.str.1 = [4 x i8] c"Poi\00"
@.str.2 = [10 x i8] c"MeganePoi\00"
define void @test_utils_strncpy_concat() {
%1 = alloca [10 x i8]
%2 = alloca i8*
%3 = bitcast [10 x i8]* %1 to i8*
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = call i8* @hz_assert_strncpy_ok(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 10)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = load i8*, i8** %2
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%9 = ptrtoint i8* %7 to i64
%10 = ptrtoint i8* %8 to i64
%11 = sub i64 %9, %10
%12 = sub nsw i64 10, %11
%13 = trunc i64 %12 to i32
%14 = call i8* @hz_assert_strncpy_ok(i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%16 = call i32 @hz_assert_str_eq(i8* %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.test_utils_strncpy_concat.buf = [10 x i8] c"ABCDEFGHI\00"
@.str = [7 x i8] c"Megane\00"
@.str.1 = [4 x i8] c"Poi\00"
@.str.2 = [10 x i8] c"MeganePoi\00"
define void @test_utils_strncpy_concat() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i8* @hz_assert_strncpy_ok(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 10)
%4 = ptrtoint i8* %3 to i64
%5 = ptrtoint [10 x i8]* %1 to i64
%6 = sub i64 %5, %4
%7 = trunc i64 %6 to i32
%8 = add i32 %7, 10
%9 = call i8* @hz_assert_strncpy_ok(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = call i32 @hz_assert_str_eq(i8* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
ret void
}