#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*/ OPENSSL_strnlen(char const *, size_t);
scalar_t__ strncmp(char const *, char const *, size_t);
int /*<<< orphan*/ test_fail_string_message(int /*<<< orphan*/ *, char const *,
                                            int, char *, char const *,
                                            char const *, char *, char const *,
                                            int /*<<< orphan*/, char const *,
                                            int /*<<< orphan*/);
int test_strn_eq(const char *file, int line, const char *st1, const char *st2,
                 const char *s1, const char *s2, size_t len) {
  if (s1 == NULL && s2 == NULL)
    return 1;
  if (s1 == NULL || s2 == NULL || strncmp(s1, s2, len) != 0) {
    test_fail_string_message(NULL, file, line, "string", st1, st2, "==", s1,
                             s1 == NULL ? 0 : OPENSSL_strnlen(s1, len), s2,
                             s2 == NULL ? 0 : OPENSSL_strnlen(s2, len));
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<test_strn_eq>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
mov    %r9,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    117b <test_strn_eq+0x4b>
cmpq   $0x0,-0x48(%rbp)
jne    117b <test_strn_eq+0x4b>
movl   $0x1,-0x14(%rbp)
jmp    1298 <test_strn_eq+0x168>
cmpq   $0x0,-0x40(%rbp)
je     11ac <test_strn_eq+0x7c>
cmpq   $0x0,-0x48(%rbp)
je     11ac <test_strn_eq+0x7c>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    0x10(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1291 <test_strn_eq+0x161>
mov    -0x20(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11e7 <test_strn_eq+0xb7>
xor    %eax,%eax
mov    %eax,-0x74(%rbp)
jmp    11f7 <test_strn_eq+0xc7>
mov    -0x40(%rbp),%rdi
mov    0x10(%rbp),%rsi
call   1040 <OPENSSL_strnlen@plt>
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1220 <test_strn_eq+0xf0>
xor    %eax,%eax
mov    %eax,-0x88(%rbp)
jmp    1233 <test_strn_eq+0x103>
mov    -0x48(%rbp),%rdi
mov    0x10(%rbp),%rsi
call   1040 <OPENSSL_strnlen@plt>
mov    %eax,-0x88(%rbp)
mov    -0x80(%rbp),%r10
mov    -0x84(%rbp),%r11d
mov    -0x50(%rbp),%rbx
mov    -0x58(%rbp),%r9
mov    -0x60(%rbp),%r8
mov    -0x64(%rbp),%edx
mov    -0x70(%rbp),%rsi
mov    -0x88(%rbp),%eax
xor    %ecx,%ecx
mov    %ecx,%edi
lea    0xd9e(%rip),%rcx
lea    0xd9e(%rip),%r14
mov    %r14,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %eax,0x20(%rsp)
call   1050 <test_fail_string_message@plt>
movl   $0x0,-0x14(%rbp)
jmp    1298 <test_strn_eq+0x168>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strn_eq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x1,%r15d
mov    %r8,%rax
or     %r9,%rax
je     1204 <test_strn_eq+0xd4>
mov    %r9,%rbx
mov    %r8,%r14
mov    %rcx,%r12
mov    %rdx,%r13
mov    %esi,%ebp
mov    %rdi,0x20(%rsp)
mov    0x60(%rsp),%rsi
test   %r8,%r8
je     118c <test_strn_eq+0x5c>
test   %rbx,%rbx
je     118c <test_strn_eq+0x5c>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    0x60(%rsp),%rdx
call   1030 <strncmp@plt>
mov    0x60(%rsp),%rsi
test   %rax,%rax
je     1204 <test_strn_eq+0xd4>
mov    %ebp,0xc(%rsp)
mov    %r13,0x10(%rsp)
mov    %r12,0x18(%rsp)
xor    %r13d,%r13d
mov    $0x0,%r12d
test   %r14,%r14
je     11b9 <test_strn_eq+0x89>
mov    %r14,%rdi
mov    %rsi,%rbp
call   1040 <OPENSSL_strnlen@plt>
mov    %rbp,%rsi
mov    %eax,%r12d
test   %rbx,%rbx
je     11c9 <test_strn_eq+0x99>
mov    %rbx,%rdi
call   1040 <OPENSSL_strnlen@plt>
mov    %eax,%r13d
sub    $0x8,%rsp
lea    0xe33(%rip),%rax
lea    0xe25(%rip),%rcx
xor    %r15d,%r15d
xor    %edi,%edi
mov    0x28(%rsp),%rsi
mov    0x14(%rsp),%edx
mov    0x18(%rsp),%r8
mov    0x20(%rsp),%r9
push   %r13
push   %rbx
push   %r12
push   %r14
push   %rax
call   1050 <test_fail_string_message@plt>
add    $0x30,%rsp
mov    %r15d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"string\00"
@.str.1 = [3 x i8] c"==\00"
define i32 @test_strn_eq(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4, i8* %5, i64 %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
store i8* %0, i8** %9
store i32 %1, i32* %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i8* %4, i8** %13
store i8* %5, i8** %14
store i64 %6, i64* %15
%16 = load i8*, i8** %13
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %7
%19 = load i8*, i8** %14
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %22
21: ; preds = %18
store i32 1, i32* %8
br label %61
22: ; preds = %18, %7
%23 = load i8*, i8** %13
%24 = icmp eq i8* %23, null
br i1 %24, label %34, label %25
25: ; preds = %22
%26 = load i8*, i8** %14
%27 = icmp eq i8* %26, null
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = load i8*, i8** %13
%30 = load i8*, i8** %14
%31 = load i64, i64* %15
%32 = call i64 @strncmp(i8* %29, i8* %30, i64 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %60
34: ; preds = %28, %25, %22
%35 = load i8*, i8** %9
%36 = load i32, i32* %10
%37 = load i8*, i8** %11
%38 = load i8*, i8** %12
%39 = load i8*, i8** %13
%40 = load i8*, i8** %13
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %43
42: ; preds = %34
br label %47
43: ; preds = %34
%44 = load i8*, i8** %13
%45 = load i64, i64* %15
%46 = call i32 @OPENSSL_strnlen(i8* %44, i64 %45)
br label %47
47: ; preds = %43, %42
%48 = phi i32 [ 0, %42 ], [ %46, %43 ]
%49 = load i8*, i8** %14
%50 = load i8*, i8** %14
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %53
52: ; preds = %47
br label %57
53: ; preds = %47
%54 = load i8*, i8** %14
%55 = load i64, i64* %15
%56 = call i32 @OPENSSL_strnlen(i8* %54, i64 %55)
br label %57
57: ; preds = %53, %52
%58 = phi i32 [ 0, %52 ], [ %56, %53 ]
%59 = call i32 @test_fail_string_message(i32* null, i8* %35, i32 %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %37, i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %39, i32 %48, i8* %49, i32 %58)
store i32 0, i32* %8
br label %61
60: ; preds = %28
store i32 1, i32* %8
br label %61
61: ; preds = %60, %57, %21
%62 = load i32, i32* %8
ret i32 %62
}

LLVM IR (-O2):
@.str = [7 x i8] c"string\00"
@.str.1 = [3 x i8] c"==\00"
define i32 @test_strn_eq(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4, i8* %5, i64 %6) {
%8 = icmp eq i8* %4, null
%9 = icmp eq i8* %5, null
%10 = and i1 %8, %9
br i1 %10, label %26, label %11
11: ; preds = %7
%12 = or i1 %8, %9
br i1 %12, label %16, label %13
13: ; preds = %11
%14 = tail call i64 @strncmp(i8* %4, i8* %5, i64 %6)
%15 = icmp eq i64 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %13, %11
br i1 %8, label %19, label %17
17: ; preds = %16
%18 = tail call i32 @OPENSSL_strnlen(i8* %4, i64 %6)
br label %19
19: ; preds = %16, %17
%20 = phi i32 [ %18, %17 ], [ 0, %16 ]
br i1 %9, label %23, label %21
21: ; preds = %19
%22 = tail call i32 @OPENSSL_strnlen(i8* %5, i64 %6)
br label %23
23: ; preds = %19, %21
%24 = phi i32 [ %22, %21 ], [ 0, %19 ]
%25 = tail call i32 @test_fail_string_message(i32* null, i8* %0, i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %20, i8* %5, i32 %24)
br label %26
26: ; preds = %13, %7, %23
%27 = phi i32 [ 0, %23 ], [ 1, %7 ], [ 1, %13 ]
ret i32 %27
}