#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 EVP_PKEY_CTX_set_dh_paramgen_generator(int /*<<< orphan*/ *, int);
int EVP_PKEY_CTX_set_dh_paramgen_prime_len(int /*<<< orphan*/ *, int);
int atoi(char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
int pkey_dh_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) {
  if (!strcmp(type, "dh_paramgen_prime_len")) {
    int len;
    len = atoi(value);
    return EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len);
  }
  if (!strcmp(type, "dh_paramgen_generator")) {
    int len;
    len = atoi(value);
    return EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, len);
  }
  return -2;
}


x86 assembly (clang, -O0):
<pkey_dh_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    0xea1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    118d <pkey_dh_ctrl_str+0x4d>
mov    -0x20(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <EVP_PKEY_CTX_set_dh_paramgen_prime_len@plt>
mov    %eax,-0x4(%rbp)
jmp    11cd <pkey_dh_ctrl_str+0x8d>
mov    -0x18(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11c6 <pkey_dh_ctrl_str+0x86>
mov    -0x20(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1050 <EVP_PKEY_CTX_set_dh_paramgen_generator@plt>
mov    %eax,-0x4(%rbp)
jmp    11cd <pkey_dh_ctrl_str+0x8d>
movl   $0xfffffffe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pkey_dh_ctrl_str>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     117f <pkey_dh_ctrl_str+0x3f>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1196 <pkey_dh_ctrl_str+0x56>
mov    $0xfffffffe,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r15,%rdi
call   1060 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <EVP_PKEY_CTX_set_dh_paramgen_prime_len@plt>
mov    %r15,%rdi
call   1060 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <EVP_PKEY_CTX_set_dh_paramgen_generator@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"dh_paramgen_prime_len\00"
@.str.1 = [22 x i8] c"dh_paramgen_generator\00"
define i32 @pkey_dh_ctrl_str(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = load i8*, i8** %6
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %3
%14 = load i8*, i8** %7
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %8
%16 = load i32*, i32** %5
%17 = load i32, i32* %8
%18 = call i32 @EVP_PKEY_CTX_set_dh_paramgen_prime_len(i32* %16, i32 %17)
store i32 %18, i32* %4
br label %30
19: ; preds = %3
%20 = load i8*, i8** %6
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %19
%24 = load i8*, i8** %7
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %9
%26 = load i32*, i32** %5
%27 = load i32, i32* %9
%28 = call i32 @EVP_PKEY_CTX_set_dh_paramgen_generator(i32* %26, i32 %27)
store i32 %28, i32* %4
br label %30
29: ; preds = %19
store i32 -2, i32* %4
br label %30
30: ; preds = %29, %23, %13
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
@.str = [22 x i8] c"dh_paramgen_prime_len\00"
@.str.1 = [22 x i8] c"dh_paramgen_generator\00"
define i32 @pkey_dh_ctrl_str(i32* %0, i8* nocapture %1, i8* nocapture %2) {
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(22) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @atoi(i8* %2)
%8 = tail call i32 @EVP_PKEY_CTX_set_dh_paramgen_prime_len(i32* %0, i32 %7)
br label %15
9: ; preds = %3
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(22) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = tail call i32 @atoi(i8* %2)
%14 = tail call i32 @EVP_PKEY_CTX_set_dh_paramgen_generator(i32* %0, i32 %13)
br label %15
15: ; preds = %9, %12, %6
%16 = phi i32 [ %14, %12 ], [ %8, %6 ], [ -2, %9 ]
ret i32 %16
}