#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*/ fail(char const *, int, char *);
int /*<<< orphan*/ pass(char const *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ putstr(char const *);
void check_str(const char *actual, const char *expect, int max,
               const char *func, int line) {
  const char *aptr = actual;
  const char *eptr = expect;
  for (int i = 0; i < max; ++i) {
    if (*aptr != *eptr++) {
      fail(func, line, "");
      putstr("\texpect: ");
      putstr(expect);
      putstr("\n\tactual: ");
      putstr(actual);
      putchar('\n');
      return;
    }
    if (!*aptr++)
      break;
  }
  pass(func);
}


x86 assembly (clang, -O0):
<check_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    121b <check_str+0xdb>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x38(%rbp)
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11eb <check_str+0xab>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    0xe67(%rip),%rdx
call   1040 <fail@plt>
lea    0xe47(%rip),%rdi
call   1060 <putstr@plt>
mov    -0x10(%rbp),%rdi
call   1060 <putstr@plt>
lea    0xe3c(%rip),%rdi
call   1060 <putstr@plt>
mov    -0x8(%rbp),%rdi
call   1060 <putstr@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1224 <check_str+0xe4>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
cmpb   $0x0,(%rax)
jne    1208 <check_str+0xc8>
jmp    121b <check_str+0xdb>
jmp    120d <check_str+0xcd>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1172 <check_str+0x32>
mov    -0x20(%rbp),%rdi
call   1050 <pass@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_str>:
push   %r15
push   %r14
push   %rbx
test   %edx,%edx
jle    1177 <check_str+0x37>
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r14,%rax,1),%ebx
cmp    (%r15,%rax,1),%bl
jne    1184 <check_str+0x44>
test   %bl,%bl
je     1177 <check_str+0x37>
add    $0x1,%rax
cmp    %edx,%eax
jl     1160 <check_str+0x20>
mov    %rcx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <pass@plt>
lea    0xe89(%rip),%rdx
mov    %rcx,%rdi
mov    %r8d,%esi
call   1040 <fail@plt>
lea    0xe63(%rip),%rdi
call   1060 <putstr@plt>
mov    %r15,%rdi
call   1060 <putstr@plt>
lea    0xe59(%rip),%rdi
call   1060 <putstr@plt>
mov    %r14,%rdi
call   1060 <putstr@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [10 x i8] c"\09expect: \00"
@.str.2 = [11 x i8] c"\0A\09actual: \00"
define void @check_str(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%14 = load i8*, i8** %6
store i8* %14, i8** %11
%15 = load i8*, i8** %7
store i8* %15, i8** %12
store i32 0, i32* %13
br label %16
16: ; preds = %47, %5
%17 = load i32, i32* %13
%18 = load i32, i32* %8
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %50
20: ; preds = %16
%21 = load i8*, i8** %11
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = load i8*, i8** %12
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %12
%26 = load i8, i8* %24
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %23, %27
br i1 %28, label %29, label %40
29: ; preds = %20
%30 = load i8*, i8** %9
%31 = load i32, i32* %10
%32 = call i32 @fail(i8* %30, i32 %31, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @putstr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%34 = load i8*, i8** %7
%35 = call i32 @putstr(i8* %34)
%36 = call i32 @putstr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%37 = load i8*, i8** %6
%38 = call i32 @putstr(i8* %37)
%39 = call i32 @putchar(i8 signext 10)
br label %53
40: ; preds = %20
%41 = load i8*, i8** %11
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %11
%43 = load i8, i8* %41
%44 = icmp ne i8 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %40
br label %50
46: ; preds = %40
br label %47
47: ; preds = %46
%48 = load i32, i32* %13
%49 = add nsw i32 %48, 1
store i32 %49, i32* %13
br label %16
50: ; preds = %45, %16
%51 = load i8*, i8** %9
%52 = call i32 @pass(i8* %51)
br label %53
53: ; preds = %50, %29
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [10 x i8] c"\09expect: \00"
@.str.2 = [11 x i8] c"\0A\09actual: \00"
define void @check_str(i8* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %28
7: ; preds = %5, %21
%8 = phi i32 [ %25, %21 ], [ 0, %5 ]
%9 = phi i8* [ %22, %21 ], [ %1, %5 ]
%10 = phi i8* [ %24, %21 ], [ %0, %5 ]
%11 = load i8, i8* %10
%12 = load i8, i8* %9
%13 = icmp eq i8 %11, %12
br i1 %13, label %21, label %14
14: ; preds = %7
%15 = tail call i32 @fail(i8* %3, i32 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @putstr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @putstr(i8* %1)
%18 = tail call i32 @putstr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%19 = tail call i32 @putstr(i8* %0)
%20 = tail call i32 @putchar(i8 signext 10)
br label %30
21: ; preds = %7
%22 = getelementptr inbounds i8, i8* %9, i64 1
%23 = icmp ne i8 %11, 0
%24 = getelementptr inbounds i8, i8* %10, i64 1
%25 = add nuw nsw i32 %8, 1
%26 = icmp slt i32 %25, %2
%27 = select i1 %23, i1 %26, i1 false
br i1 %27, label %7, label %28
28: ; preds = %21, %5
%29 = tail call i32 @pass(i8* %3)
br label %30
30: ; preds = %14, %28
ret void
}