#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*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_flush(int /*<<< orphan*/ *);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char const *,
                              int /*<<< orphan*/);
int /*<<< orphan*/ i2d_OCSP_RESPONSE(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ i2d_OCSP_RESPONSE_bio(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ *);
int send_ocsp_response(BIO *cbio, OCSP_RESPONSE *resp) {
  static const char http_resp[] =
      "HTTP/1.0 200 OK\r\nContent-type: application/ocsp-response\r\n"
      "Content-Length: %d\r\n\r\n";
  if (!cbio)
    return 0;
  BIO_printf(cbio, http_resp, i2d_OCSP_RESPONSE(resp, NULL));
  i2d_OCSP_RESPONSE_bio(cbio, resp);
  (void)BIO_flush(cbio);
  return 1;
}


x86 assembly (clang, -O0):
<send_ocsp_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1167 <send_ocsp_response+0x27>
movl   $0x0,-0x4(%rbp)
jmp    11ab <send_ocsp_response+0x6b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <i2d_OCSP_RESPONSE@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe77(%rip),%rsi
call   1040 <BIO_printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <i2d_OCSP_RESPONSE_bio@plt>
mov    -0x10(%rbp),%rdi
call   1060 <BIO_flush@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_ocsp_response>:
test   %rdi,%rdi
je     118a <send_ocsp_response+0x4a>
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
xor    %esi,%esi
call   1050 <i2d_OCSP_RESPONSE@plt>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1040 <BIO_printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <i2d_OCSP_RESPONSE_bio@plt>
mov    %rbx,%rdi
call   1060 <BIO_flush@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@send_ocsp_response.http_resp = internal constant [81 x i8] c"HTTP/1.0 200 OK\0D\0AContent-type: application/ocsp-response\0D\0AContent-Length: %d\0D\0A\0D\0A\00"
define i32 @send_ocsp_response(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
%6 = load i32*, i32** %4
%7 = icmp ne i32* %6, null
br i1 %7, label %9, label %8
8: ; preds = %2
store i32 0, i32* %3
br label %19
9: ; preds = %2
%10 = load i32*, i32** %4
%11 = load i32*, i32** %5
%12 = call i32 @i2d_OCSP_RESPONSE(i32* %11, i32* null)
%13 = call i32 @BIO_printf(i32* %10, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @send_ocsp_response.http_resp, i64 0, i64 0), i32 %12)
%14 = load i32*, i32** %4
%15 = load i32*, i32** %5
%16 = call i32 @i2d_OCSP_RESPONSE_bio(i32* %14, i32* %15)
%17 = load i32*, i32** %4
%18 = call i32 @BIO_flush(i32* %17)
store i32 1, i32* %3
br label %19
19: ; preds = %9, %8
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@send_ocsp_response.http_resp = internal constant [81 x i8] c"HTTP/1.0 200 OK\0D\0AContent-type: application/ocsp-response\0D\0AContent-Length: %d\0D\0A\0D\0A\00"
define i32 @send_ocsp_response(i32* %0, i32* %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = tail call i32 @i2d_OCSP_RESPONSE(i32* %1, i32* null)
%6 = tail call i32 @BIO_printf(i32* %0, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @send_ocsp_response.http_resp, i64 0, i64 0), i32 %5)
%7 = tail call i32 @i2d_OCSP_RESPONSE_bio(i32* %0, i32* %1)
%8 = tail call i32 @BIO_flush(i32* %0)
br label %9
9: ; preds = %2, %4
%10 = phi i32 [ 1, %4 ], [ 0, %2 ]
ret i32 %10
}