user: Converte this assembly snippet into its equivalent C code:

```asm
<sm2_ec_group>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  call   <EC_GFp_mont_method@plt>
  mov    %eax,%edi
  call   <EC_GROUP_new@plt>
  mov    %rax,%rbx
  mov    $0x0,%eax
  call   <BN_CTX_new@plt>
  mov    %rax,%rbp
  movq   $0x0,0x8(%rsp)
  movq   $0x0,0x10(%rsp)
  movq   $0x0,0x18(%rsp)
  lea    0x8(%rsp),%rdi
  lea    D58(%rip),%rsi
  call   <BN_hex2bn@plt>
  lea    0x10(%rsp),%rdi
  lea    D35(%rip),%rsi
  call   <BN_hex2bn@plt>
  lea    0x18(%rsp),%rdi
  lea    D33(%rip),%rsi
  call   <BN_hex2bn@plt>
  mov    %rbp,%r8
  mov    0x18(%rsp),%rcx
  mov    0x10(%rsp),%rdx
  mov    0x8(%rsp),%rsi
  mov    %rbx,%rdi
  call   <EC_GROUP_set_curve_GFp@plt>
  cmp    $0x1,%eax
  jne    L1
  movq   $0x0,0x20(%rsp)
  movq   $0x0,0x28(%rsp)
  movq   $0x0,0x30(%rsp)
  lea    0x20(%rsp),%rdi
  lea    D48(%rip),%rsi
  call   <BN_hex2bn@plt>
  lea    0x28(%rsp),%rdi
  lea    D34(%rip),%rsi
  call   <BN_hex2bn@plt>
  lea    0x30(%rsp),%rdi
  lea    D6(%rip),%rsi
  call   <BN_hex2bn@plt>
  mov    %rbx,%rdi
  call   <EC_POINT_new@plt>
  mov    %rax,%r12
  mov    %rbp,%r8
  mov    0x28(%rsp),%rcx
  mov    0x20(%rsp),%rdx
  mov    %rax,%rsi
  mov    %rbx,%rdi
  call   <EC_POINT_set_affine_coordinates_GFp@plt>
  mov    $0x0,%eax
  call   <BN_value_one@plt>
  mov    %eax,%ecx
  mov    0x30(%rsp),%rdx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <EC_GROUP_set_generator@plt>
  mov    0x8(%rsp),%rdi
  call   <BN_free@plt>
  mov    0x10(%rsp),%rdi
  call   <BN_free@plt>
  mov    0x18(%rsp),%rdi
  call   <BN_free@plt>
  mov    0x20(%rsp),%rdi
  call   <BN_free@plt>
  mov    0x28(%rsp),%rdi
  call   <BN_free@plt>
  mov    0x30(%rsp),%rdi
  call   <BN_free@plt>
  mov    %rbp,%rdi
  call   <BN_CTX_free@plt>
L2:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L29
  mov    %rbx,%rax
  add    $0x40,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L1:
  mov    $0x0,%ebx
  jmp    L2
L29:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D58
data_type: string
name: parse_data
arguments: label: D35
data_type: string
name: parse_data
arguments: label: D33
data_type: string
name: parse_data
arguments: label: D48
data_type: string
name: parse_data
arguments: label: D34
data_type: string
name: parse_data
arguments: label: D6
data_type: string

tool: D58: 8542D69E4C044F18E8B92435BF6FF7DE457283915C45517D722EDB8B08F1DFC3

tool: D35: 787968B4FA32C3FD2417842E73BBFEFF2F3C848B6831D7E0EC65228B3937E498

tool: D33: 63E4C6D3B23B0C849CF84241484BFE48F61D59A5B16BA06E6E12D1DA27C5249A

tool: D48: 421DEBD61B62EAB6746434EBC3CC315E32220B3BADD50BDC4C4E6C147FEDD43D

tool: D34: 0680512BCBB42C07D47349D2153B70C4E5D7FDFCBFA36EA1A85841B9E46E09A2

tool: D6: 8542D69E4C044F18E8B92435BF6FF7DD297720630485628D5AE74EE7C32E79B7

assistant: ```c
EC_GROUP *sm2_ec_group() {
  EC_GROUP *ecg = EC_GROUP_new(EC_GFp_mont_method());
  BN_CTX *ctx = BN_CTX_new();
  BIGNUM *p = NULL, *a = NULL, *b = NULL;
  BN_hex2bn(&p, "8542D69E4C044F18E8B92435BF6FF7DE457283915C45517D722EDB8B08F1DFC3");
  BN_hex2bn(&a, "787968B4FA32C3FD2417842E73BBFEFF2F3C848B6831D7E0EC65228B3937E498");
  BN_hex2bn(&b, "63E4C6D3B23B0C849CF84241484BFE48F61D59A5B16BA06E6E12D1DA27C5249A");
  if (EC_GROUP_set_curve_GFp(ecg, p, a, b, ctx) != 1)
    return 0;
  ;
  BIGNUM *Gx = NULL, *Gy = NULL, *N = NULL;
  BN_hex2bn(&Gx, "421DEBD61B62EAB6746434EBC3CC315E32220B3BADD50BDC4C4E6C147FEDD43D");
  BN_hex2bn(&Gy, "0680512BCBB42C07D47349D2153B70C4E5D7FDFCBFA36EA1A85841B9E46E09A2");
  BN_hex2bn(&N, "8542D69E4C044F18E8B92435BF6FF7DD297720630485628D5AE74EE7C32E79B7");
  EC_POINT *generator = EC_POINT_new(ecg);
  EC_POINT_set_affine_coordinates_GFp(ecg, generator, Gx, Gy, ctx);
  EC_GROUP_set_generator(ecg, generator, N, BN_value_one());
  BN_free(p);
  BN_free(a);
  BN_free(b);
  BN_free(Gx);
  BN_free(Gy);
  BN_free(N);
  BN_CTX_free(ctx);
  return ecg;
}
```