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

/* Variables and functions */
int /*<<< orphan*/ EC_GROUP_method_of(int /*<<< orphan*/ const *);
scalar_t__ EC_METHOD_get_field_type(int /*<<< orphan*/);
int EC_POINT_set_affine_coordinates_GF2m(int /*<<< orphan*/ const *,
                                         int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ const *,
                                         int /*<<< orphan*/ const *,
                                         int /*<<< orphan*/ *);
int EC_POINT_set_affine_coordinates_GFp(int /*<<< orphan*/ const *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ const *,
                                        int /*<<< orphan*/ const *,
                                        int /*<<< orphan*/ *);
scalar_t__ NID_X9_62_prime_field;
int set_affine_coordinates(const EC_GROUP *G, EC_POINT *P, const BIGNUM *x,
                           const BIGNUM *y, BN_CTX *ctx) {
  if (EC_METHOD_get_field_type(EC_GROUP_method_of(G)) ==
      NID_X9_62_prime_field) {
    return EC_POINT_set_affine_coordinates_GFp(G, P, x, y, ctx);
  } else {
    return EC_POINT_set_affine_coordinates_GF2m(G, P, x, y, ctx);
  }
}


x86 assembly (clang, -O0):
<set_affine_coordinates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <EC_GROUP_method_of@plt>
mov    %eax,%edi
call   1050 <EC_METHOD_get_field_type@plt>
mov    0x2e75(%rip),%rcx
cmp    (%rcx),%rax
jne    119d <set_affine_coordinates+0x5d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1060 <EC_POINT_set_affine_coordinates_GFp@plt>
mov    %eax,-0x4(%rbp)
jmp    11b9 <set_affine_coordinates+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1030 <EC_POINT_set_affine_coordinates_GF2m@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_affine_coordinates>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
call   1040 <EC_GROUP_method_of@plt>
mov    %eax,%edi
call   1050 <EC_METHOD_get_field_type@plt>
mov    0x2e7d(%rip),%rcx
cmp    (%rcx),%rax
jne    118d <set_affine_coordinates+0x4d>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1060 <EC_POINT_set_affine_coordinates_GFp@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <EC_POINT_set_affine_coordinates_GF2m@plt>

LLVM IR (-O0):
@NID_X9_62_prime_field = global i64 0
define i32 @set_affine_coordinates(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
%12 = load i32*, i32** %7
%13 = call i32 @EC_GROUP_method_of(i32* %12)
%14 = call i64 @EC_METHOD_get_field_type(i32 %13)
%15 = load i64, i64* @NID_X9_62_prime_field
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %24
17: ; preds = %5
%18 = load i32*, i32** %7
%19 = load i32*, i32** %8
%20 = load i32*, i32** %9
%21 = load i32*, i32** %10
%22 = load i32*, i32** %11
%23 = call i32 @EC_POINT_set_affine_coordinates_GFp(i32* %18, i32* %19, i32* %20, i32* %21, i32* %22)
store i32 %23, i32* %6
br label %31
24: ; preds = %5
%25 = load i32*, i32** %7
%26 = load i32*, i32** %8
%27 = load i32*, i32** %9
%28 = load i32*, i32** %10
%29 = load i32*, i32** %11
%30 = call i32 @EC_POINT_set_affine_coordinates_GF2m(i32* %25, i32* %26, i32* %27, i32* %28, i32* %29)
store i32 %30, i32* %6
br label %31
31: ; preds = %24, %17
%32 = load i32, i32* %6
ret i32 %32
}

LLVM IR (-O2):
@NID_X9_62_prime_field = global i64 0
define i32 @set_affine_coordinates(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4) {
%6 = tail call i32 @EC_GROUP_method_of(i32* %0)
%7 = tail call i64 @EC_METHOD_get_field_type(i32 %6)
%8 = load i64, i64* @NID_X9_62_prime_field
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @EC_POINT_set_affine_coordinates_GFp(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4)
br label %14
12: ; preds = %5
%13 = tail call i32 @EC_POINT_set_affine_coordinates_GF2m(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4)
br label %14
14: ; preds = %12, %10
%15 = phi i32 [ %11, %10 ], [ %13, %12 ]
ret i32 %15
}