#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_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int /*<<< orphan*/ rid;
  int /*<<< orphan*/ ip;
  int /*<<< orphan*/ dirn;
  int /*<<< orphan*/ ia5;
  int /*<<< orphan*/ otherName;
  int /*<<< orphan*/ other;
};
struct TYPE_6__ {
  int type;
  TYPE_1__ d;
};
typedef TYPE_2__ GENERAL_NAME;

/* Variables and functions */
int ASN1_OCTET_STRING_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int ASN1_STRING_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int ASN1_TYPE_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
#define GEN_DIRNAME 136
#define GEN_DNS 135
#define GEN_EDIPARTY 134
#define GEN_EMAIL 133
#define GEN_IPADD 132
#define GEN_OTHERNAME 131
#define GEN_RID 130
#define GEN_URI 129
#define GEN_X400 128
int OBJ_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int OTHERNAME_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int X509_NAME_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b) {
  int result = -1;
  if (!a || !b || a->type != b->type)
    return -1;
  switch (a->type) {
  case GEN_X400:
  case GEN_EDIPARTY:
    result = ASN1_TYPE_cmp(a->d.other, b->d.other);
    break;
  case GEN_OTHERNAME:
    result = OTHERNAME_cmp(a->d.otherName, b->d.otherName);
    break;
  case GEN_EMAIL:
  case GEN_DNS:
  case GEN_URI:
    result = ASN1_STRING_cmp(a->d.ia5, b->d.ia5);
    break;
  case GEN_DIRNAME:
    result = X509_NAME_cmp(a->d.dirn, b->d.dirn);
    break;
  case GEN_IPADD:
    result = ASN1_OCTET_STRING_cmp(a->d.ip, b->d.ip);
    break;
  case GEN_RID:
    result = OBJ_cmp(a->d.rid, b->d.rid);
    break;
  }
  return result;
}


