#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 */
typedef scalar_t__ u_char;
typedef int /*<<< orphan*/ EC_POINT;
typedef int /*<<< orphan*/ EC_GROUP;

/* Variables and functions */
int EC_POINT_oct2point(int /*<<< orphan*/ const *, int /*<<< orphan*/ *,
                       scalar_t__ const *, size_t, int /*<<< orphan*/ *);
scalar_t__ const POINT_CONVERSION_UNCOMPRESSED;
int get_ec(const u_char *d, size_t len, EC_POINT *v, const EC_GROUP *g) {
  if (len == 0 || len > ((528 * 2 / 8) + 1))
    return -8;
  if (*d != POINT_CONVERSION_UNCOMPRESSED)
    return -4;
  if (v != NULL && EC_POINT_oct2point(g, v, d, len, NULL) != 1)
    return -4;
  return 0;
}


x86 assembly (clang, -O0):
<get_ec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1141 <get_ec+0x31>
cmpq   $0x85,-0x18(%rbp)
jbe    114d <get_ec+0x3d>
movl   $0xfffffff8,-0x4(%rbp)
jmp    11b1 <get_ec+0xa1>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%rax
je     1170 <get_ec+0x60>
movl   $0xfffffffc,-0x4(%rbp)
jmp    11b1 <get_ec+0xa1>
cmpq   $0x0,-0x20(%rbp)
je     11aa <get_ec+0x9a>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <EC_POINT_oct2point@plt>
cmp    $0x1,%eax
je     11aa <get_ec+0x9a>
movl   $0xfffffffc,-0x4(%rbp)
jmp    11b1 <get_ec+0xa1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ec>:
push   %rbx
mov    %rsi,%rax
add    $0xffffffffffffff7a,%rsi
mov    $0xfffffff8,%ebx
cmp    $0xffffffffffffff7b,%rsi
jb     1157 <get_ec+0x47>
mov    %rdi,%r8
mov    $0xfffffffc,%ebx
cmpq   $0x0,(%rdi)
jne    1157 <get_ec+0x47>
test   %rdx,%rdx
je     1155 <get_ec+0x45>
mov    %rcx,%rdi
mov    %rdx,%rsi
mov    %r8,%rdx
mov    %rax,%rcx
xor    %r8d,%r8d
call   1030 <EC_POINT_oct2point@plt>
cmp    $0x1,%eax
jne    1157 <get_ec+0x47>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@POINT_CONVERSION_UNCOMPRESSED = constant i64 0
define i32 @get_ec(i64* %0, i64 %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i64*
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i32*
store i64* %0, i64** %6
store i64 %1, i64* %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%10 = load i64, i64* %7
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %4
%13 = load i64, i64* %7
%14 = icmp ugt i64 %13, 133
br i1 %14, label %15, label %16
15: ; preds = %12, %4
store i32 -8, i32* %5
br label %34
16: ; preds = %12
%17 = load i64*, i64** %6
%18 = load i64, i64* %17
%19 = load i64, i64* @POINT_CONVERSION_UNCOMPRESSED
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 -4, i32* %5
br label %34
22: ; preds = %16
%23 = load i32*, i32** %8
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = load i32*, i32** %9
%27 = load i32*, i32** %8
%28 = load i64*, i64** %6
%29 = load i64, i64* %7
%30 = call i32 @EC_POINT_oct2point(i32* %26, i32* %27, i64* %28, i64 %29, i32* null)
%31 = icmp ne i32 %30, 1
br i1 %31, label %32, label %33
32: ; preds = %25
store i32 -4, i32* %5
br label %34
33: ; preds = %25, %22
store i32 0, i32* %5
br label %34
34: ; preds = %33, %32, %21, %15
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
@POINT_CONVERSION_UNCOMPRESSED = constant i64 0
define i32 @get_ec(i64* %0, i64 %1, i32* %2, i32* %3) {
%5 = add i64 %1, -134
%6 = icmp ult i64 %5, -133
br i1 %6, label %16, label %7
7: ; preds = %4
%8 = load i64, i64* %0
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = icmp eq i32* %2, null
br i1 %11, label %15, label %12
12: ; preds = %10
%13 = tail call i32 @EC_POINT_oct2point(i32* %3, i32* %2, i64* %0, i64 %1, i32* null)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %12, %10
br label %16
16: ; preds = %12, %7, %4, %15
%17 = phi i32 [ 0, %15 ], [ -8, %4 ], [ -4, %7 ], [ -4, %12 ]
ret i32 %17
}