#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *, ...);
scalar_t__ strncmp(char const *, char const *, size_t);
void assert_str_equals(const char *s1, const char *s2, size_t len) {
  if (!s2) {
    printf("Expected: '%s', but was: NULL\n", s1);
    exit(EXIT_FAILURE);
  }
  if (strncmp(s1, s2, len)) {
    printf("Expected: '%s', but was: '%s'\n", s1, s2);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<assert_str_equals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116f <assert_str_equals+0x3f>
mov    -0x8(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11ae <assert_str_equals+0x7e>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assert_str_equals>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
je     1154 <assert_str_equals+0x24>
mov    %rsi,%rbx
mov    %r14,%rdi
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1167 <assert_str_equals+0x37>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xea5(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117b <assert_str_equals+0x4b>
lea    0xeb1(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Expected: '%s', but was: NULL\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"Expected: '%s', but was: '%s'\0A\00"
define void @assert_str_equals(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = load i64, i64* %6
%18 = call i64 @strncmp(i8* %15, i8* %16, i64 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = load i8*, i8** %5
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"Expected: '%s', but was: NULL\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"Expected: '%s', but was: '%s'\0A\00"
define void @assert_str_equals(i8* %0, i8* %1, i64 %2) {
%4 = icmp eq i8* %1, null
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %3
%10 = tail call i64 @strncmp(i8* %0, i8* %1, i64 %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %9
ret void
}