#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*/ memset(char *, int, int);
int /*<<< orphan*/ string_is(char const *, unsigned int, char *, char const *,
                             char const *);
int /*<<< orphan*/ strncpy(char *, char const *, size_t);
void test_str(const char *file, unsigned int line, const char *s, size_t n,
              const char *expected) {
  char buffer[16];
setup:
  memset(&buffer[0], 0x55, sizeof buffer);
exercise:
  (void)strncpy(&buffer[0], s, n);
verify:
  string_is(file, line, &buffer[0], expected, expected);
teardown:
  return;
}


x86 assembly (clang, -O0):
<test_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x55,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <strncpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x40(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <string_is@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%r12d
mov    %rdi,%rbp
mov    %rsp,%r13
mov    %r13,%rdi
mov    $0x55,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <strncpy@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbx,%r8
call   1030 <string_is@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @test_str(i8* %0, i32 %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca [16 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i8* %4, i8** %10
br label %12
12: ; preds = %5
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i32 85, i32 16)
br label %15
15: ; preds = %12
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%17 = load i8*, i8** %8
%18 = load i64, i64* %9
%19 = call i32 @strncpy(i8* %16, i8* %17, i64 %18)
br label %20
20: ; preds = %15
%21 = load i8*, i8** %6
%22 = load i32, i32* %7
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%24 = load i8*, i8** %10
%25 = load i8*, i8** %10
%26 = call i32 @string_is(i8* %21, i32 %22, i8* %23, i8* %24, i8* %25)
br label %27
27: ; preds = %20
ret void
}

LLVM IR (-O2):
define void @test_str(i8* %0, i32 %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 85, i32 16)
%9 = call i32 @strncpy(i8* %7, i8* %2, i64 %3)
%10 = call i32 @string_is(i8* %0, i32 %1, i8* %7, i8* %4, i8* %4)
ret void
}