#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*/ EVP_PKEY_CTX;

/* Variables and functions */
int /*<<< orphan*/ EC_R_INVALID_CURVE;
int EC_curve_nist2nid(char const *);
int /*<<< orphan*/ ECerror(int /*<<< orphan*/);
int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(int /*<<< orphan*/ *, int);
int NID_undef;
int OBJ_ln2nid(char const *);
int OBJ_sn2nid(char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
int pkey_ec_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) {
  if (!strcmp(type, "ec_paramgen_curve")) {
    int nid;
    nid = EC_curve_nist2nid(value);
    if (nid == NID_undef)
      nid = OBJ_sn2nid(value);
    if (nid == NID_undef)
      nid = OBJ_ln2nid(value);
    if (nid == NID_undef) {
      ECerror(EC_R_INVALID_CURVE);
      return 0;
    }
    return EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid);
  }
  return -2;
}


x86 assembly (clang, -O0):
<pkey_ec_ctrl_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1215 <pkey_ec_ctrl_str+0xb5>
mov    -0x20(%rbp),%rdi
call   1070 <EC_curve_nist2nid@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%eax
jne    11b7 <pkey_ec_ctrl_str+0x57>
mov    -0x20(%rbp),%rdi
call   1030 <OBJ_sn2nid@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e17(%rip),%rcx
cmp    (%rcx),%eax
jne    11d5 <pkey_ec_ctrl_str+0x75>
mov    -0x20(%rbp),%rdi
call   1060 <OBJ_ln2nid@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2df9(%rip),%rcx
cmp    (%rcx),%eax
jne    1201 <pkey_ec_ctrl_str+0xa1>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1040 <ECerror@plt>
movl   $0x0,-0x4(%rbp)
jmp    121c <pkey_ec_ctrl_str+0xbc>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <EVP_PKEY_CTX_set_ec_paramgen_curve_nid@plt>
mov    %eax,-0x4(%rbp)
jmp    121c <pkey_ec_ctrl_str+0xbc>
movl   $0xfffffffe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pkey_ec_ctrl_str>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%rax
mov    %rdi,%r14
lea    0xe8b(%rip),%rsi
mov    %rax,%rdi
call   1080 <strcmp@plt>
mov    %eax,%ecx
mov    $0xfffffffe,%eax
test   %ecx,%ecx
jne    11b6 <pkey_ec_ctrl_str+0x56>
mov    %rbx,%rdi
call   1070 <EC_curve_nist2nid@plt>
mov    0x2e41(%rip),%r15
mov    (%r15),%ecx
cmp    %ecx,%eax
je     11bc <pkey_ec_ctrl_str+0x5c>
cmp    %ecx,%eax
je     11cb <pkey_ec_ctrl_str+0x6b>
cmp    %ecx,%eax
jne    11da <pkey_ec_ctrl_str+0x7a>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1040 <ECerror@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1030 <OBJ_sn2nid@plt>
mov    (%r15),%ecx
cmp    %ecx,%eax
jne    11a2 <pkey_ec_ctrl_str+0x42>
mov    %rbx,%rdi
call   1060 <OBJ_ln2nid@plt>
mov    (%r15),%ecx
cmp    %ecx,%eax
je     11a6 <pkey_ec_ctrl_str+0x46>
mov    %r14,%rdi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <EVP_PKEY_CTX_set_ec_paramgen_curve_nid@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"ec_paramgen_curve\00"
@NID_undef = global i32 0
@EC_R_INVALID_CURVE = global i32 0
define i32 @pkey_ec_ctrl_str(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %6
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %39, label %12
12: ; preds = %3
%13 = load i8*, i8** %7
%14 = call i32 @EC_curve_nist2nid(i8* %13)
store i32 %14, i32* %8
%15 = load i32, i32* %8
%16 = load i32, i32* @NID_undef
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i8*, i8** %7
%20 = call i32 @OBJ_sn2nid(i8* %19)
store i32 %20, i32* %8
br label %21
21: ; preds = %18, %12
%22 = load i32, i32* %8
%23 = load i32, i32* @NID_undef
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i8*, i8** %7
%27 = call i32 @OBJ_ln2nid(i8* %26)
store i32 %27, i32* %8
br label %28
28: ; preds = %25, %21
%29 = load i32, i32* %8
%30 = load i32, i32* @NID_undef
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i32, i32* @EC_R_INVALID_CURVE
%34 = call i32 @ECerror(i32 %33)
store i32 0, i32* %4
br label %40
35: ; preds = %28
%36 = load i32*, i32** %5
%37 = load i32, i32* %8
%38 = call i32 @EVP_PKEY_CTX_set_ec_paramgen_curve_nid(i32* %36, i32 %37)
store i32 %38, i32* %4
br label %40
39: ; preds = %3
store i32 -2, i32* %4
br label %40
40: ; preds = %39, %35, %32
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
@.str = [18 x i8] c"ec_paramgen_curve\00"
@NID_undef = global i32 0
@EC_R_INVALID_CURVE = global i32 0
define i32 @pkey_ec_ctrl_str(i32* %0, i8* nocapture %1, i8* %2) {
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %29
6: ; preds = %3
%7 = tail call i32 @EC_curve_nist2nid(i8* %2)
%8 = load i32, i32* @NID_undef
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = tail call i32 @OBJ_sn2nid(i8* %2)
%12 = load i32, i32* @NID_undef
br label %13
13: ; preds = %10, %6
%14 = phi i32 [ %12, %10 ], [ %8, %6 ]
%15 = phi i32 [ %11, %10 ], [ %7, %6 ]
%16 = icmp eq i32 %15, %14
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = tail call i32 @OBJ_ln2nid(i8* %2)
%19 = load i32, i32* @NID_undef
br label %20
20: ; preds = %17, %13
%21 = phi i32 [ %19, %17 ], [ %14, %13 ]
%22 = phi i32 [ %18, %17 ], [ %15, %13 ]
%23 = icmp eq i32 %22, %21
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* @EC_R_INVALID_CURVE
%26 = tail call i32 @ECerror(i32 %25)
br label %29
27: ; preds = %20
%28 = tail call i32 @EVP_PKEY_CTX_set_ec_paramgen_curve_nid(i32* %0, i32 %22)
br label %29
29: ; preds = %3, %24, %27
%30 = phi i32 [ 0, %24 ], [ %28, %27 ], [ -2, %3 ]
ret i32 %30
}