#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void check_byte_arrays(unsigned char *actual, unsigned int actual_len,
                       unsigned char *expected, unsigned int expected_len,
                       const char *name) {
  unsigned int i;
  if (actual_len != expected_len) {
    fprintf(stderr, "actual/expected length mis-match %d != %d\n", actual_len,
            expected_len);
    goto fail;
  }
  for (i = 0; i < actual_len; i++) {
    if (actual[i] != expected[i]) {
      fprintf(stderr, "buffers differ at %d\n", i);
      goto fail;
    }
  }
  return;
fail:
  fprintf(stderr, "FAIL: %s\n", name);
  for (i = 0; i < actual_len; i++) {
    fprintf(stderr, "actual[%d]=%02x\n", i, actual[i]);
  }
  for (i = 0; i < expected_len; i++) {
    fprintf(stderr, "expected[%d]=%02x\n", i, expected[i]);
  }
  exit(1);
}


x86 assembly (clang, -O0):
<check_byte_arrays>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1168 <check_byte_arrays+0x48>
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11d1 <check_byte_arrays+0xb1>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11cb <check_byte_arrays+0xab>
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x2c(%rbp),%edx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11b8 <check_byte_arrays+0x98>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11d1 <check_byte_arrays+0xb1>
jmp    11bd <check_byte_arrays+0x9d>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    116f <check_byte_arrays+0x4f>
add    $0x30,%rsp
pop    %rbp
ret
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1232 <check_byte_arrays+0x112>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movzbl (%rax,%rcx,1),%ecx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11f3 <check_byte_arrays+0xd3>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    1278 <check_byte_arrays+0x158>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movzbl (%rax,%rcx,1),%ecx
lea    0xdf9(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1239 <check_byte_arrays+0x119>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<check_byte_arrays>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rdx,%r13
mov    %esi,%r15d
mov    %rdi,%rbp
cmp    %ecx,%esi
jne    1229 <check_byte_arrays+0x109>
test   %r15d,%r15d
je     1165 <check_byte_arrays+0x45>
mov    %r15d,%eax
xor    %edx,%edx
nopl   0x0(%rax)
movzbl 0x0(%rbp,%rdx,1),%ebx
cmp    0x0(%r13,%rdx,1),%bl
jne    1174 <check_byte_arrays+0x54>
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1150 <check_byte_arrays+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ecx,0x4(%rsp)
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e4a(%rip),%r12
mov    (%r12),%edi
lea    0xea0(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r15d,%r15d
je     11de <check_byte_arrays+0xbe>
mov    %r15d,%r14d
lea    0xe91(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r12),%edi
movzbl 0x0(%rbp,%rbx,1),%ecx
mov    %r15,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11c0 <check_byte_arrays+0xa0>
cmpl   $0x0,0x4(%rsp)
je     121f <check_byte_arrays+0xff>
mov    0x4(%rsp),%ebp
lea    0xe6c(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12),%edi
movzbl 0x0(%r13,%rbx,1),%ecx
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1200 <check_byte_arrays+0xe0>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xdc7(%rip),%rsi
mov    %r15d,%edx
mov    %ecx,0x4(%rsp)
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    118f <check_byte_arrays+0x6f>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"actual/expected length mis-match %d != %d\0A\00"
@.str.1 = [22 x i8] c"buffers differ at %d\0A\00"
@.str.2 = [10 x i8] c"FAIL: %s\0A\00"
@.str.3 = [17 x i8] c"actual[%d]=%02x\0A\00"
@.str.4 = [19 x i8] c"expected[%d]=%02x\0A\00"
define void @check_byte_arrays(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%12 = load i32, i32* %7
%13 = load i32, i32* %9
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %20
15: ; preds = %5
%16 = load i32, i32* @stderr
%17 = load i32, i32* %7
%18 = load i32, i32* %9
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
br label %48
20: ; preds = %5
store i32 0, i32* %11
br label %21
21: ; preds = %44, %20
%22 = load i32, i32* %11
%23 = load i32, i32* %7
%24 = icmp ult i32 %22, %23
br i1 %24, label %25, label %47
25: ; preds = %21
%26 = load i8*, i8** %6
%27 = load i32, i32* %11
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = load i8*, i8** %8
%33 = load i32, i32* %11
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = icmp ne i32 %31, %37
br i1 %38, label %39, label %43
39: ; preds = %25
%40 = load i32, i32* @stderr
%41 = load i32, i32* %11
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %41)
br label %48
43: ; preds = %25
br label %44
44: ; preds = %43
%45 = load i32, i32* %11
%46 = add i32 %45, 1
store i32 %46, i32* %11
br label %21
47: ; preds = %21
ret void
48: ; preds = %39, %15
%49 = load i32, i32* @stderr
%50 = load i8*, i8** %10
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %50)
store i32 0, i32* %11
br label %52
52: ; preds = %66, %48
%53 = load i32, i32* %11
%54 = load i32, i32* %7
%55 = icmp ult i32 %53, %54
br i1 %55, label %56, label %69
56: ; preds = %52
%57 = load i32, i32* @stderr
%58 = load i32, i32* %11
%59 = load i8*, i8** %6
%60 = load i32, i32* %11
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %58, i32 %64)
br label %66
66: ; preds = %56
%67 = load i32, i32* %11
%68 = add i32 %67, 1
store i32 %68, i32* %11
br label %52
69: ; preds = %52
store i32 0, i32* %11
br label %70
70: ; preds = %84, %69
%71 = load i32, i32* %11
%72 = load i32, i32* %9
%73 = icmp ult i32 %71, %72
br i1 %73, label %74, label %87
74: ; preds = %70
%75 = load i32, i32* @stderr
%76 = load i32, i32* %11
%77 = load i8*, i8** %8
%78 = load i32, i32* %11
%79 = zext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %77, i64 %79
%81 = load i8, i8* %80
%82 = zext i8 %81 to i32
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %76, i32 %82)
br label %84
84: ; preds = %74
%85 = load i32, i32* %11
%86 = add i32 %85, 1
store i32 %86, i32* %11
br label %70
87: ; preds = %70
%88 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"actual/expected length mis-match %d != %d\0A\00"
@.str.1 = [22 x i8] c"buffers differ at %d\0A\00"
@.str.2 = [10 x i8] c"FAIL: %s\0A\00"
@.str.3 = [17 x i8] c"actual[%d]=%02x\0A\00"
@.str.4 = [19 x i8] c"expected[%d]=%02x\0A\00"
define void @check_byte_arrays(i8* nocapture %0, i32 %1, i8* nocapture %2, i32 %3, i8* %4) {
%6 = icmp eq i32 %1, %3
br i1 %6, label %7, label %11
7: ; preds = %5
%8 = icmp eq i32 %1, 0
br i1 %8, label %28, label %9
9: ; preds = %7
%10 = zext i32 %1 to i64
br label %14
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %3)
br label %29
14: ; preds = %9, %25
%15 = phi i64 [ 0, %9 ], [ %26, %25 ]
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %2, i64 %15
%19 = load i8, i8* %18
%20 = icmp eq i8 %17, %19
br i1 %20, label %25, label %21
21: ; preds = %14
%22 = trunc i64 %15 to i32
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %29
25: ; preds = %14
%26 = add nuw nsw i64 %15, 1
%27 = icmp eq i64 %26, %10
br i1 %27, label %28, label %14
28: ; preds = %25, %7
ret void
29: ; preds = %21, %11
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%32 = icmp eq i32 %1, 0
br i1 %32, label %35, label %33
33: ; preds = %29
%34 = zext i32 %1 to i64
br label %39
35: ; preds = %39, %29
%36 = icmp eq i32 %3, 0
br i1 %36, label %59, label %37
37: ; preds = %35
%38 = zext i32 %3 to i64
br label %49
39: ; preds = %33, %39
%40 = phi i64 [ 0, %33 ], [ %47, %39 ]
%41 = load i32, i32* @stderr
%42 = getelementptr inbounds i8, i8* %0, i64 %40
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = trunc i64 %40 to i32
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %45, i32 %44)
%47 = add nuw nsw i64 %40, 1
%48 = icmp eq i64 %47, %34
br i1 %48, label %35, label %39
49: ; preds = %37, %49
%50 = phi i64 [ 0, %37 ], [ %57, %49 ]
%51 = load i32, i32* @stderr
%52 = getelementptr inbounds i8, i8* %2, i64 %50
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = trunc i64 %50 to i32
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %55, i32 %54)
%57 = add nuw nsw i64 %50, 1
%58 = icmp eq i64 %57, %38
br i1 %58, label %59, label %49
59: ; preds = %49, %35
%60 = tail call i32 @exit(i32 1)
unreachable
}