#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 *, 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) {
  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);
  BIO_flush(cbio);
  return 1;
}


x86 assembly (clang, -O0):
<send_ocsp_response>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe92(%rip),%rsi
mov    $0x51,%edx
call   1050 <memcpy@plt>
cmpq   $0x0,-0x10(%rbp)
jne    118f <send_ocsp_response+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <send_ocsp_response+0x88>
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <i2d_OCSP_RESPONSE@plt>
mov    -0x80(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
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   1070 <BIO_flush@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_ocsp_response>:
push   %r14
push   %rbx
sub    $0x58,%rsp
movaps 0xef2(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe82(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x50(%rsp)
test   %rdi,%rdi
je     11c3 <send_ocsp_response+0x83>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
xor    %esi,%esi
call   1050 <i2d_OCSP_RESPONSE@plt>
mov    %rsp,%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
jmp    11c5 <send_ocsp_response+0x85>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.send_ocsp_response.http_resp = [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*
%6 = alloca [81 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
%7 = bitcast [81 x i8]* %6 to i8*
%8 = load i32*, i32** %4
%9 = icmp ne i32* %8, null
br i1 %9, label %11, label %10
10: ; preds = %2
store i32 0, i32* %3
br label %22
11: ; preds = %2
%12 = load i32*, i32** %4
%13 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%14 = load i32*, i32** %5
%15 = call i32 @i2d_OCSP_RESPONSE(i32* %14, i32* null)
%16 = call i32 @BIO_printf(i32* %12, i8* %13, i32 %15)
%17 = load i32*, i32** %4
%18 = load i32*, i32** %5
%19 = call i32 @i2d_OCSP_RESPONSE_bio(i32* %17, i32* %18)
%20 = load i32*, i32** %4
%21 = call i32 @BIO_flush(i32* %20)
store i32 1, i32* %3
br label %22
22: ; preds = %11, %10
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
@__const.send_ocsp_response.http_resp = [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 [81 x i8]
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32* %0, null
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = tail call i32 @i2d_OCSP_RESPONSE(i32* %1, i32* null)
%8 = call i32 @BIO_printf(i32* %0, i8* %4, i32 %7)
%9 = call i32 @i2d_OCSP_RESPONSE_bio(i32* %0, i32* %1)
%10 = call i32 @BIO_flush(i32* %0)
br label %11
11: ; preds = %2, %6
%12 = phi i32 [ 1, %6 ], [ 0, %2 ]
ret i32 %12
}