#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*/ OCSP_RESPONSE;
typedef int /*<<< orphan*/ OCSP_REQ_CTX;
typedef int /*<<< orphan*/ OCSP_REQUEST;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
scalar_t__ BIO_should_retry(int /*<<< orphan*/ *);
int /*<<< orphan*/ OCSP_REQ_CTX_free(int /*<<< orphan*/ *);
int OCSP_sendreq_nbio(int /*<<< orphan*/ **, int /*<<< orphan*/ *);
int /*<<< orphan*/ *OCSP_sendreq_new(int /*<<< orphan*/ *, char const *,
                                     int /*<<< orphan*/ *, int);
OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req) {
  OCSP_RESPONSE *resp = NULL;
  OCSP_REQ_CTX *ctx;
  int rv;
  ctx = OCSP_sendreq_new(b, path, req, -1);
  if (!ctx)
    return NULL;
  do {
    rv = OCSP_sendreq_nbio(&resp, ctx);
  } while ((rv == -1) && BIO_should_retry(b));
  OCSP_REQ_CTX_free(ctx);
  if (rv)
    return resp;
  return NULL;
}


x86 assembly (clang, -O0):
<OCSP_sendreq_bio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    $0xffffffff,%ecx
call   1040 <OCSP_sendreq_new@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    118e <OCSP_sendreq_bio+0x4e>
movq   $0x0,-0x8(%rbp)
jmp    11f8 <OCSP_sendreq_bio+0xb8>
jmp    1193 <OCSP_sendreq_bio+0x53>
mov    -0x30(%rbp),%rsi
lea    -0x28(%rbp),%rdi
call   1050 <OCSP_sendreq_nbio@plt>
mov    %eax,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x34(%rbp)
mov    %al,-0x35(%rbp)
jne    11c5 <OCSP_sendreq_bio+0x85>
mov    -0x10(%rbp),%rdi
call   1060 <BIO_should_retry@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    1193 <OCSP_sendreq_bio+0x53>
mov    -0x30(%rbp),%rdi
call   1030 <OCSP_REQ_CTX_free@plt>
cmpl   $0x0,-0x34(%rbp)
je     11f0 <OCSP_sendreq_bio+0xb0>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11f8 <OCSP_sendreq_bio+0xb8>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OCSP_sendreq_bio>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movq   $0x0,(%rsp)
mov    $0xffffffff,%ecx
call   1040 <OCSP_sendreq_new@plt>
test   %rax,%rax
je     11ab <OCSP_sendreq_bio+0x6b>
mov    %rax,%rbx
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <OCSP_sendreq_nbio@plt>
cmp    $0xffffffff,%eax
jne    1197 <OCSP_sendreq_bio+0x57>
mov    %r14,%rdi
call   1060 <BIO_should_retry@plt>
test   %rax,%rax
jne    1170 <OCSP_sendreq_bio+0x30>
mov    %rbx,%rdi
call   1030 <OCSP_REQ_CTX_free@plt>
jmp    11a5 <OCSP_sendreq_bio+0x65>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <OCSP_REQ_CTX_free@plt>
test   %ebp,%ebp
je     11ab <OCSP_sendreq_bio+0x6b>
mov    (%rsp),%rax
jmp    11ad <OCSP_sendreq_bio+0x6d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @OCSP_sendreq_bio(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32* null, i32** %8
%11 = load i32*, i32** %5
%12 = load i8*, i8** %6
%13 = load i32*, i32** %7
%14 = call i32* @OCSP_sendreq_new(i32* %11, i8* %12, i32* %13, i32 -1)
store i32* %14, i32** %9
%15 = load i32*, i32** %9
%16 = icmp ne i32* %15, null
br i1 %16, label %18, label %17
17: ; preds = %3
store i32* null, i32** %4
br label %39
18: ; preds = %3
br label %19
19: ; preds = %29, %18
%20 = load i32*, i32** %9
%21 = call i32 @OCSP_sendreq_nbio(i32** %8, i32* %20)
store i32 %21, i32* %10
br label %22
22: ; preds = %19
%23 = load i32, i32* %10
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32*, i32** %5
%27 = call i64 @BIO_should_retry(i32* %26)
%28 = icmp ne i64 %27, 0
br label %29
29: ; preds = %25, %22
%30 = phi i1 [ false, %22 ], [ %28, %25 ]
br i1 %30, label %19, label %31
31: ; preds = %29
%32 = load i32*, i32** %9
%33 = call i32 @OCSP_REQ_CTX_free(i32* %32)
%34 = load i32, i32* %10
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = load i32*, i32** %8
store i32* %37, i32** %4
br label %39
38: ; preds = %31
store i32* null, i32** %4
br label %39
39: ; preds = %38, %36, %17
%40 = load i32*, i32** %4
ret i32* %40
}

LLVM IR (-O2):
define i32* @OCSP_sendreq_bio(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32*
%5 = bitcast i32** %4 to i8*
store i32* null, i32** %4
%6 = tail call i32* @OCSP_sendreq_new(i32* %0, i8* %1, i32* %2, i32 -1)
%7 = icmp eq i32* %6, null
br i1 %7, label %22, label %8
8: ; preds = %3, %11
%9 = call i32 @OCSP_sendreq_nbio(i32** %4, i32* %6)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = call i64 @BIO_should_retry(i32* %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %8
14: ; preds = %11
%15 = call i32 @OCSP_REQ_CTX_free(i32* %6)
%16 = load i32*, i32** %4
br label %22
17: ; preds = %8
%18 = call i32 @OCSP_REQ_CTX_free(i32* %6)
%19 = icmp eq i32 %9, 0
%20 = load i32*, i32** %4
%21 = select i1 %19, i32* null, i32* %20
br label %22
22: ; preds = %17, %14, %3
%23 = phi i32* [ null, %3 ], [ %16, %14 ], [ %21, %17 ]
ret i32* %23
}