#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ hexdump(unsigned char const *, int);
scalar_t__ memcmp(unsigned char const *, unsigned char const *, int);
int /*<<< orphan*/ stderr;
int asn1_compare_bytes(int test_no, const unsigned char *d1,
                       const unsigned char *d2, int len1, int len2) {
  if (len1 != len2) {
    fprintf(stderr,
            "FAIL: test %i - byte lengths differ "
            "(%i != %i)\n",
            test_no, len1, len2);
    return (1);
  }
  if (memcmp(d1, d2, len1) != 0) {
    fprintf(stderr, "FAIL: test %i - bytes differ\n", test_no);
    fprintf(stderr, "Got:\n");
    hexdump(d1, len1);
    fprintf(stderr, "Want:\n");
    hexdump(d2, len2);
  }
  return (0);
}


x86 assembly (clang, -O0):
<asn1_compare_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     1183 <asn1_compare_bytes+0x53>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1204 <asn1_compare_bytes+0xd4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     11fd <asn1_compare_bytes+0xcd>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <hexdump@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1050 <hexdump@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_compare_bytes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edi,%ebp
cmp    %r8d,%ecx
jne    11b4 <asn1_compare_bytes+0x84>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %ebx,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     11d7 <asn1_compare_bytes+0xa7>
mov    0x2e7d(%rip),%r13
mov    0x0(%r13),%edi
lea    0xec2(%rip),%rsi
xor    %r12d,%r12d
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%r13),%edi
lea    0xec9(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <hexdump@plt>
mov    0x0(%r13),%edi
lea    0xeb3(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <hexdump@plt>
jmp    11da <asn1_compare_bytes+0xaa>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%r12d
jmp    11da <asn1_compare_bytes+0xaa>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [48 x i8] c"FAIL: test %i - byte lengths differ (%i != %i)\0A\00"
@.str.1 = [30 x i8] c"FAIL: test %i - bytes differ\0A\00"
@.str.2 = [6 x i8] c"Got:\0A\00"
@.str.3 = [7 x i8] c"Want:\0A\00"
define i32 @asn1_compare_bytes(i32 %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%12 = load i32, i32* %10
%13 = load i32, i32* %11
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %5
%16 = load i32, i32* @stderr
%17 = load i32, i32* %7
%18 = load i32, i32* %10
%19 = load i32, i32* %11
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18, i32 %19)
store i32 1, i32* %6
br label %42
21: ; preds = %5
%22 = load i8*, i8** %8
%23 = load i8*, i8** %9
%24 = load i32, i32* %10
%25 = call i64 @memcmp(i8* %22, i8* %23, i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %41
27: ; preds = %21
%28 = load i32, i32* @stderr
%29 = load i32, i32* %7
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%33 = load i8*, i8** %8
%34 = load i32, i32* %10
%35 = call i32 @hexdump(i8* %33, i32 %34)
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%38 = load i8*, i8** %9
%39 = load i32, i32* %11
%40 = call i32 @hexdump(i8* %38, i32 %39)
br label %41
41: ; preds = %27, %21
store i32 0, i32* %6
br label %42
42: ; preds = %41, %15
%43 = load i32, i32* %6
ret i32 %43
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [48 x i8] c"FAIL: test %i - byte lengths differ (%i != %i)\0A\00"
@.str.1 = [30 x i8] c"FAIL: test %i - bytes differ\0A\00"
@.str.2 = [6 x i8] c"Got:\0A\00"
@.str.3 = [7 x i8] c"Want:\0A\00"
define i32 @asn1_compare_bytes(i32 %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %3, %4
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %3, i32 %4)
br label %22
10: ; preds = %5
%11 = tail call i64 @memcmp(i8* %1, i8* %2, i32 %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @hexdump(i8* %1, i32 %3)
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%21 = tail call i32 @hexdump(i8* %2, i32 %3)
br label %22
22: ; preds = %10, %13, %7
%23 = phi i32 [ 1, %7 ], [ 0, %13 ], [ 0, %10 ]
ret i32 %23
}