x86 assembly (clang, -O0):
<GENERAL_NAME_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119f <GENERAL_NAME_cmp+0x3f>
cmpq   $0x0,-0x18(%rbp)
je     119f <GENERAL_NAME_cmp+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
je     11ab <GENERAL_NAME_cmp+0x4b>
movl   $0xffffffff,-0x4(%rbp)
jmp    127a <GENERAL_NAME_cmp+0x11a>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x8,%eax
ja     1274 <GENERAL_NAME_cmp+0x114>
mov    -0x28(%rbp),%rax
lea    0xe32(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%esi
call   1040 <ASN1_TYPE_cmp@plt>
mov    %eax,-0x1c(%rbp)
jmp    1274 <GENERAL_NAME_cmp+0x114>
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%esi
call   1050 <OTHERNAME_cmp@plt>
mov    %eax,-0x1c(%rbp)
jmp    1274 <GENERAL_NAME_cmp+0x114>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%esi
call   1060 <ASN1_STRING_cmp@plt>
mov    %eax,-0x1c(%rbp)
jmp    1274 <GENERAL_NAME_cmp+0x114>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%esi
call   1080 <X509_NAME_cmp@plt>
mov    %eax,-0x1c(%rbp)
jmp    1274 <GENERAL_NAME_cmp+0x114>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%esi
call   1030 <ASN1_OCTET_STRING_cmp@plt>
mov    %eax,-0x1c(%rbp)
jmp    1274 <GENERAL_NAME_cmp+0x114>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%esi
call   1070 <OBJ_cmp@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GENERAL_NAME_cmp>:
test   %rdi,%rdi
je     1193 <GENERAL_NAME_cmp+0x33>
test   %rsi,%rsi
je     1193 <GENERAL_NAME_cmp+0x33>
mov    (%rdi),%eax
cmp    (%rsi),%eax
jne    1193 <GENERAL_NAME_cmp+0x33>
add    $0xffffff80,%eax
cmp    $0x8,%eax
ja     1193 <GENERAL_NAME_cmp+0x33>
lea    0xe81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x10(%rdi),%edi
mov    0x10(%rsi),%esi
jmp    1060 <ASN1_STRING_cmp@plt>
mov    $0xffffffff,%eax
ret
mov    0x18(%rdi),%edi
mov    0x18(%rsi),%esi
jmp    1040 <ASN1_TYPE_cmp@plt>
mov    0x4(%rdi),%edi
mov    0x4(%rsi),%esi
jmp    1070 <OBJ_cmp@plt>
mov    0x14(%rdi),%edi
mov    0x14(%rsi),%esi
jmp    1050 <OTHERNAME_cmp@plt>
mov    0x8(%rdi),%edi
mov    0x8(%rsi),%esi
jmp    1030 <ASN1_OCTET_STRING_cmp@plt>
mov    0xc(%rdi),%edi
mov    0xc(%rsi),%esi
jmp    1080 <X509_NAME_cmp@plt>

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32, %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i32, i32, i32, i32, i32, i32 }
define i32 @GENERAL_NAME_cmp(%struct.TYPE_6__* %0, %struct.TYPE_6__* %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_6__*
%5 = alloca %struct.TYPE_6__*
%6 = alloca i32
store %struct.TYPE_6__* %0, %struct.TYPE_6__** %4
store %struct.TYPE_6__* %1, %struct.TYPE_6__** %5
store i32 -1, i32* %6
%7 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%8 = icmp ne %struct.TYPE_6__* %7, null
br i1 %8, label %9, label %20
9: ; preds = %2
%10 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%11 = icmp ne %struct.TYPE_6__* %10, null
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%14 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = icmp ne i32 %15, %18
br i1 %19, label %20, label %21
20: ; preds = %12, %9, %2
store i32 -1, i32* %3
br label %87
21: ; preds = %12
%22 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%23 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %22, i32 0, i32 0
%24 = load i32, i32* %23
switch i32 %24, label %85 [
i32 128, label %25
i32 134, label %25
i32 131, label %35
i32 133, label %45
i32 135, label %45
i32 129, label %45
i32 136, label %55
i32 132, label %65
i32 130, label %75
]
25: ; preds = %21, %21
%26 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%27 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %26, i32 0, i32 1
%28 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %27, i32 0, i32 5
%29 = load i32, i32* %28
%30 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%31 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %30, i32 0, i32 1
%32 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %31, i32 0, i32 5
%33 = load i32, i32* %32
%34 = call i32 @ASN1_TYPE_cmp(i32 %29, i32 %33)
store i32 %34, i32* %6
br label %85
35: ; preds = %21
%36 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%37 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %36, i32 0, i32 1
%38 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %37, i32 0, i32 4
%39 = load i32, i32* %38
%40 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%41 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %40, i32 0, i32 1
%42 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %41, i32 0, i32 4
%43 = load i32, i32* %42
%44 = call i32 @OTHERNAME_cmp(i32 %39, i32 %43)
store i32 %44, i32* %6
br label %85
45: ; preds = %21, %21, %21
%46 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%47 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %46, i32 0, i32 1
%48 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %47, i32 0, i32 3
%49 = load i32, i32* %48
%50 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%51 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %50, i32 0, i32 1
%52 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %51, i32 0, i32 3
%53 = load i32, i32* %52
%54 = call i32 @ASN1_STRING_cmp(i32 %49, i32 %53)
store i32 %54, i32* %6
br label %85
55: ; preds = %21
%56 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%57 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %56, i32 0, i32 1
%58 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %57, i32 0, i32 2
%59 = load i32, i32* %58
%60 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%61 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %60, i32 0, i32 1
%62 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %61, i32 0, i32 2
%63 = load i32, i32* %62
%64 = call i32 @X509_NAME_cmp(i32 %59, i32 %63)
store i32 %64, i32* %6
br label %85
65: ; preds = %21
%66 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%67 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %66, i32 0, i32 1
%68 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %67, i32 0, i32 1
%69 = load i32, i32* %68
%70 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%71 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %70, i32 0, i32 1
%72 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %71, i32 0, i32 1
%73 = load i32, i32* %72
%74 = call i32 @ASN1_OCTET_STRING_cmp(i32 %69, i32 %73)
store i32 %74, i32* %6
br label %85
75: ; preds = %21
%76 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%77 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %76, i32 0, i32 1
%78 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %77, i32 0, i32 0
%79 = load i32, i32* %78
%80 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%81 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %80, i32 0, i32 1
%82 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %81, i32 0, i32 0
%83 = load i32, i32* %82
%84 = call i32 @OBJ_cmp(i32 %79, i32 %83)
store i32 %84, i32* %6
br label %85
85: ; preds = %21, %75, %65, %55, %45, %35, %25
%86 = load i32, i32* %6
store i32 %86, i32* %3
br label %87
87: ; preds = %85, %20
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32, %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i32, i32, i32, i32, i32, i32 }
define i32 @GENERAL_NAME_cmp(%struct.TYPE_6__* %0, %struct.TYPE_6__* %1) {
%3 = icmp ne %struct.TYPE_6__* %0, null
%4 = icmp ne %struct.TYPE_6__* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %49
6: ; preds = %2
%7 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 0
%10 = load i32, i32* %9
%11 = icmp eq i32 %8, %10
br i1 %11, label %12, label %49
12: ; preds = %6
switch i32 %8, label %49 [
i32 128, label %13
i32 134, label %13
i32 131, label %19
i32 133, label %25
i32 135, label %25
i32 129, label %25
i32 136, label %31
i32 132, label %37
i32 130, label %43
]
13: ; preds = %12, %12
%14 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1, i32 5
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 1, i32 5
%17 = load i32, i32* %16
%18 = tail call i32 @ASN1_TYPE_cmp(i32 %15, i32 %17)
br label %49
19: ; preds = %12
%20 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1, i32 4
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 1, i32 4
%23 = load i32, i32* %22
%24 = tail call i32 @OTHERNAME_cmp(i32 %21, i32 %23)
br label %49
25: ; preds = %12, %12, %12
%26 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1, i32 3
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 1, i32 3
%29 = load i32, i32* %28
%30 = tail call i32 @ASN1_STRING_cmp(i32 %27, i32 %29)
br label %49
31: ; preds = %12
%32 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1, i32 2
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 1, i32 2
%35 = load i32, i32* %34
%36 = tail call i32 @X509_NAME_cmp(i32 %33, i32 %35)
br label %49
37: ; preds = %12
%38 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1, i32 1
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 1, i32 1
%41 = load i32, i32* %40
%42 = tail call i32 @ASN1_OCTET_STRING_cmp(i32 %39, i32 %41)
br label %49
43: ; preds = %12
%44 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1, i32 0
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 1, i32 0
%47 = load i32, i32* %46
%48 = tail call i32 @OBJ_cmp(i32 %45, i32 %47)
br label %49
49: ; preds = %13, %19, %25, %31, %37, %43, %12, %2, %6
%50 = phi i32 [ -1, %6 ], [ -1, %2 ], [ -1, %12 ], [ %48, %43 ], [ %42, %37 ], [ %36, %31 ], [ %30, %25 ], [ %24, %19 ], [ %18, %13 ]
ret i32 %50
}