#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 */
typedef int /*<<< orphan*/ str3;
typedef int /*<<< orphan*/ str2;
typedef int /*<<< orphan*/ str1;

/* Variables and functions */
int /*<<< orphan*/ check_int(int, int /*<<< orphan*/);
int str_ncmp(char const *, int, char const *, int);
void test_str_ncmp() {
  const char *str1 = "foo";
  const char *str2 = "foo2";
  const char *str3 = "fun";
  int result;
  result = str_ncmp(str1, sizeof(str1), str1, sizeof(str1));
  check_int(result, 0);
  result = str_ncmp(str1, sizeof(str1), str2, sizeof(str2));
  check_int(result, 0);
  result = str_ncmp(str1, sizeof(str1), str3, sizeof(str3));
  check_int(result, 0);
}


x86 assembly (clang, -O0):
<test_str_ncmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xec4(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x8,%ecx
mov    %ecx,%esi
call   1040 <str_ncmp@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
xor    %esi,%esi
call   1030 <check_int@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x8,%ecx
mov    %ecx,%esi
call   1040 <str_ncmp@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
xor    %esi,%esi
call   1030 <check_int@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x8,%ecx
mov    %ecx,%esi
call   1040 <str_ncmp@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
xor    %esi,%esi
call   1030 <check_int@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_str_ncmp>:
push   %rbx
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x8,%esi
mov    %rbx,%rdx
mov    $0x8,%ecx
call   1040 <str_ncmp@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1030 <check_int@plt>
lea    0xeb7(%rip),%rdx
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x8,%ecx
call   1040 <str_ncmp@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1030 <check_int@plt>
lea    0xe9a(%rip),%rdx
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x8,%ecx
call   1040 <str_ncmp@plt>
mov    %eax,%edi
xor    %esi,%esi
pop    %rbx
jmp    1030 <check_int@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"foo\00"
@.str.1 = [5 x i8] c"foo2\00"
@.str.2 = [4 x i8] c"fun\00"
define void @test_str_ncmp() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %1
%6 = load i8*, i8** %1
%7 = call i32 @str_ncmp(i8* %5, i32 8, i8* %6, i32 8)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = call i32 @check_int(i32 %8, i32 0)
%10 = load i8*, i8** %1
%11 = load i8*, i8** %2
%12 = call i32 @str_ncmp(i8* %10, i32 8, i8* %11, i32 8)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = call i32 @check_int(i32 %13, i32 0)
%15 = load i8*, i8** %1
%16 = load i8*, i8** %3
%17 = call i32 @str_ncmp(i8* %15, i32 8, i8* %16, i32 8)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = call i32 @check_int(i32 %18, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"foo\00"
@.str.1 = [5 x i8] c"foo2\00"
@.str.2 = [4 x i8] c"fun\00"
define void @test_str_ncmp() {
%1 = tail call i32 @str_ncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8)
%2 = tail call i32 @check_int(i32 %1, i32 0)
%3 = tail call i32 @str_ncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 8)
%4 = tail call i32 @check_int(i32 %3, i32 0)
%5 = tail call i32 @str_ncmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 8)
%6 = tail call i32 @check_int(i32 %5, i32 0)
ret void
}