#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*/ ERR_GOST_error(int, int, char *, int);
int /*<<< orphan*/ EVP_PKEY_CTRL_SET_MAC_KEY;
int /*<<< orphan*/ OPENSSL_free(unsigned char *);
int pkey_gost_mac_ctrl(int /*<<< orphan*/ *, int /*<<< orphan*/, int, ...);
int /*<<< orphan*/ strcmp(char const *, char *);
unsigned char *string_to_hex(char const *, long *);
int strlen(char const *);
int pkey_gost_mac_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
                           const char *value) {
  if (!strcmp(type, "key")) {
    if (strlen(value) != 32) {
      ERR_GOST_error((129), (111),
                     "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/caidongyun/"
                     "nginx-openresty-windows/refs/heads/master/nginx/objs/lib/"
                     "openssl-1.0.1g/engines/ccgost/gost_pmeth.c",
                     515);
      return 0;
    }
    return pkey_gost_mac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, 32,
                              (char *)value);
  }
  if (!strcmp(type, "hexkey")) {
    long keylen;
    int ret;
    unsigned char *keybuf = string_to_hex(value, &keylen);
    if (keylen != 32) {
      ERR_GOST_error((129), (111),
                     "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                     "outputs/2022-01-22/02-19-57/repos/caidongyun/"
                     "nginx-openresty-windows/refs/heads/master/nginx/objs/lib/"
                     "openssl-1.0.1g/engines/ccgost/gost_pmeth.c",
                     528);
      OPENSSL_free(keybuf);
      return 0;
    }
    ret = pkey_gost_mac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY, 32, keybuf);
    OPENSSL_free(keybuf);
    return ret;
  }
  return -2;
}


