#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int length;
  int type;
  int /*<<< orphan*/ data;
};
typedef TYPE_1__ ASN1_STRING;

/* Variables and functions */
int memcmp(int /*<<< orphan*/, int /*<<< orphan*/, int);
int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b) {
  int i;
  i = (a->length - b->length);
  if (i == 0) {
    i = memcmp(a->data, b->data, a->length);
    if (i == 0)
      return (a->type - b->type);
    else
      return (i);
  } else
    return (i);
}


x86 assembly (clang, -O0):
<ASN1_STRING_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
sub    (%rcx),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1180 <ASN1_STRING_cmp+0x70>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
call   1030 <memcmp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1175 <ASN1_STRING_cmp+0x65>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    -0x18(%rbp),%rcx
sub    0x4(%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <ASN1_STRING_cmp+0x76>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <ASN1_STRING_cmp+0x76>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_STRING_cmp>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%edx
mov    %edx,%eax
sub    (%rsi),%eax
jne    1138 <ASN1_STRING_cmp+0x28>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x8(%rdi),%edi
mov    0x8(%rsi),%esi
call   1030 <memcmp@plt>
test   %eax,%eax
jne    1138 <ASN1_STRING_cmp+0x28>
mov    0x4(%rbx),%eax
sub    0x4(%r14),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i32, i32 }
define i32 @ASN1_STRING_cmp(%struct.TYPE_4__* %0, %struct.TYPE_4__* %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_4__*
%5 = alloca %struct.TYPE_4__*
%6 = alloca i32
store %struct.TYPE_4__* %0, %struct.TYPE_4__** %4
store %struct.TYPE_4__* %1, %struct.TYPE_4__** %5
%7 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = sub nsw i32 %9, %12
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %39
16: ; preds = %2
%17 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%18 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %17, i32 0, i32 2
%19 = load i32, i32* %18
%20 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%21 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %20, i32 0, i32 2
%22 = load i32, i32* %21
%23 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%24 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %23, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @memcmp(i32 %19, i32 %22, i32 %25)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %37
29: ; preds = %16
%30 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%31 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %30, i32 0, i32 1
%32 = load i32, i32* %31
%33 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%34 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %33, i32 0, i32 1
%35 = load i32, i32* %34
%36 = sub nsw i32 %32, %35
store i32 %36, i32* %3
br label %41
37: ; preds = %16
%38 = load i32, i32* %6
store i32 %38, i32* %3
br label %41
39: ; preds = %2
%40 = load i32, i32* %6
store i32 %40, i32* %3
br label %41
41: ; preds = %39, %37, %29
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i32, i32 }
define i32 @ASN1_STRING_cmp(%struct.TYPE_4__* nocapture %0, %struct.TYPE_4__* nocapture %1) {
%3 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = sub nsw i32 %4, %6
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 2
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 2
%13 = load i32, i32* %12
%14 = tail call i32 @memcmp(i32 %11, i32 %13, i32 %4)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %9
%17 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 1
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 1
%20 = load i32, i32* %19
%21 = sub nsw i32 %18, %20
br label %22
22: ; preds = %2, %9, %16
%23 = phi i32 [ %21, %16 ], [ %14, %9 ], [ %7, %2 ]
ret i32 %23
}