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

/* Variables and functions */
int /*<<< orphan*/ BIO_dump_indent(void *, char *, int, int);
int /*<<< orphan*/ BIO_puts(void *, char *);
int /*<<< orphan*/ OCSP_RESPONSE_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ OCSP_RESPONSE_print(void *, int /*<<< orphan*/ *,
                                       int /*<<< orphan*/);
int SSL_get_tlsext_status_ocsp_resp(int /*<<< orphan*/ *,
                                    unsigned char const **);
int /*<<< orphan*/ *d2i_OCSP_RESPONSE(int /*<<< orphan*/ *,
                                      unsigned char const **, int);
int ocsp_resp_cb(SSL *s, void *arg) {
  const unsigned char *p;
  int len;
  OCSP_RESPONSE *rsp;
  len = SSL_get_tlsext_status_ocsp_resp(s, &p);
  BIO_puts(arg, "OCSP response: ");
  if (!p) {
    BIO_puts(arg, "no response sent\n");
    return 1;
  }
  rsp = d2i_OCSP_RESPONSE(NULL, &p, len);
  if (!rsp) {
    BIO_puts(arg, "response parse error\n");
    BIO_dump_indent(arg, (char *)p, len, 4);
    return 0;
  }
  BIO_puts(arg, "\n======================================\n");
  OCSP_RESPONSE_print(arg, rsp, 0);
  BIO_puts(arg, "======================================\n");
  OCSP_RESPONSE_free(rsp);
  return 1;
}


x86 assembly (clang, -O0):
<ocsp_resp_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <SSL_get_tlsext_status_ocsp_resp@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1080 <BIO_puts@plt>
cmpq   $0x0,-0x20(%rbp)
jne    11b7 <ocsp_resp_cb+0x57>
mov    -0x18(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <BIO_puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    1246 <ocsp_resp_cb+0xe6>
mov    -0x24(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x20(%rbp),%rsi
call   1040 <d2i_OCSP_RESPONSE@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1207 <ocsp_resp_cb+0xa7>
mov    -0x18(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1080 <BIO_puts@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    $0x4,%ecx
call   1070 <BIO_dump_indent@plt>
movl   $0x0,-0x4(%rbp)
jmp    1246 <ocsp_resp_cb+0xe6>
mov    -0x18(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1080 <BIO_puts@plt>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
xor    %edx,%edx
call   1030 <OCSP_RESPONSE_print@plt>
mov    -0x18(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   1080 <BIO_puts@plt>
mov    -0x30(%rbp),%rdi
call   1060 <OCSP_RESPONSE_free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ocsp_resp_cb>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rsp,%rsi
call   1050 <SSL_get_tlsext_status_ocsp_resp@plt>
mov    %eax,%r14d
lea    0xe84(%rip),%rsi
mov    %rbx,%rdi
call   1080 <BIO_puts@plt>
cmpq   $0x0,(%rsp)
je     11d8 <ocsp_resp_cb+0x78>
xor    %r15d,%r15d
mov    %rsp,%rsi
xor    %edi,%edi
mov    %r14d,%edx
call   1040 <d2i_OCSP_RESPONSE@plt>
test   %rax,%rax
je     11ef <ocsp_resp_cb+0x8f>
mov    %rax,%rbp
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1080 <BIO_puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %edx,%edx
call   1030 <OCSP_RESPONSE_print@plt>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1080 <BIO_puts@plt>
mov    %rbp,%rdi
call   1060 <OCSP_RESPONSE_free@plt>
jmp    11e7 <ocsp_resp_cb+0x87>
lea    0xe31(%rip),%rsi
mov    %rbx,%rdi
call   1080 <BIO_puts@plt>
mov    $0x1,%r15d
jmp    1212 <ocsp_resp_cb+0xb2>
lea    0xe2c(%rip),%rsi
mov    %rbx,%rdi
call   1080 <BIO_puts@plt>
mov    (%rsp),%rsi
mov    %rbx,%rdi
mov    %r14d,%edx
mov    $0x4,%ecx
call   1070 <BIO_dump_indent@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"OCSP response: \00"
@.str.1 = [18 x i8] c"no response sent\0A\00"
@.str.2 = [22 x i8] c"response parse error\0A\00"
@.str.3 = [41 x i8] c"\0A======================================\0A\00"
@.str.4 = [40 x i8] c"======================================\0A\00"
define i32 @ocsp_resp_cb(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
store i32* %0, i32** %4
store i8* %1, i8** %5
%9 = load i32*, i32** %4
%10 = call i32 @SSL_get_tlsext_status_ocsp_resp(i32* %9, i8** %6)
store i32 %10, i32* %7
%11 = load i8*, i8** %5
%12 = call i32 @BIO_puts(i8* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = call i32 @BIO_puts(i8* %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %40
18: ; preds = %2
%19 = load i32, i32* %7
%20 = call i32* @d2i_OCSP_RESPONSE(i32* null, i8** %6, i32 %19)
store i32* %20, i32** %8
%21 = load i32*, i32** %8
%22 = icmp ne i32* %21, null
br i1 %22, label %30, label %23
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = call i32 @BIO_puts(i8* %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%26 = load i8*, i8** %5
%27 = load i8*, i8** %6
%28 = load i32, i32* %7
%29 = call i32 @BIO_dump_indent(i8* %26, i8* %27, i32 %28, i32 4)
store i32 0, i32* %3
br label %40
30: ; preds = %18
%31 = load i8*, i8** %5
%32 = call i32 @BIO_puts(i8* %31, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%33 = load i8*, i8** %5
%34 = load i32*, i32** %8
%35 = call i32 @OCSP_RESPONSE_print(i8* %33, i32* %34, i32 0)
%36 = load i8*, i8** %5
%37 = call i32 @BIO_puts(i8* %36, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%38 = load i32*, i32** %8
%39 = call i32 @OCSP_RESPONSE_free(i32* %38)
store i32 1, i32* %3
br label %40
40: ; preds = %30, %23, %15
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [16 x i8] c"OCSP response: \00"
@.str.1 = [18 x i8] c"no response sent\0A\00"
@.str.2 = [22 x i8] c"response parse error\0A\00"
@.str.3 = [41 x i8] c"\0A======================================\0A\00"
@.str.4 = [40 x i8] c"======================================\0A\00"
define i32 @ocsp_resp_cb(i32* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i32 @SSL_get_tlsext_status_ocsp_resp(i32* %0, i8** %3)
%6 = call i32 @BIO_puts(i8* %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @BIO_puts(i8* %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %23
11: ; preds = %2
%12 = call i32* @d2i_OCSP_RESPONSE(i32* null, i8** %3, i32 %5)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = call i32 @BIO_puts(i8* %1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%16 = load i8*, i8** %3
%17 = call i32 @BIO_dump_indent(i8* %1, i8* %16, i32 %5, i32 4)
br label %23
18: ; preds = %11
%19 = call i32 @BIO_puts(i8* %1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @OCSP_RESPONSE_print(i8* %1, i32* %12, i32 0)
%21 = call i32 @BIO_puts(i8* %1, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 @OCSP_RESPONSE_free(i32* %12)
br label %23
23: ; preds = %18, %14, %9
%24 = phi i32 [ 1, %18 ], [ 0, %14 ], [ 1, %9 ]
ret i32 %24
}