#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 uint8_t;
typedef int /*<<< orphan*/ signature;
typedef int /*<<< orphan*/ EVP_PKEY_CTX;
typedef int /*<<< orphan*/ EVP_PKEY;
typedef int /*<<< orphan*/ EVP_MD_CTX;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_mem_buf(char const *, int /*<<< orphan*/);
scalar_t__ EVP_DigestVerifyFinal(int /*<<< orphan*/ *, int const *, int);
scalar_t__ EVP_DigestVerifyInit(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                int /*<<< orphan*/, int /*<<< orphan*/ *,
                                int /*<<< orphan*/ *);
scalar_t__ EVP_DigestVerifyUpdate(int /*<<< orphan*/ *, char const *,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ EVP_MD_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EVP_MD_CTX_new();
int /*<<< orphan*/ EVP_MD_CTX_set_pkey_ctx(int /*<<< orphan*/ *,
                                           int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_PKEY_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EVP_PKEY_CTX_new(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_PKEY_CTX_set1_id(int /*<<< orphan*/ *, int const *,
                                        int /*<<< orphan*/);
int /*<<< orphan*/ EVP_PKEY_SM2;
int /*<<< orphan*/ EVP_PKEY_free(int /*<<< orphan*/ *);
scalar_t__ EVP_PKEY_set_alias_type(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ EVP_sm3();
int /*<<< orphan*/ *PEM_read_bio_PUBKEY(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ test_int_gt(char *, int, char *, char *, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int /*<<< orphan*/ test_ptr(char *, int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ test_true(char *, int, char *, int);
int test_EVP_SM2_verify(void) {
  const char *pubkey =
      "-----BEGIN PUBLIC KEY-----\n"
      "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEAhULWnkwETxjouSQ1\n"
      "v2/33kVyg5FcRVF9ci7biwjx38MwRAQgeHlotPoyw/0kF4Quc7v+/y88hItoMdfg\n"
      "7GUiizk35JgEIGPkxtOyOwyEnPhCQUhL/kj2HVmlsWugbm4S0donxSSaBEEEQh3r\n"
      "1hti6rZ0ZDTrw8wxXjIiCzut1QvcTE5sFH/t1D0GgFEry7QsB9RzSdIVO3DE5df9\n"
      "/L+jbqGoWEG55G4JogIhAIVC1p5MBE8Y6LkkNb9v990pdyBjBIVijVrnTufDLnm3\n"
      "AgEBA0IABArkx3mKoPEZRxvuEYJb5GICu3nipYRElel8BP9N8lSKfAJA+I8c1OFj\n"
      "Uqc8F7fxbwc1PlOhdtaEqf4Ma7eY6Fc=\n"
      "-----END PUBLIC KEY-----\n";
  const char *msg = "message digest";
  const char *id = "ALICE123@YAHOO.COM";
  const uint8_t signature[] = {
      0x30, 0x44, 0x02, 0x20, 0x40, 0xF1, 0xEC, 0x59, 0xF7, 0x93, 0xD9, 0xF4,
      0x9E, 0x09, 0xDC, 0xEF, 0x49, 0x13, 0x0D, 0x41, 0x94, 0xF7, 0x9F, 0xB1,
      0xEE, 0xD2, 0xCA, 0xA5, 0x5B, 0xAC, 0xDB, 0x49, 0xC4, 0xE7, 0x55, 0xD1,
      0x02, 0x20, 0x6F, 0xC6, 0xDA, 0xC3, 0x2C, 0x5D, 0x5C, 0xF1, 0x0C, 0x77,
      0xDF, 0xB2, 0x0F, 0x7C, 0x2E, 0xB6, 0x67, 0xA4, 0x57, 0x87, 0x2F, 0xB0,
      0x9E, 0xC5, 0x63, 0x27, 0xA6, 0x7E, 0xC7, 0xDE, 0xEB, 0xE7};
  int rc = 0;
  BIO *bio = NULL;
  EVP_PKEY *pkey = NULL;
  EVP_MD_CTX *mctx = NULL;
  EVP_PKEY_CTX *pctx = NULL;
  bio = BIO_new_mem_buf(pubkey, strlen(pubkey));
  if (!test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          640, "bio != NULL", (bio != NULL) != 0))
    goto done;
  pkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL);
  if (!test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          644, "pkey != NULL", (pkey != NULL) != 0))
    goto done;
  if (!test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          647, "EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2)",
          (EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2)) != 0))
    goto done;
  if (!test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/"
                "refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
                650, "mctx = EVP_MD_CTX_new()", mctx = EVP_MD_CTX_new()))
    goto done;
  if (!test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/"
                "refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
                653, "pctx = EVP_PKEY_CTX_new(pkey, NULL)",
                pctx = EVP_PKEY_CTX_new(pkey, NULL)))
    goto done;
  if (!test_int_gt(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          656, "EVP_PKEY_CTX_set1_id(pctx, (const uint8_t *)id, strlen(id))",
          "0", EVP_PKEY_CTX_set1_id(pctx, (const uint8_t *)id, strlen(id)), 0))
    goto done;
  EVP_MD_CTX_set_pkey_ctx(mctx, pctx);
  if (!test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          662, "EVP_DigestVerifyInit(mctx, NULL, EVP_sm3(), NULL, pkey)",
          (EVP_DigestVerifyInit(mctx, NULL, EVP_sm3(), NULL, pkey)) != 0))
    goto done;
  if (!test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          665, "EVP_DigestVerifyUpdate(mctx, msg, strlen(msg))",
          (EVP_DigestVerifyUpdate(mctx, msg, strlen(msg))) != 0))
    goto done;
  if (!test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          668, "EVP_DigestVerifyFinal(mctx, signature, sizeof(signature))",
          (EVP_DigestVerifyFinal(mctx, signature, sizeof(signature))) != 0))
    goto done;
  rc = 1;
