#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 */
struct clad_test {
  int dummy;
};

/* Variables and functions */
struct clad_test *clad_test_assert(struct clad_test *, int, char *, char *,
                                   char *, char const *);
scalar_t__ strncmp(char *, char *, size_t);
struct clad_test *clad_test_streqn(struct clad_test *test, char *s1, size_t n,
                                   char *s2, const char *explain) {
  return clad_test_assert(test, strncmp(s1, s2, n) == 0,
                          "Strings should be equal: >%s< >%s<; %s ", s1, s2,
                          explain);
}


x86 assembly (clang, -O0):
<clad_test_streqn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <strncmp@plt>
mov    -0x30(%rbp),%rdi
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%esi
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
lea    0xe88(%rip),%rdx
call   1040 <clad_test_assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clad_test_streqn>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
mov    %rsi,%rdi
mov    %rcx,%rsi
call   1030 <strncmp@plt>
xor    %esi,%esi
test   %rax,%rax
sete   %sil
lea    0xeb1(%rip),%rdx
mov    %r12,%rdi
mov    %rbx,%rcx
mov    %r15,%r8
mov    %r14,%r9
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <clad_test_assert@plt>

LLVM IR (-O0):
%struct.clad_test = type { i32 }
@.str = [40 x i8] c"Strings should be equal: >%s< >%s<; %s \00"
define %struct.clad_test* @clad_test_streqn(%struct.clad_test* %0, i8* %1, i64 %2, i8* %3, i8* %4) {
%6 = alloca %struct.clad_test*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
store %struct.clad_test* %0, %struct.clad_test** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%11 = load %struct.clad_test*, %struct.clad_test** %6
%12 = load i8*, i8** %7
%13 = load i8*, i8** %9
%14 = load i64, i64* %8
%15 = call i64 @strncmp(i8* %12, i8* %13, i64 %14)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = load i8*, i8** %7
%19 = load i8*, i8** %9
%20 = load i8*, i8** %10
%21 = call %struct.clad_test* @clad_test_assert(%struct.clad_test* %11, i32 %17, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %19, i8* %20)
ret %struct.clad_test* %21
}

LLVM IR (-O2):
%struct.clad_test = type { i32 }
@.str = [40 x i8] c"Strings should be equal: >%s< >%s<; %s \00"
define %struct.clad_test* @clad_test_streqn(%struct.clad_test* %0, i8* %1, i64 %2, i8* %3, i8* %4) {
%6 = tail call i64 @strncmp(i8* %1, i8* %3, i64 %2)
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call %struct.clad_test* @clad_test_assert(%struct.clad_test* %0, i32 %8, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %3, i8* %4)
ret %struct.clad_test* %9
}