x86 assembly (clang, -O0):
<pkey_gost_mac_ctrl_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xf4d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11eb <pkey_gost_mac_ctrl_str+0x8b>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x20,%eax
je     11c6 <pkey_gost_mac_ctrl_str+0x66>
mov    $0x81,%edi
mov    $0x6f,%esi
lea    0xe50(%rip),%rdx
mov    $0x203,%ecx
call   1070 <ERR_GOST_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    128b <pkey_gost_mac_ctrl_str+0x12b>
mov    -0x10(%rbp),%rdi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rcx
mov    $0x20,%edx
mov    $0x0,%al
call   1040 <pkey_gost_mac_ctrl@plt>
mov    %eax,-0x4(%rbp)
jmp    128b <pkey_gost_mac_ctrl_str+0x12b>
mov    -0x18(%rbp),%rdi
lea    0xed3(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1284 <pkey_gost_mac_ctrl_str+0x124>
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1060 <string_to_hex@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x20,-0x28(%rbp)
je     1250 <pkey_gost_mac_ctrl_str+0xf0>
mov    $0x81,%edi
mov    $0x6f,%esi
lea    0xdcf(%rip),%rdx
mov    $0x210,%ecx
call   1070 <ERR_GOST_error@plt>
mov    -0x38(%rbp),%rdi
call   1080 <OPENSSL_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    128b <pkey_gost_mac_ctrl_str+0x12b>
mov    -0x10(%rbp),%rdi
mov    0x2d85(%rip),%rax
mov    (%rax),%esi
mov    -0x38(%rbp),%rcx
mov    $0x20,%edx
mov    $0x0,%al
call   1040 <pkey_gost_mac_ctrl@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rdi
call   1080 <OPENSSL_free@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    128b <pkey_gost_mac_ctrl_str+0x12b>
movl   $0xfffffffe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pkey_gost_mac_ctrl_str>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r14
lea    0xf54(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11d7 <pkey_gost_mac_ctrl_str+0x77>
lea    0xf3e(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
mov    $0xfffffffe,%ebp
test   %eax,%eax
jne    124b <pkey_gost_mac_ctrl_str+0xeb>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <string_to_hex@plt>
mov    %rax,%rbx
cmpq   $0x20,0x8(%rsp)
jne    1226 <pkey_gost_mac_ctrl_str+0xc6>
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
mov    $0x20,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <pkey_gost_mac_ctrl@plt>
mov    %eax,%ebp
jmp    1243 <pkey_gost_mac_ctrl_str+0xe3>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x20,%eax
jne    1207 <pkey_gost_mac_ctrl_str+0xa7>
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
mov    $0x20,%edx
mov    %rbx,%rcx
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <pkey_gost_mac_ctrl@plt>
lea    0xdf2(%rip),%rdx
mov    $0x81,%edi
mov    $0x6f,%esi
mov    $0x203,%ecx
call   1070 <ERR_GOST_error@plt>
xor    %ebp,%ebp
jmp    124b <pkey_gost_mac_ctrl_str+0xeb>
lea    0xdd3(%rip),%rdx
mov    $0x81,%edi
mov    $0x6f,%esi
mov    $0x210,%ecx
call   1070 <ERR_GOST_error@plt>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1080 <OPENSSL_free@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"key\00"
@.str.1 = [201 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/caidongyun/nginx-openresty-windows/refs/heads/master/nginx/objs/lib/openssl-1.0.1g/engines/ccgost/gost_pmeth.c\00"
@EVP_PKEY_CTRL_SET_MAC_KEY = global i32 0
@.str.2 = [7 x i8] c"hexkey\00"
define i32 @pkey_gost_mac_ctrl_str(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = load i8*, i8** %6
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %25, label %14
14: ; preds = %3
%15 = load i8*, i8** %7
%16 = call i32 @strlen(i8* %15)
%17 = icmp ne i32 %16, 32
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @ERR_GOST_error(i32 129, i32 111, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str.1, i64 0, i64 0), i32 515)
store i32 0, i32* %4
br label %47
20: ; preds = %14
%21 = load i32*, i32** %5
%22 = load i32, i32* @EVP_PKEY_CTRL_SET_MAC_KEY
%23 = load i8*, i8** %7
%24 = call i32 (i32*, i32, i32, ...) @pkey_gost_mac_ctrl(i32* %21, i32 %22, i32 32, i8* %23)
store i32 %24, i32* %4
br label %47
25: ; preds = %3
%26 = load i8*, i8** %6
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %46, label %29
29: ; preds = %25
%30 = load i8*, i8** %7
%31 = call i8* @string_to_hex(i8* %30, i64* %8)
store i8* %31, i8** %10
%32 = load i64, i64* %8
%33 = icmp ne i64 %32, 32
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = call i32 @ERR_GOST_error(i32 129, i32 111, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str.1, i64 0, i64 0), i32 528)
%36 = load i8*, i8** %10
%37 = call i32 @OPENSSL_free(i8* %36)
store i32 0, i32* %4
br label %47
38: ; preds = %29
%39 = load i32*, i32** %5
%40 = load i32, i32* @EVP_PKEY_CTRL_SET_MAC_KEY
%41 = load i8*, i8** %10
%42 = call i32 (i32*, i32, i32, ...) @pkey_gost_mac_ctrl(i32* %39, i32 %40, i32 32, i8* %41)
store i32 %42, i32* %9
%43 = load i8*, i8** %10
%44 = call i32 @OPENSSL_free(i8* %43)
%45 = load i32, i32* %9
store i32 %45, i32* %4
br label %47
46: ; preds = %25
store i32 -2, i32* %4
br label %47
47: ; preds = %46, %38, %34, %20, %18
%48 = load i32, i32* %4
ret i32 %48
}

LLVM IR (-O2):
@.str = [4 x i8] c"key\00"
@.str.1 = [201 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/caidongyun/nginx-openresty-windows/refs/heads/master/nginx/objs/lib/openssl-1.0.1g/engines/ccgost/gost_pmeth.c\00"
@EVP_PKEY_CTRL_SET_MAC_KEY = global i32 0
@.str.2 = [7 x i8] c"hexkey\00"
define i32 @pkey_gost_mac_ctrl_str(i32* %0, i8* nocapture %1, i8* %2) {
%4 = alloca i64
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %3
%8 = tail call i32 @strlen(i8* %2)
%9 = icmp eq i32 %8, 32
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @ERR_GOST_error(i32 129, i32 111, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str.1, i64 0, i64 0), i32 515)
br label %31
12: ; preds = %7
%13 = load i32, i32* @EVP_PKEY_CTRL_SET_MAC_KEY
%14 = tail call i32 (i32*, i32, i32, ...) @pkey_gost_mac_ctrl(i32* %0, i32 %13, i32 32, i8* %2)
br label %31
15: ; preds = %3
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %31
18: ; preds = %15
%19 = bitcast i64* %4 to i8*
%20 = call i8* @string_to_hex(i8* %2, i64* %4)
%21 = load i64, i64* %4
%22 = icmp eq i64 %21, 32
br i1 %22, label %25, label %23
23: ; preds = %18
%24 = call i32 @ERR_GOST_error(i32 129, i32 111, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str.1, i64 0, i64 0), i32 528)
br label %28
25: ; preds = %18
%26 = load i32, i32* @EVP_PKEY_CTRL_SET_MAC_KEY
%27 = call i32 (i32*, i32, i32, ...) @pkey_gost_mac_ctrl(i32* %0, i32 %26, i32 32, i8* %20)
br label %28
28: ; preds = %25, %23
%29 = phi i32 [ 0, %23 ], [ %27, %25 ]
%30 = call i32 @OPENSSL_free(i8* %20)
br label %31
31: ; preds = %15, %28, %12, %10
%32 = phi i32 [ %29, %28 ], [ 0, %10 ], [ %14, %12 ], [ -2, %15 ]
ret i32 %32
}