#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ rand_tmp;
struct TYPE_3__ {
  int /*<<< orphan*/ *N;
  int /*<<< orphan*/ *g;
};
typedef TYPE_1__ SRP_gN;
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ *BN_bin2bn(unsigned char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_clear_free(int /*<<< orphan*/ *);
scalar_t__ BN_cmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ RAND_pseudo_bytes(unsigned char *, int);
int /*<<< orphan*/ *SRP_Calc_A(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ *SRP_Calc_B(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *
SRP_Calc_client_key(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *SRP_Calc_server_key(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ *SRP_Calc_u(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ *SRP_Calc_x(int /*<<< orphan*/ *, char const *,
                               char const *);
int /*<<< orphan*/ SRP_Verify_A_mod_N(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ SRP_Verify_B_mod_N(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ SRP_create_verifier_BN(char const *, char const *,
                                          int /*<<< orphan*/ **,
                                          int /*<<< orphan*/ **,
                                          int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *);
TYPE_1__ *SRP_get_default_gN(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ showbn(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int run_srp(const char *username, const char *client_pass,
            const char *server_pass) {
  int ret = -1;
  BIGNUM *s = NULL;
  BIGNUM *v = NULL;
  BIGNUM *a = NULL;
  BIGNUM *b = NULL;
  BIGNUM *u = NULL;
  BIGNUM *x = NULL;
  BIGNUM *Apub = NULL;
  BIGNUM *Bpub = NULL;
  BIGNUM *Kclient = NULL;
  BIGNUM *Kserver = NULL;
  unsigned char rand_tmp[32];
  SRP_gN *GN = SRP_get_default_gN("1024");
  if (GN == NULL) {
    fprintf(stderr, "Failed to get SRP parameters\n");
    return -1;
  }
  if (!SRP_create_verifier_BN(username, server_pass, &s, &v, GN->N, GN->g)) {
    fprintf(stderr, "Failed to create SRP verifier\n");
    return -1;
  }
  showbn("N", GN->N);
  showbn("g", GN->g);
  showbn("Salt", s);
  showbn("Verifier", v);
  RAND_pseudo_bytes(rand_tmp, sizeof(rand_tmp));
  b = BN_bin2bn(rand_tmp, sizeof(rand_tmp), NULL);
  showbn("b", b);
  Bpub = SRP_Calc_B(b, GN->N, GN->g, v);
  showbn("B", Bpub);
  if (!SRP_Verify_B_mod_N(Bpub, GN->N)) {
    fprintf(stderr, "Invalid B\n");
    return -1;
  }
  RAND_pseudo_bytes(rand_tmp, sizeof(rand_tmp));
  a = BN_bin2bn(rand_tmp, sizeof(rand_tmp), NULL);
  showbn("a", a);
  Apub = SRP_Calc_A(a, GN->N, GN->g);
  showbn("A", Apub);
  if (!SRP_Verify_A_mod_N(Apub, GN->N)) {
    fprintf(stderr, "Invalid A\n");
    return -1;
  }
  u = SRP_Calc_u(Apub, Bpub, GN->N);
  x = SRP_Calc_x(s, username, client_pass);
  Kclient = SRP_Calc_client_key(GN->N, Bpub, GN->g, x, a, u);
  showbn("Client's key", Kclient);
  Kserver = SRP_Calc_server_key(Apub, v, u, b, GN->N);
  showbn("Server's key", Kserver);
  if (BN_cmp(Kclient, Kserver) == 0) {
    ret = 0;
  } else {
    fprintf(stderr, "Keys mismatch\n");
    ret = 1;
  }
  BN_clear_free(Kclient);
  BN_clear_free(Kserver);
  BN_clear_free(x);
  BN_free(u);
  BN_free(Apub);
  BN_clear_free(a);
  BN_free(Bpub);
  BN_clear_free(b);
  BN_free(s);
  BN_clear_free(v);
  return ret;
}


x86 assembly (clang, -O0):
<run_srp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
lea    0xd7b(%rip),%rdi
call   10d0 <SRP_get_default_gN@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
jne    12c0 <run_srp+0xb0>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
lea    0xd56(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15f7 <run_srp+0x3e7>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0xa8(%rbp),%rax
mov    (%rax),%r8
mov    -0xa8(%rbp),%rax
mov    0x8(%rax),%r9
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   1050 <SRP_create_verifier_BN@plt>
cmp    $0x0,%eax
jne    1314 <run_srp+0x104>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
lea    0xd20(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15f7 <run_srp+0x3e7>
mov    -0xa8(%rbp),%rax
mov    (%rax),%rsi
lea    0xd1d(%rip),%rdi
call   1100 <showbn@plt>
mov    -0xa8(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd08(%rip),%rdi
call   1100 <showbn@plt>
mov    -0x30(%rbp),%rsi
lea    0xcfa(%rip),%rdi
call   1100 <showbn@plt>
mov    -0x38(%rbp),%rsi
lea    0xcef(%rip),%rdi
call   1100 <showbn@plt>
lea    -0xa0(%rbp),%rdi
mov    $0x20,%esi
call   10e0 <RAND_pseudo_bytes@plt>
lea    -0xa0(%rbp),%rdi
mov    $0x20,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <BN_bin2bn@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xcbe(%rip),%rdi
call   1100 <showbn@plt>
mov    -0x48(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    (%rax),%rsi
mov    -0xa8(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x38(%rbp),%rcx
call   1080 <SRP_Calc_B@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rsi
lea    0xc8a(%rip),%rdi
call   1100 <showbn@plt>
mov    -0x68(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    (%rax),%rsi
call   1090 <SRP_Verify_B_mod_N@plt>
cmp    $0x0,%eax
jne    140e <run_srp+0x1fe>
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
lea    0xc5b(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15f7 <run_srp+0x3e7>
lea    -0xa0(%rbp),%rdi
mov    $0x20,%esi
call   10e0 <RAND_pseudo_bytes@plt>
lea    -0xa0(%rbp),%rdi
mov    $0x20,%esi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <BN_bin2bn@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xc20(%rip),%rdi
call   1100 <showbn@plt>
mov    -0x40(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    (%rax),%rsi
mov    -0xa8(%rbp),%rax
mov    0x8(%rax),%rdx
call   1120 <SRP_Calc_A@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rsi
lea    0xbf0(%rip),%rdi
call   1100 <showbn@plt>
mov    -0x60(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    (%rax),%rsi
call   1060 <SRP_Verify_A_mod_N@plt>
cmp    $0x0,%eax
jne    14b7 <run_srp+0x2a7>
mov    0x2b43(%rip),%rax
mov    (%rax),%edi
lea    0xbc1(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    15f7 <run_srp+0x3e7>
mov    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0xa8(%rbp),%rax
mov    (%rax),%rdx
call   1030 <SRP_Calc_u@plt>
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10c0 <SRP_Calc_x@plt>
mov    %rax,-0x58(%rbp)
mov    -0xa8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x68(%rbp),%rsi
mov    -0xa8(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x58(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    -0x50(%rbp),%r9
call   1040 <SRP_Calc_client_key@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rsi
lea    0xb52(%rip),%rdi
call   1100 <showbn@plt>
mov    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0xa8(%rbp),%rax
mov    (%rax),%r8
call   10f0 <SRP_Calc_server_key@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rsi
lea    0xb2c(%rip),%rdi
call   1100 <showbn@plt>
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1110 <BN_cmp@plt>
cmp    $0x0,%rax
jne    157b <run_srp+0x36b>
movl   $0x0,-0x24(%rbp)
jmp    1597 <run_srp+0x387>
mov    0x2a5e(%rip),%rax
mov    (%rax),%edi
lea    0xb01(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x70(%rbp),%rdi
call   1130 <BN_clear_free@plt>
mov    -0x78(%rbp),%rdi
call   1130 <BN_clear_free@plt>
mov    -0x58(%rbp),%rdi
call   1130 <BN_clear_free@plt>
mov    -0x50(%rbp),%rdi
call   10a0 <BN_free@plt>
mov    -0x60(%rbp),%rdi
call   10a0 <BN_free@plt>
mov    -0x40(%rbp),%rdi
call   1130 <BN_clear_free@plt>
mov    -0x68(%rbp),%rdi
call   10a0 <BN_free@plt>
mov    -0x48(%rbp),%rdi
call   1130 <BN_clear_free@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <BN_free@plt>
mov    -0x38(%rbp),%rdi
call   1130 <BN_clear_free@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_srp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%r14
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xdc1(%rip),%rdi
call   10d0 <SRP_get_default_gN@plt>
test   %rax,%rax
je     14b7 <run_srp+0x2a7>
mov    %rax,%rbx
mov    (%rax),%r8
mov    0x8(%rax),%r9
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <SRP_create_verifier_BN@plt>
test   %eax,%eax
je     14c9 <run_srp+0x2b9>
mov    (%rbx),%rsi
lea    0xdc6(%rip),%rdi
call   1100 <showbn@plt>
mov    0x8(%rbx),%rsi
lea    0xdb8(%rip),%rdi
call   1100 <showbn@plt>
mov    0x8(%rsp),%rsi
lea    0xda9(%rip),%rdi
call   1100 <showbn@plt>
mov    (%rsp),%rsi
lea    0xd9e(%rip),%rdi
call   1100 <showbn@plt>
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   10e0 <RAND_pseudo_bytes@plt>
mov    %rbp,%rdi
mov    $0x20,%esi
xor    %edx,%edx
call   1070 <BN_bin2bn@plt>
mov    %rax,%rbp
lea    0xd77(%rip),%rdi
mov    %rax,%rsi
call   1100 <showbn@plt>
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdx
mov    (%rsp),%rcx
mov    %rbp,%rdi
call   1080 <SRP_Calc_B@plt>
mov    %rax,%r13
lea    0xd54(%rip),%rdi
mov    %rax,%rsi
call   1100 <showbn@plt>
mov    (%rbx),%rsi
mov    %r13,%rdi
call   1090 <SRP_Verify_B_mod_N@plt>
test   %eax,%eax
je     14db <run_srp+0x2cb>
mov    %r14,0x10(%rsp)
mov    %rbp,0x38(%rsp)
mov    %r15,0x18(%rsp)
lea    0x40(%rsp),%r15
mov    %r15,%rdi
mov    $0x20,%esi
call   10e0 <RAND_pseudo_bytes@plt>
xor    %r12d,%r12d
mov    %r15,%rdi
mov    $0x20,%esi
xor    %edx,%edx
call   1070 <BN_bin2bn@plt>
mov    %rax,%r14
lea    0xd09(%rip),%rdi
mov    %rax,%rsi
call   1100 <showbn@plt>
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdx
mov    %r14,%rdi
call   1120 <SRP_Calc_A@plt>
mov    %rax,%rbp
lea    0xcea(%rip),%rdi
mov    %rax,%rsi
call   1100 <showbn@plt>
mov    (%rbx),%rsi
mov    %rbp,%rdi
call   1060 <SRP_Verify_A_mod_N@plt>
test   %eax,%eax
je     14ed <run_srp+0x2dd>
mov    (%rbx),%rdx
mov    %rbp,%rdi
mov    %r13,%rsi
call   1030 <SRP_Calc_u@plt>
mov    %rbp,0x20(%rsp)
mov    %rax,%r15
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    0x18(%rsp),%rdx
call   10c0 <SRP_Calc_x@plt>
mov    (%rbx),%rdi
mov    0x8(%rbx),%rdx
mov    %r13,0x30(%rsp)
mov    %r13,%rsi
mov    %rax,0x28(%rsp)
mov    %rax,%rcx
mov    %r14,0x18(%rsp)
mov    %r14,%r8
mov    %r15,%r9
call   1040 <SRP_Calc_client_key@plt>
mov    %rax,%rbp
lea    0xc81(%rip),%rdi
mov    %rax,%rsi
call   1100 <showbn@plt>
mov    (%rsp),%rsi
mov    (%rbx),%r8
mov    0x20(%rsp),%rdi
mov    %rdi,%r13
mov    %r15,0x10(%rsp)
mov    %r15,%rdx
mov    0x38(%rsp),%r14
mov    %r14,%rcx
call   10f0 <SRP_Calc_server_key@plt>
mov    %rax,%rbx
lea    0xc58(%rip),%rdi
mov    %rax,%rsi
call   1100 <showbn@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1110 <BN_cmp@plt>
test   %rax,%rax
je     145a <run_srp+0x24a>
mov    0x2b9a(%rip),%rax
mov    (%rax),%edi
lea    0xc3d(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0x1,%r12d
mov    %rbp,%rdi
call   1130 <BN_clear_free@plt>
mov    %rbx,%rdi
call   1130 <BN_clear_free@plt>
mov    0x28(%rsp),%rdi
call   1130 <BN_clear_free@plt>
mov    0x10(%rsp),%rdi
call   10a0 <BN_free@plt>
mov    %r13,%rdi
call   10a0 <BN_free@plt>
mov    0x18(%rsp),%rdi
call   1130 <BN_clear_free@plt>
mov    0x30(%rsp),%rdi
call   10a0 <BN_free@plt>
mov    %r14,%rdi
call   1130 <BN_clear_free@plt>
mov    0x8(%rsp),%rdi
call   10a0 <BN_free@plt>
mov    (%rsp),%rdi
call   1130 <BN_clear_free@plt>
jmp    1508 <run_srp+0x2f8>
mov    0x2b22(%rip),%rax
mov    (%rax),%edi
lea    0xb3e(%rip),%rsi
jmp    14fd <run_srp+0x2ed>
mov    0x2b10(%rip),%rax
mov    (%rax),%edi
lea    0xb4a(%rip),%rsi
jmp    14fd <run_srp+0x2ed>
mov    0x2afe(%rip),%rax
mov    (%rax),%edi
lea    0xb6d(%rip),%rsi
jmp    14fd <run_srp+0x2ed>
mov    0x2aec(%rip),%rax
mov    (%rax),%edi
lea    0xb6a(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0xffffffff,%r12d
mov    %r12d,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32*, i32* }
@.str = [5 x i8] c"1024\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Failed to get SRP parameters\0A\00"
@.str.2 = [31 x i8] c"Failed to create SRP verifier\0A\00"
@.str.3 = [2 x i8] c"N\00"
@.str.4 = [2 x i8] c"g\00"
@.str.5 = [5 x i8] c"Salt\00"
@.str.6 = [9 x i8] c"Verifier\00"
@.str.7 = [2 x i8] c"b\00"
@.str.8 = [2 x i8] c"B\00"
@.str.9 = [11 x i8] c"Invalid B\0A\00"
@.str.10 = [2 x i8] c"a\00"
@.str.11 = [2 x i8] c"A\00"
@.str.12 = [11 x i8] c"Invalid A\0A\00"
@.str.13 = [13 x i8] c"Client's key\00"
@.str.14 = [13 x i8] c"Server's key\00"
@.str.15 = [15 x i8] c"Keys mismatch\0A\00"
define i32 @run_srp(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca [32 x i8]
%20 = alloca %struct.TYPE_3__*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 -1, i32* %8
store i32* null, i32** %9
store i32* null, i32** %10
store i32* null, i32** %11
store i32* null, i32** %12
store i32* null, i32** %13
store i32* null, i32** %14
store i32* null, i32** %15
store i32* null, i32** %16
store i32* null, i32** %17
store i32* null, i32** %18
%21 = call %struct.TYPE_3__* @SRP_get_default_gN(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store %struct.TYPE_3__* %21, %struct.TYPE_3__** %20
%22 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%23 = icmp eq %struct.TYPE_3__* %22, null
br i1 %23, label %24, label %27
24: ; preds = %3
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %170
27: ; preds = %3
%28 = load i8*, i8** %5
%29 = load i8*, i8** %7
%30 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %30, i32 0, i32 0
%32 = load i32*, i32** %31
%33 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %33, i32 0, i32 1
%35 = load i32*, i32** %34
%36 = call i32 @SRP_create_verifier_BN(i8* %28, i8* %29, i32** %9, i32** %10, i32* %32, i32* %35)
%37 = icmp ne i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %27
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %4
br label %170
41: ; preds = %27
%42 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%43 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %42, i32 0, i32 0
%44 = load i32*, i32** %43
%45 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32* %44)
%46 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%47 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %46, i32 0, i32 1
%48 = load i32*, i32** %47
%49 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %48)
%50 = load i32*, i32** %9
%51 = call i32 @showbn(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %50)
%52 = load i32*, i32** %10
%53 = call i32 @showbn(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32* %52)
%54 = getelementptr inbounds [32 x i8], [32 x i8]* %19, i64 0, i64 0
%55 = call i32 @RAND_pseudo_bytes(i8* %54, i32 32)
%56 = getelementptr inbounds [32 x i8], [32 x i8]* %19, i64 0, i64 0
%57 = call i32* @BN_bin2bn(i8* %56, i32 32, i32* null)
store i32* %57, i32** %12
%58 = load i32*, i32** %12
%59 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32* %58)
%60 = load i32*, i32** %12
%61 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%62 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %61, i32 0, i32 0
%63 = load i32*, i32** %62
%64 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%65 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %64, i32 0, i32 1
%66 = load i32*, i32** %65
%67 = load i32*, i32** %10
%68 = call i32* @SRP_Calc_B(i32* %60, i32* %63, i32* %66, i32* %67)
store i32* %68, i32** %16
%69 = load i32*, i32** %16
%70 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* %69)
%71 = load i32*, i32** %16
%72 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%73 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %72, i32 0, i32 0
%74 = load i32*, i32** %73
%75 = call i32 @SRP_Verify_B_mod_N(i32* %71, i32* %74)
%76 = icmp ne i32 %75, 0
br i1 %76, label %80, label %77
77: ; preds = %41
%78 = load i32, i32* @stderr
%79 = call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %4
br label %170
80: ; preds = %41
%81 = getelementptr inbounds [32 x i8], [32 x i8]* %19, i64 0, i64 0
%82 = call i32 @RAND_pseudo_bytes(i8* %81, i32 32)
%83 = getelementptr inbounds [32 x i8], [32 x i8]* %19, i64 0, i64 0
%84 = call i32* @BN_bin2bn(i8* %83, i32 32, i32* null)
store i32* %84, i32** %11
%85 = load i32*, i32** %11
%86 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32* %85)
%87 = load i32*, i32** %11
%88 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%89 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %88, i32 0, i32 0
%90 = load i32*, i32** %89
%91 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%92 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %91, i32 0, i32 1
%93 = load i32*, i32** %92
%94 = call i32* @SRP_Calc_A(i32* %87, i32* %90, i32* %93)
store i32* %94, i32** %15
%95 = load i32*, i32** %15
%96 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32* %95)
%97 = load i32*, i32** %15
%98 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%99 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %98, i32 0, i32 0
%100 = load i32*, i32** %99
%101 = call i32 @SRP_Verify_A_mod_N(i32* %97, i32* %100)
%102 = icmp ne i32 %101, 0
br i1 %102, label %106, label %103
103: ; preds = %80
%104 = load i32, i32* @stderr
%105 = call i32 @fprintf(i32 %104, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
store i32 -1, i32* %4
br label %170
106: ; preds = %80
%107 = load i32*, i32** %15
%108 = load i32*, i32** %16
%109 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%110 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %109, i32 0, i32 0
%111 = load i32*, i32** %110
%112 = call i32* @SRP_Calc_u(i32* %107, i32* %108, i32* %111)
store i32* %112, i32** %13
%113 = load i32*, i32** %9
%114 = load i8*, i8** %5
%115 = load i8*, i8** %6
%116 = call i32* @SRP_Calc_x(i32* %113, i8* %114, i8* %115)
store i32* %116, i32** %14
%117 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%118 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %117, i32 0, i32 0
%119 = load i32*, i32** %118
%120 = load i32*, i32** %16
%121 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%122 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %121, i32 0, i32 1
%123 = load i32*, i32** %122
%124 = load i32*, i32** %14
%125 = load i32*, i32** %11
%126 = load i32*, i32** %13
%127 = call i32* @SRP_Calc_client_key(i32* %119, i32* %120, i32* %123, i32* %124, i32* %125, i32* %126)
store i32* %127, i32** %17
%128 = load i32*, i32** %17
%129 = call i32 @showbn(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i32* %128)
%130 = load i32*, i32** %15
%131 = load i32*, i32** %10
%132 = load i32*, i32** %13
%133 = load i32*, i32** %12
%134 = load %struct.TYPE_3__*, %struct.TYPE_3__** %20
%135 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %134, i32 0, i32 0
%136 = load i32*, i32** %135
%137 = call i32* @SRP_Calc_server_key(i32* %130, i32* %131, i32* %132, i32* %133, i32* %136)
store i32* %137, i32** %18
%138 = load i32*, i32** %18
%139 = call i32 @showbn(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0), i32* %138)
%140 = load i32*, i32** %17
%141 = load i32*, i32** %18
%142 = call i64 @BN_cmp(i32* %140, i32* %141)
%143 = icmp eq i64 %142, 0
br i1 %143, label %144, label %145
144: ; preds = %106
store i32 0, i32* %8
br label %148
145: ; preds = %106
%146 = load i32, i32* @stderr
%147 = call i32 @fprintf(i32 %146, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0))
store i32 1, i32* %8
br label %148
148: ; preds = %145, %144
%149 = load i32*, i32** %17
%150 = call i32 @BN_clear_free(i32* %149)
%151 = load i32*, i32** %18
%152 = call i32 @BN_clear_free(i32* %151)
%153 = load i32*, i32** %14
%154 = call i32 @BN_clear_free(i32* %153)
%155 = load i32*, i32** %13
%156 = call i32 @BN_free(i32* %155)
%157 = load i32*, i32** %15
%158 = call i32 @BN_free(i32* %157)
%159 = load i32*, i32** %11
%160 = call i32 @BN_clear_free(i32* %159)
%161 = load i32*, i32** %16
%162 = call i32 @BN_free(i32* %161)
%163 = load i32*, i32** %12
%164 = call i32 @BN_clear_free(i32* %163)
%165 = load i32*, i32** %9
%166 = call i32 @BN_free(i32* %165)
%167 = load i32*, i32** %10
%168 = call i32 @BN_clear_free(i32* %167)
%169 = load i32, i32* %8
store i32 %169, i32* %4
br label %170
170: ; preds = %148, %103, %77, %38, %24
%171 = load i32, i32* %4
ret i32 %171
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32*, i32* }
@.str = [5 x i8] c"1024\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Failed to get SRP parameters\0A\00"
@.str.2 = [31 x i8] c"Failed to create SRP verifier\0A\00"
@.str.3 = [2 x i8] c"N\00"
@.str.4 = [2 x i8] c"g\00"
@.str.5 = [5 x i8] c"Salt\00"
@.str.6 = [9 x i8] c"Verifier\00"
@.str.7 = [2 x i8] c"b\00"
@.str.8 = [2 x i8] c"B\00"
@.str.9 = [11 x i8] c"Invalid B\0A\00"
@.str.10 = [2 x i8] c"a\00"
@.str.11 = [2 x i8] c"A\00"
@.str.12 = [11 x i8] c"Invalid A\0A\00"
@.str.13 = [13 x i8] c"Client's key\00"
@.str.14 = [13 x i8] c"Server's key\00"
@.str.15 = [15 x i8] c"Keys mismatch\0A\00"
define i32 @run_srp(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [32 x i8]
%7 = bitcast i32** %4 to i8*
store i32* null, i32** %4
%8 = bitcast i32** %5 to i8*
store i32* null, i32** %5
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%10 = tail call %struct.TYPE_3__* @SRP_get_default_gN(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq %struct.TYPE_3__* %10, null
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %94
15: ; preds = %3
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i64 0, i32 0
%17 = load i32*, i32** %16
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i64 0, i32 1
%19 = load i32*, i32** %18
%20 = call i32 @SRP_create_verifier_BN(i8* %0, i8* %2, i32** %4, i32** %5, i32* %17, i32* %19)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
br label %94
25: ; preds = %15
%26 = load i32*, i32** %16
%27 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32* %26)
%28 = load i32*, i32** %18
%29 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32* %28)
%30 = load i32*, i32** %4
%31 = call i32 @showbn(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %30)
%32 = load i32*, i32** %5
%33 = call i32 @showbn(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32* %32)
%34 = call i32 @RAND_pseudo_bytes(i8* %9, i32 32)
%35 = call i32* @BN_bin2bn(i8* %9, i32 32, i32* null)
%36 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32* %35)
%37 = load i32*, i32** %16
%38 = load i32*, i32** %18
%39 = load i32*, i32** %5
%40 = call i32* @SRP_Calc_B(i32* %35, i32* %37, i32* %38, i32* %39)
%41 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32* %40)
%42 = load i32*, i32** %16
%43 = call i32 @SRP_Verify_B_mod_N(i32* %40, i32* %42)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %25
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
br label %94
48: ; preds = %25
%49 = call i32 @RAND_pseudo_bytes(i8* %9, i32 32)
%50 = call i32* @BN_bin2bn(i8* %9, i32 32, i32* null)
%51 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0), i32* %50)
%52 = load i32*, i32** %16
%53 = load i32*, i32** %18
%54 = call i32* @SRP_Calc_A(i32* %50, i32* %52, i32* %53)
%55 = call i32 @showbn(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32* %54)
%56 = load i32*, i32** %16
%57 = call i32 @SRP_Verify_A_mod_N(i32* %54, i32* %56)
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %48
%60 = load i32, i32* @stderr
%61 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
br label %94
62: ; preds = %48
%63 = load i32*, i32** %16
%64 = call i32* @SRP_Calc_u(i32* %54, i32* %40, i32* %63)
%65 = load i32*, i32** %4
%66 = call i32* @SRP_Calc_x(i32* %65, i8* %0, i8* %1)
%67 = load i32*, i32** %16
%68 = load i32*, i32** %18
%69 = call i32* @SRP_Calc_client_key(i32* %67, i32* %40, i32* %68, i32* %66, i32* %50, i32* %64)
%70 = call i32 @showbn(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i32* %69)
%71 = load i32*, i32** %5
%72 = load i32*, i32** %16
%73 = call i32* @SRP_Calc_server_key(i32* %54, i32* %71, i32* %64, i32* %35, i32* %72)
%74 = call i32 @showbn(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0), i32* %73)
%75 = call i64 @BN_cmp(i32* %69, i32* %73)
%76 = icmp eq i64 %75, 0
br i1 %76, label %80, label %77
77: ; preds = %62
%78 = load i32, i32* @stderr
%79 = call i32 @fprintf(i32 %78, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0))
br label %80
80: ; preds = %62, %77
%81 = phi i32 [ 1, %77 ], [ 0, %62 ]
%82 = call i32 @BN_clear_free(i32* %69)
%83 = call i32 @BN_clear_free(i32* %73)
%84 = call i32 @BN_clear_free(i32* %66)
%85 = call i32 @BN_free(i32* %64)
%86 = call i32 @BN_free(i32* %54)
%87 = call i32 @BN_clear_free(i32* %50)
%88 = call i32 @BN_free(i32* %40)
%89 = call i32 @BN_clear_free(i32* %35)
%90 = load i32*, i32** %4
%91 = call i32 @BN_free(i32* %90)
%92 = load i32*, i32** %5
%93 = call i32 @BN_clear_free(i32* %92)
br label %94
94: ; preds = %80, %59, %45, %22, %12
%95 = phi i32 [ -1, %12 ], [ %81, %80 ], [ -1, %59 ], [ -1, %45 ], [ -1, %22 ]
ret i32 %95
}