done:
  BIO_free(bio);
  EVP_PKEY_free(pkey);
  EVP_PKEY_CTX_free(pctx);
  EVP_MD_CTX_free(mctx);
  return rc;
}


x86 assembly (clang, -O0):
<test_EVP_SM2_verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
lea    0xdae(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xf7f(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xf83(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x130(%rbp),%rdi
lea    0x1196(%rip),%rsi
mov    $0x118,%edx
call   10e0 <memcpy@plt>
movl   $0x0,-0x134(%rbp)
movq   $0x0,-0x140(%rbp)
movq   $0x0,-0x148(%rbp)
movq   $0x0,-0x150(%rbp)
movq   $0x0,-0x158(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x160(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x160(%rbp),%rdi
mov    %eax,%esi
call   10f0 <BIO_new_mem_buf@plt>
mov    %rax,-0x140(%rbp)
cmpq   $0x0,-0x140(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xef9(%rip),%rdi
mov    $0x280,%esi
lea    0xf9f(%rip),%rdx
call   1040 <test_true@plt>
cmp    $0x0,%eax
jne    1324 <test_EVP_SM2_verify+0xe4>
jmp    15dd <test_EVP_SM2_verify+0x39d>
mov    -0x140(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1090 <PEM_read_bio_PUBKEY@plt>
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x148(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xe9b(%rip),%rdi
mov    $0x284,%esi
lea    0xf4d(%rip),%rdx
call   1040 <test_true@plt>
cmp    $0x0,%eax
jne    1382 <test_EVP_SM2_verify+0x142>
jmp    15dd <test_EVP_SM2_verify+0x39d>
mov    -0x148(%rbp),%rdi
mov    0x2c50(%rip),%rax
mov    (%rax),%esi
call   1160 <EVP_PKEY_set_alias_type@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xe54(%rip),%rdi
mov    $0x287,%esi
lea    0xf13(%rip),%rdx
call   1040 <test_true@plt>
cmp    $0x0,%eax
jne    13c9 <test_EVP_SM2_verify+0x189>
jmp    15dd <test_EVP_SM2_verify+0x39d>
mov    $0x0,%al
call   1110 <EVP_MD_CTX_new@plt>
mov    %rax,%rcx
mov    %rcx,-0x150(%rbp)
lea    0xe1d(%rip),%rdi
mov    $0x28a,%esi
lea    0xf08(%rip),%rdx
call   10b0 <test_ptr@plt>
cmp    $0x0,%eax
jne    1400 <test_EVP_SM2_verify+0x1c0>
jmp    15dd <test_EVP_SM2_verify+0x39d>
mov    -0x148(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <EVP_PKEY_CTX_new@plt>
mov    %rax,%rcx
mov    %rcx,-0x158(%rbp)
lea    0xddd(%rip),%rdi
mov    $0x28d,%esi
lea    0xee0(%rip),%rdx
call   10b0 <test_ptr@plt>
cmp    $0x0,%eax
jne    1440 <test_EVP_SM2_verify+0x200>
jmp    15dd <test_EVP_SM2_verify+0x39d>
mov    -0x158(%rbp),%rax
mov    %rax,-0x170(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x168(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x170(%rbp),%rdi
mov    -0x168(%rbp),%rsi
mov    %eax,%edx
call   1070 <EVP_PKEY_CTX_set1_id@plt>
mov    %eax,%r8d
lea    0xd7d(%rip),%rdi
mov    $0x290,%esi
lea    0xea4(%rip),%rdx
lea    0xed9(%rip),%rcx
xor    %r9d,%r9d
call   1060 <test_int_gt@plt>
cmp    $0x0,%eax
jne    14aa <test_EVP_SM2_verify+0x26a>
jmp    15dd <test_EVP_SM2_verify+0x39d>
mov    -0x150(%rbp),%rdi
mov    -0x158(%rbp),%rsi
call   10c0 <EVP_MD_CTX_set_pkey_ctx@plt>
mov    -0x150(%rbp),%rax
mov    %rax,-0x178(%rbp)
mov    $0x0,%al
call   1120 <EVP_sm3@plt>
mov    -0x178(%rbp),%rdi
mov    %eax,%edx
mov    -0x148(%rbp),%r8
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
call   10d0 <EVP_DigestVerifyInit@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xcfd(%rip),%rdi
mov    $0x296,%esi
lea    0xe62(%rip),%rdx
call   1040 <test_true@plt>
cmp    $0x0,%eax
jne    1520 <test_EVP_SM2_verify+0x2e0>
jmp    15dd <test_EVP_SM2_verify+0x39d>
mov    -0x150(%rbp),%rax
mov    %rax,-0x188(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x180(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x188(%rbp),%rdi
mov    -0x180(%rbp),%rsi
mov    %eax,%edx
call   1130 <EVP_DigestVerifyUpdate@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xc94(%rip),%rdi
mov    $0x299,%esi
lea    0xe31(%rip),%rdx
call   1040 <test_true@plt>
cmp    $0x0,%eax
jne    1589 <test_EVP_SM2_verify+0x349>
jmp    15dd <test_EVP_SM2_verify+0x39d>
mov    -0x150(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    $0x118,%edx
call   1140 <EVP_DigestVerifyFinal@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xc4a(%rip),%rdi
mov    $0x29c,%esi
lea    0xe16(%rip),%rdx
call   1040 <test_true@plt>
cmp    $0x0,%eax
jne    15d3 <test_EVP_SM2_verify+0x393>
jmp    15dd <test_EVP_SM2_verify+0x39d>
movl   $0x1,-0x134(%rbp)
mov    -0x140(%rbp),%rdi
call   1100 <BIO_free@plt>
mov    -0x148(%rbp),%rdi
call   10a0 <EVP_PKEY_free@plt>
mov    -0x158(%rbp),%rdi
call   1150 <EVP_PKEY_CTX_free@plt>
mov    -0x150(%rbp),%rdi
call   1050 <EVP_MD_CTX_free@plt>
mov    -0x134(%rbp),%eax
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_EVP_SM2_verify>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
lea    0x11b8(%rip),%rsi
mov    %rsp,%rdi
mov    $0x118,%edx
call   10e0 <memcpy@plt>
lea    0xd94(%rip),%rbx
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   10f0 <BIO_new_mem_buf@plt>
mov    %rax,%r12
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xf6e(%rip),%rdi
lea    0x1019(%rip),%rdx
mov    $0x280,%esi
call   1040 <test_true@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     148f <test_EVP_SM2_verify+0x24f>
mov    %r12,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1090 <PEM_read_bio_PUBKEY@plt>
mov    %rax,%r14
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xf33(%rip),%rdi
lea    0xfea(%rip),%rdx
mov    $0x284,%esi
call   1040 <test_true@plt>
test   %eax,%eax
je     1492 <test_EVP_SM2_verify+0x252>
mov    0x2cf5(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1160 <EVP_PKEY_set_alias_type@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xefa(%rip),%rdi
lea    0xfbe(%rip),%rdx
mov    $0x287,%esi
call   1040 <test_true@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1492 <test_EVP_SM2_verify+0x252>
xor    %eax,%eax
call   1110 <EVP_MD_CTX_new@plt>
mov    %rax,%r15
lea    0xece(%rip),%rdi
lea    0xfbe(%rip),%rdx
mov    $0x28a,%esi
mov    %rax,%rcx
call   10b0 <test_ptr@plt>
test   %eax,%eax
je     1495 <test_EVP_SM2_verify+0x255>
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <EVP_PKEY_CTX_new@plt>
mov    %rax,%r13
lea    0xe9c(%rip),%rdi
lea    0xfa4(%rip),%rdx
mov    $0x28d,%esi
mov    %rax,%rcx
call   10b0 <test_ptr@plt>
test   %eax,%eax
je     1498 <test_EVP_SM2_verify+0x258>
lea    0xe66(%rip),%rbx
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <EVP_PKEY_CTX_set1_id@plt>
lea    0xe5d(%rip),%rdi
lea    0xf89(%rip),%rdx
lea    0xfbe(%rip),%rcx
xor    %ebx,%ebx
mov    $0x290,%esi
mov    %eax,%r8d
xor    %r9d,%r9d
call   1060 <test_int_gt@plt>
test   %eax,%eax
je     1498 <test_EVP_SM2_verify+0x258>
mov    %r15,%rdi
mov    %r13,%rsi
call   10c0 <EVP_MD_CTX_set_pkey_ctx@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1120 <EVP_sm3@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    %eax,%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   10d0 <EVP_DigestVerifyInit@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xe01(%rip),%rdi
lea    0xf6b(%rip),%rdx
mov    $0x296,%esi
call   1040 <test_true@plt>
test   %eax,%eax
je     1498 <test_EVP_SM2_verify+0x258>
lea    0xdbf(%rip),%rbp
mov    %rbp,%rdi
call   1080 <strlen@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1130 <EVP_DigestVerifyUpdate@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xdbd(%rip),%rdi
lea    0xf5f(%rip),%rdx
mov    $0x299,%esi
call   1040 <test_true@plt>
test   %eax,%eax
je     1498 <test_EVP_SM2_verify+0x258>
mov    %rsp,%rsi
mov    %r15,%rdi
mov    $0x118,%edx
call   1140 <EVP_DigestVerifyFinal@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xd89(%rip),%rdi
lea    0xf5a(%rip),%rdx
mov    $0x29c,%esi
call   1040 <test_true@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
jmp    1498 <test_EVP_SM2_verify+0x258>
xor    %r14d,%r14d
xor    %r15d,%r15d
xor    %r13d,%r13d
mov    %r12,%rdi
call   1100 <BIO_free@plt>
mov    %r14,%rdi
call   10a0 <EVP_PKEY_free@plt>
mov    %r13,%rdi
call   1150 <EVP_PKEY_CTX_free@plt>
mov    %r15,%rdi
call   1050 <EVP_MD_CTX_free@plt>
mov    %ebx,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [476 x i8] c"-----BEGIN PUBLIC KEY-----\0AMIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEAhULWnkwETxjouSQ1\0Av2/33kVyg5FcRVF9ci7biwjx38MwRAQgeHlotPoyw/0kF4Quc7v+/y88hItoMdfg\0A7GUiizk35JgEIGPkxtOyOwyEnPhCQUhL/kj2HVmlsWugbm4S0donxSSaBEEEQh3r\0A1hti6rZ0ZDTrw8wxXjIiCzut1QvcTE5sFH/t1D0GgFEry7QsB9RzSdIVO3DE5df9\0A/L+jbqGoWEG55G4JogIhAIVC1p5MBE8Y6LkkNb9v990pdyBjBIVijVrnTufDLnm3\0AAgEBA0IABArkx3mKoPEZRxvuEYJb5GICu3nipYRElel8BP9N8lSKfAJA+I8c1OFj\0AUqc8F7fxbwc1PlOhdtaEqf4Ma7eY6Fc=\0A-----END PUBLIC KEY-----\0A\00"
@.str.1 = [15 x i8] c"message digest\00"
@.str.2 = [19 x i8] c"ALICE123@YAHOO.COM\00"
@__const.test_EVP_SM2_verify.signature = [70 x i32] [i32 48, i32 68, i32 2, i32 32, i32 64, i32 241, i32 236, i32 89, i32 247, i32 147, i32 217, i32 244, i32 158, i32 9, i32 220, i32 239, i32 73, i32 19, i32 13, i32 65, i32 148, i32 247, i32 159, i32 177, i32 238, i32 210, i32 202, i32 165, i32 91, i32 172, i32 219, i32 73, i32 196, i32 231, i32 85, i32 209, i32 2, i32 32, i32 111, i32 198, i32 218, i32 195, i32 44, i32 93, i32 92, i32 241, i32 12, i32 119, i32 223, i32 178, i32 15, i32 124, i32 46, i32 182, i32 103, i32 164, i32 87, i32 135, i32 47, i32 176, i32 158, i32 197, i32 99, i32 39, i32 166, i32 126, i32 199, i32 222, i32 235, i32 231]
@.str.3 = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c\00"
@.str.4 = [12 x i8] c"bio != NULL\00"
@.str.5 = [13 x i8] c"pkey != NULL\00"
@.str.6 = [44 x i8] c"EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2)\00"
@EVP_PKEY_SM2 = global i32 0
@.str.7 = [24 x i8] c"mctx = EVP_MD_CTX_new()\00"
@.str.8 = [36 x i8] c"pctx = EVP_PKEY_CTX_new(pkey, NULL)\00"
@.str.9 = [60 x i8] c"EVP_PKEY_CTX_set1_id(pctx, (const uint8_t *)id, strlen(id))\00"
@.str.10 = [2 x i8] c"0\00"
@.str.11 = [56 x i8] c"EVP_DigestVerifyInit(mctx, NULL, EVP_sm3(), NULL, pkey)\00"
@.str.12 = [47 x i8] c"EVP_DigestVerifyUpdate(mctx, msg, strlen(msg))\00"
@.str.13 = [58 x i8] c"EVP_DigestVerifyFinal(mctx, signature, sizeof(signature))\00"
define i32 @test_EVP_SM2_verify() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [70 x i32]
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
store i8* getelementptr inbounds ([476 x i8], [476 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8** %3
%10 = bitcast [70 x i32]* %4 to i8*
store i32 0, i32* %5
store i32* null, i32** %6
store i32* null, i32** %7
store i32* null, i32** %8
store i32* null, i32** %9
%11 = load i8*, i8** %1
%12 = load i8*, i8** %1
%13 = call i32 @strlen(i8* %12)
%14 = call i32* @BIO_new_mem_buf(i8* %11, i32 %13)
store i32* %14, i32** %6
%15 = load i32*, i32** %6
%16 = icmp ne i32* %15, null
%17 = zext i1 %16 to i32
%18 = icmp ne i32 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 640, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %0
br label %98
23: ; preds = %0
%24 = load i32*, i32** %6
%25 = call i32* @PEM_read_bio_PUBKEY(i32* %24, i32* null, i32* null, i32* null)
store i32* %25, i32** %7
%26 = load i32*, i32** %7
%27 = icmp ne i32* %26, null
%28 = zext i1 %27 to i32
%29 = icmp ne i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 644, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %23
br label %98
34: ; preds = %23
%35 = load i32*, i32** %7
%36 = load i32, i32* @EVP_PKEY_SM2
%37 = call i64 @EVP_PKEY_set_alias_type(i32* %35, i32 %36)
%38 = icmp ne i64 %37, 0
%39 = zext i1 %38 to i32
%40 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 647, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %34
br label %98
43: ; preds = %34
%44 = call i32* (...) @EVP_MD_CTX_new()
store i32* %44, i32** %8
%45 = call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 650, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32* %44)
%46 = icmp ne i32 %45, 0
br i1 %46, label %48, label %47
47: ; preds = %43
br label %98
48: ; preds = %43
%49 = load i32*, i32** %7
%50 = call i32* @EVP_PKEY_CTX_new(i32* %49, i32* null)
store i32* %50, i32** %9
%51 = call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 653, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i32* %50)
%52 = icmp ne i32 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %48
br label %98
54: ; preds = %48
%55 = load i32*, i32** %9
%56 = load i8*, i8** %3
%57 = bitcast i8* %56 to i32*
%58 = load i8*, i8** %3
%59 = call i32 @strlen(i8* %58)
%60 = call i32 @EVP_PKEY_CTX_set1_id(i32* %55, i32* %57, i32 %59)
%61 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 656, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 %60, i32 0)
%62 = icmp ne i32 %61, 0
br i1 %62, label %64, label %63
63: ; preds = %54
br label %98
64: ; preds = %54
%65 = load i32*, i32** %8
%66 = load i32*, i32** %9
%67 = call i32 @EVP_MD_CTX_set_pkey_ctx(i32* %65, i32* %66)
%68 = load i32*, i32** %8
%69 = call i32 (...) @EVP_sm3()
%70 = load i32*, i32** %7
%71 = call i64 @EVP_DigestVerifyInit(i32* %68, i32* null, i32 %69, i32* null, i32* %70)
%72 = icmp ne i64 %71, 0
%73 = zext i1 %72 to i32
%74 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 662, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.11, i64 0, i64 0), i32 %73)
%75 = icmp ne i32 %74, 0
br i1 %75, label %77, label %76
76: ; preds = %64
br label %98
77: ; preds = %64
%78 = load i32*, i32** %8
%79 = load i8*, i8** %2
%80 = load i8*, i8** %2
%81 = call i32 @strlen(i8* %80)
%82 = call i64 @EVP_DigestVerifyUpdate(i32* %78, i8* %79, i32 %81)
%83 = icmp ne i64 %82, 0
%84 = zext i1 %83 to i32
%85 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 665, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.12, i64 0, i64 0), i32 %84)
%86 = icmp ne i32 %85, 0
br i1 %86, label %88, label %87
87: ; preds = %77
br label %98
88: ; preds = %77
%89 = load i32*, i32** %8
%90 = getelementptr inbounds [70 x i32], [70 x i32]* %4, i64 0, i64 0
%91 = call i64 @EVP_DigestVerifyFinal(i32* %89, i32* %90, i32 280)
%92 = icmp ne i64 %91, 0
%93 = zext i1 %92 to i32
%94 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 668, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.13, i64 0, i64 0), i32 %93)
%95 = icmp ne i32 %94, 0
br i1 %95, label %97, label %96
96: ; preds = %88
br label %98
97: ; preds = %88
store i32 1, i32* %5
br label %98
98: ; preds = %97, %96, %87, %76, %63, %53, %47, %42, %33, %22
%99 = load i32*, i32** %6
%100 = call i32 @BIO_free(i32* %99)
%101 = load i32*, i32** %7
%102 = call i32 @EVP_PKEY_free(i32* %101)
%103 = load i32*, i32** %9
%104 = call i32 @EVP_PKEY_CTX_free(i32* %103)
%105 = load i32*, i32** %8
%106 = call i32 @EVP_MD_CTX_free(i32* %105)
%107 = load i32, i32* %5
ret i32 %107
}

LLVM IR (-O2):
@.str = [476 x i8] c"-----BEGIN PUBLIC KEY-----\0AMIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEAhULWnkwETxjouSQ1\0Av2/33kVyg5FcRVF9ci7biwjx38MwRAQgeHlotPoyw/0kF4Quc7v+/y88hItoMdfg\0A7GUiizk35JgEIGPkxtOyOwyEnPhCQUhL/kj2HVmlsWugbm4S0donxSSaBEEEQh3r\0A1hti6rZ0ZDTrw8wxXjIiCzut1QvcTE5sFH/t1D0GgFEry7QsB9RzSdIVO3DE5df9\0A/L+jbqGoWEG55G4JogIhAIVC1p5MBE8Y6LkkNb9v990pdyBjBIVijVrnTufDLnm3\0AAgEBA0IABArkx3mKoPEZRxvuEYJb5GICu3nipYRElel8BP9N8lSKfAJA+I8c1OFj\0AUqc8F7fxbwc1PlOhdtaEqf4Ma7eY6Fc=\0A-----END PUBLIC KEY-----\0A\00"
@.str.1 = [15 x i8] c"message digest\00"
@.str.2 = [19 x i8] c"ALICE123@YAHOO.COM\00"
@__const.test_EVP_SM2_verify.signature = [70 x i32] [i32 48, i32 68, i32 2, i32 32, i32 64, i32 241, i32 236, i32 89, i32 247, i32 147, i32 217, i32 244, i32 158, i32 9, i32 220, i32 239, i32 73, i32 19, i32 13, i32 65, i32 148, i32 247, i32 159, i32 177, i32 238, i32 210, i32 202, i32 165, i32 91, i32 172, i32 219, i32 73, i32 196, i32 231, i32 85, i32 209, i32 2, i32 32, i32 111, i32 198, i32 218, i32 195, i32 44, i32 93, i32 92, i32 241, i32 12, i32 119, i32 223, i32 178, i32 15, i32 124, i32 46, i32 182, i32 103, i32 164, i32 87, i32 135, i32 47, i32 176, i32 158, i32 197, i32 99, i32 39, i32 166, i32 126, i32 199, i32 222, i32 235, i32 231]
@.str.3 = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c\00"
@.str.4 = [12 x i8] c"bio != NULL\00"
@.str.5 = [13 x i8] c"pkey != NULL\00"
@.str.6 = [44 x i8] c"EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2)\00"
@EVP_PKEY_SM2 = global i32 0
@.str.7 = [24 x i8] c"mctx = EVP_MD_CTX_new()\00"
@.str.8 = [36 x i8] c"pctx = EVP_PKEY_CTX_new(pkey, NULL)\00"
@.str.9 = [60 x i8] c"EVP_PKEY_CTX_set1_id(pctx, (const uint8_t *)id, strlen(id))\00"
@.str.10 = [2 x i8] c"0\00"
@.str.11 = [56 x i8] c"EVP_DigestVerifyInit(mctx, NULL, EVP_sm3(), NULL, pkey)\00"
@.str.12 = [47 x i8] c"EVP_DigestVerifyUpdate(mctx, msg, strlen(msg))\00"
@.str.13 = [58 x i8] c"EVP_DigestVerifyFinal(mctx, signature, sizeof(signature))\00"
define i32 @test_EVP_SM2_verify() {
%1 = alloca [70 x i32]
%2 = bitcast [70 x i32]* %1 to i8*
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([476 x i8], [476 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32* @BIO_new_mem_buf(i8* getelementptr inbounds ([476 x i8], [476 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp ne i32* %4, null
%6 = zext i1 %5 to i32
%7 = tail call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 640, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %58, label %9
9: ; preds = %0
%10 = tail call i32* @PEM_read_bio_PUBKEY(i32* %4, i32* null, i32* null, i32* null)
%11 = icmp ne i32* %10, null
%12 = zext i1 %11 to i32
%13 = tail call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 644, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %58, label %15
15: ; preds = %9
%16 = load i32, i32* @EVP_PKEY_SM2
%17 = tail call i64 @EVP_PKEY_set_alias_type(i32* %10, i32 %16)
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 647, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i32 %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %58, label %22
22: ; preds = %15
%23 = tail call i32* (...) @EVP_MD_CTX_new()
%24 = tail call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 650, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32* %23)
%25 = icmp eq i32 %24, 0
br i1 %25, label %58, label %26
26: ; preds = %22
%27 = tail call i32* @EVP_PKEY_CTX_new(i32* %10, i32* null)
%28 = tail call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 653, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i32* %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %58, label %30
30: ; preds = %26
%31 = tail call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%32 = tail call i32 @EVP_PKEY_CTX_set1_id(i32* %27, i32* bitcast ([19 x i8]* @.str.2 to i32*), i32 %31)
%33 = tail call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 656, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32 %32, i32 0)
%34 = icmp eq i32 %33, 0
br i1 %34, label %58, label %35
35: ; preds = %30
%36 = tail call i32 @EVP_MD_CTX_set_pkey_ctx(i32* %23, i32* %27)
%37 = tail call i32 (...) @EVP_sm3()
%38 = tail call i64 @EVP_DigestVerifyInit(i32* %23, i32* null, i32 %37, i32* null, i32* %10)
%39 = icmp ne i64 %38, 0
%40 = zext i1 %39 to i32
%41 = tail call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 662, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.11, i64 0, i64 0), i32 %40)
%42 = icmp eq i32 %41, 0
br i1 %42, label %58, label %43
43: ; preds = %35
%44 = tail call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%45 = tail call i64 @EVP_DigestVerifyUpdate(i32* %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = icmp ne i64 %45, 0
%47 = zext i1 %46 to i32
%48 = tail call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 665, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.12, i64 0, i64 0), i32 %47)
%49 = icmp eq i32 %48, 0
br i1 %49, label %58, label %50
50: ; preds = %43
%51 = getelementptr inbounds [70 x i32], [70 x i32]* %1, i64 0, i64 0
%52 = call i64 @EVP_DigestVerifyFinal(i32* %23, i32* %51, i32 280)
%53 = icmp ne i64 %52, 0
%54 = zext i1 %53 to i32
%55 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.3, i64 0, i64 0), i32 668, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.13, i64 0, i64 0), i32 %54)
%56 = icmp ne i32 %55, 0
%57 = zext i1 %56 to i32
br label %58
58: ; preds = %50, %43, %35, %30, %26, %22, %15, %9, %0
%59 = phi i32 [ 0, %43 ], [ 0, %35 ], [ 0, %30 ], [ 0, %26 ], [ 0, %22 ], [ 0, %15 ], [ 0, %9 ], [ 0, %0 ], [ %57, %50 ]
%60 = phi i32* [ %10, %43 ], [ %10, %35 ], [ %10, %30 ], [ %10, %26 ], [ %10, %22 ], [ %10, %15 ], [ %10, %9 ], [ null, %0 ], [ %10, %50 ]
%61 = phi i32* [ %23, %43 ], [ %23, %35 ], [ %23, %30 ], [ %23, %26 ], [ %23, %22 ], [ null, %15 ], [ null, %9 ], [ null, %0 ], [ %23, %50 ]
%62 = phi i32* [ %27, %43 ], [ %27, %35 ], [ %27, %30 ], [ %27, %26 ], [ null, %22 ], [ null, %15 ], [ null, %9 ], [ null, %0 ], [ %27, %50 ]
%63 = call i32 @BIO_free(i32* %4)
%64 = call i32 @EVP_PKEY_free(i32* %60)
%65 = call i32 @EVP_PKEY_CTX_free(i32* %62)
%66 = call i32 @EVP_MD_CTX_free(i32* %61)
ret i32 %59
}