#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_1__;

/* Type definitions */
struct TYPE_6__ {
  int type;
};
typedef TYPE_1__ ASN1_INTEGER;

/* Variables and functions */
int ASN1_STRING_cmp(TYPE_1__ const *, TYPE_1__ const *);
int V_ASN1_NEG;
int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y) {
  int neg, ret;
  neg = x->type & V_ASN1_NEG;
  if (neg != (y->type & V_ASN1_NEG)) {
    if (neg)
      return -1;
    else
      return 1;
  }
  ret = ASN1_STRING_cmp(x, y);
  if (neg)
    return -ret;
  else
    return ret;
}


x86 assembly (clang, -O0):
<ASN1_INTEGER_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    0x2ebb(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
mov    0x2ea6(%rip),%rdx
and    (%rdx),%ecx
cmp    %ecx,%eax
je     116e <ASN1_INTEGER_cmp+0x5e>
cmpl   $0x0,-0x1c(%rbp)
je     1162 <ASN1_INTEGER_cmp+0x52>
movl   $0xffffffff,-0x4(%rbp)
jmp    119b <ASN1_INTEGER_cmp+0x8b>
movl   $0x1,-0x4(%rbp)
jmp    119b <ASN1_INTEGER_cmp+0x8b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <ASN1_STRING_cmp@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1195 <ASN1_INTEGER_cmp+0x85>
xor    %eax,%eax
sub    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119b <ASN1_INTEGER_cmp+0x8b>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_INTEGER_cmp>:
push   %rbx
mov    0x2ed0(%rip),%rax
mov    (%rax),%eax
mov    (%rdi),%ebx
and    %eax,%ebx
and    (%rsi),%eax
cmp    %eax,%ebx
jne    1134 <ASN1_INTEGER_cmp+0x24>
call   1030 <ASN1_STRING_cmp@plt>
mov    %eax,%ecx
neg    %eax
test   %ebx,%ebx
cmove  %ecx,%eax
pop    %rbx
ret
neg    %ebx
sbb    %eax,%eax
or     $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32 }
@V_ASN1_NEG = global i32 0
define i32 @ASN1_INTEGER_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
%7 = alloca i32
store %struct.TYPE_6__* %0, %struct.TYPE_6__** %4
store %struct.TYPE_6__* %1, %struct.TYPE_6__** %5
%8 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%9 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = load i32, i32* @V_ASN1_NEG
%12 = and i32 %10, %11
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%15 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = load i32, i32* @V_ASN1_NEG
%18 = and i32 %16, %17
%19 = icmp ne i32 %13, %18
br i1 %19, label %20, label %25
20: ; preds = %2
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 -1, i32* %3
br label %36
24: ; preds = %20
store i32 1, i32* %3
br label %36
25: ; preds = %2
%26 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%27 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%28 = call i32 @ASN1_STRING_cmp(%struct.TYPE_6__* %26, %struct.TYPE_6__* %27)
store i32 %28, i32* %7
%29 = load i32, i32* %6
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i32, i32* %7
%33 = sub nsw i32 0, %32
store i32 %33, i32* %3
br label %36
34: ; preds = %25
%35 = load i32, i32* %7
store i32 %35, i32* %3
br label %36
36: ; preds = %34, %31, %24, %23
%37 = load i32, i32* %3
ret i32 %37
}

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