#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*/ printf(char *, char const *, char const *);
int /*<<< orphan*/ strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int /*<<< orphan*/);
void assert_str_equals(const char *val1, const char *val2) {
  if (strncmp(val1, val2, strlen(val1)) == 0 &&
      strncmp(val2, val1, strlen(val2)) == 0)
    printf("\033[00;32mOK: Asserting that %s equals %s\033[00m\n", val1, val2);
  else
    printf("\033[31mKO: Asserting that %s equals %s\033[00m\n", val1, val2);
}


x86 assembly (clang, -O0):
<assert_str_equals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11bd <assert_str_equals+0x8d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11bd <assert_str_equals+0x8d>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe4d(%rip),%rdi
call   1050 <printf@plt>
jmp    11d1 <assert_str_equals+0xa1>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe62(%rip),%rdi
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assert_str_equals>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    116b <assert_str_equals+0x3b>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1184 <assert_str_equals+0x54>
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <printf@plt>
lea    0xe75(%rip),%rdi
jmp    1172 <assert_str_equals+0x42>

LLVM IR (-O0):
@.str = [46 x i8] c"\1B[00;32mOK: Asserting that %s equals %s\1B[00m\0A\00"
@.str.1 = [43 x i8] c"\1B[31mKO: Asserting that %s equals %s\1B[00m\0A\00"
define void @assert_str_equals(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = load i8*, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = call i64 @strncmp(i8* %5, i8* %6, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load i8*, i8** %3
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = call i64 @strncmp(i8* %12, i8* %13, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i8*, i8** %3
%20 = load i8*, i8** %4
%21 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
br label %26
22: ; preds = %11, %2
%23 = load i8*, i8** %3
%24 = load i8*, i8** %4
%25 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %24)
br label %26
26: ; preds = %22, %18
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"\1B[00;32mOK: Asserting that %s equals %s\1B[00m\0A\00"
@.str.1 = [43 x i8] c"\1B[31mKO: Asserting that %s equals %s\1B[00m\0A\00"
define void @assert_str_equals(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %1)
%8 = tail call i64 @strncmp(i8* %1, i8* %0, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %6, %2
br label %11
11: ; preds = %6, %10
%12 = phi i8* [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), %10 ], [ getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), %6 ]
%13 = tail call i32 @printf(i8* %12, i8* %0, i8* %1)
ret void
}