#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_F_PKEY_EC_CTRL_STR;
int /*<<< orphan*/ EC_R_INVALID_CURVE;
int /*<<< orphan*/ ECerr(int /*<<< orphan*/, 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 = OBJ_sn2nid(value);
    if (nid == NID_undef)
      nid = OBJ_ln2nid(value);
    if (nid == NID_undef) {
      ECerr(EC_F_PKEY_EC_CTRL_STR, 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    0xe91(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11f0 <pkey_ec_ctrl_str+0xa0>
mov    -0x20(%rbp),%rdi
call   1030 <OBJ_sn2nid@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e3d(%rip),%rcx
cmp    (%rcx),%eax
jne    11a7 <pkey_ec_ctrl_str+0x57>
mov    -0x20(%rbp),%rdi
call   1050 <OBJ_ln2nid@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e1f(%rip),%rcx
cmp    (%rcx),%eax
jne    11dc <pkey_ec_ctrl_str+0x8c>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
call   1070 <ECerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <pkey_ec_ctrl_str+0xa7>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <EVP_PKEY_CTX_set_ec_paramgen_curve_nid@plt>
mov    %eax,-0x4(%rbp)
jmp    11f7 <pkey_ec_ctrl_str+0xa7>
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    0xe9b(%rip),%rsi
mov    %rax,%rdi
call   1060 <strcmp@plt>
mov    %eax,%ecx
mov    $0xfffffffe,%eax
test   %ecx,%ecx
jne    11b6 <pkey_ec_ctrl_str+0x66>
mov    %rbx,%rdi
call   1030 <OBJ_sn2nid@plt>
mov    0x2e49(%rip),%r15
mov    (%r15),%ecx
cmp    %ecx,%eax
jne    1199 <pkey_ec_ctrl_str+0x49>
mov    %rbx,%rdi
call   1050 <OBJ_ln2nid@plt>
mov    (%r15),%ecx
cmp    %ecx,%eax
jne    11bc <pkey_ec_ctrl_str+0x6c>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
call   1070 <ECerr@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <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_F_PKEY_EC_CTRL_STR = 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 %33, label %12
12: ; preds = %3
%13 = load i8*, i8** %7
%14 = call i32 @OBJ_sn2nid(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_ln2nid(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 %29
25: ; preds = %21
%26 = load i32, i32* @EC_F_PKEY_EC_CTRL_STR
%27 = load i32, i32* @EC_R_INVALID_CURVE
%28 = call i32 @ECerr(i32 %26, i32 %27)
store i32 0, i32* %4
br label %34
29: ; preds = %21
%30 = load i32*, i32** %5
%31 = load i32, i32* %8
%32 = call i32 @EVP_PKEY_CTX_set_ec_paramgen_curve_nid(i32* %30, i32 %31)
store i32 %32, i32* %4
br label %34
33: ; preds = %3
store i32 -2, i32* %4
br label %34
34: ; preds = %33, %29, %25
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@.str = [18 x i8] c"ec_paramgen_curve\00"
@NID_undef = global i32 0
@EC_F_PKEY_EC_CTRL_STR = 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 %23
6: ; preds = %3
%7 = tail call i32 @OBJ_sn2nid(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_ln2nid(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 %21
17: ; preds = %13
%18 = load i32, i32* @EC_F_PKEY_EC_CTRL_STR
%19 = load i32, i32* @EC_R_INVALID_CURVE
%20 = tail call i32 @ECerr(i32 %18, i32 %19)
br label %23
21: ; preds = %13
%22 = tail call i32 @EVP_PKEY_CTX_set_ec_paramgen_curve_nid(i32* %0, i32 %15)
br label %23
23: ; preds = %3, %17, %21
%24 = phi i32 [ 0, %17 ], [ %22, %21 ], [ -2, %3 ]
ret i32 %24
}