#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 */
struct TS_resp_ctx {
  int dummy;
};
typedef int /*<<< orphan*/ ASN1_INTEGER;

/* Variables and functions */
int /*<<< orphan*/ *ASN1_INTEGER_new();
int /*<<< orphan*/ ASN1_INTEGER_set(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ TS_RESP_CTX_set_status_info(struct TS_resp_ctx *,
                                               int /*<<< orphan*/, char *);
int /*<<< orphan*/ TS_STATUS_REJECTION;
int /*<<< orphan*/ TSerror(int /*<<< orphan*/);
ASN1_INTEGER *def_serial_cb(struct TS_resp_ctx *ctx, void *data) {
  ASN1_INTEGER *serial = ASN1_INTEGER_new();
  if (!serial)
    goto err;
  if (!ASN1_INTEGER_set(serial, 1))
    goto err;
  return serial;
err:
  TSerror(ERR_R_MALLOC_FAILURE);
  TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION,
                              "Error during serial number generation.");
  return NULL;
}


x86 assembly (clang, -O0):
<def_serial_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1030 <ASN1_INTEGER_new@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116b <def_serial_cb+0x2b>
jmp    1194 <def_serial_cb+0x54>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1050 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    1187 <def_serial_cb+0x47>
jmp    1194 <def_serial_cb+0x54>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <def_serial_cb+0x83>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1060 <TSerror@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
lea    0xe4a(%rip),%rdx
call   1040 <TS_RESP_CTX_set_status_info@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<def_serial_cb>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <ASN1_INTEGER_new@plt>
test   %rax,%rax
je     1167 <def_serial_cb+0x27>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
call   1050 <ASN1_INTEGER_set@plt>
test   %eax,%eax
jne    118f <def_serial_cb+0x4f>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
call   1060 <TSerror@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
lea    0xe7b(%rip),%rdx
mov    %r14,%rdi
call   1040 <TS_RESP_CTX_set_status_info@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TS_resp_ctx = type { i32 }
@ERR_R_MALLOC_FAILURE = global i32 0
@TS_STATUS_REJECTION = global i32 0
@.str = [39 x i8] c"Error during serial number generation.\00"
define i32* @def_serial_cb(%struct.TS_resp_ctx* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca %struct.TS_resp_ctx*
%5 = alloca i8*
%6 = alloca i32*
store %struct.TS_resp_ctx* %0, %struct.TS_resp_ctx** %4
store i8* %1, i8** %5
%7 = call i32* (...) @ASN1_INTEGER_new()
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = icmp ne i32* %8, null
br i1 %9, label %11, label %10
10: ; preds = %2
br label %18
11: ; preds = %2
%12 = load i32*, i32** %6
%13 = call i32 @ASN1_INTEGER_set(i32* %12, i32 1)
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %11
br label %18
16: ; preds = %11
%17 = load i32*, i32** %6
store i32* %17, i32** %3
br label %24
18: ; preds = %15, %10
%19 = load i32, i32* @ERR_R_MALLOC_FAILURE
%20 = call i32 @TSerror(i32 %19)
%21 = load %struct.TS_resp_ctx*, %struct.TS_resp_ctx** %4
%22 = load i32, i32* @TS_STATUS_REJECTION
%23 = call i32 @TS_RESP_CTX_set_status_info(%struct.TS_resp_ctx* %21, i32 %22, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store i32* null, i32** %3
br label %24
24: ; preds = %18, %16
%25 = load i32*, i32** %3
ret i32* %25
}

LLVM IR (-O2):
%struct.TS_resp_ctx = type { i32 }
@ERR_R_MALLOC_FAILURE = global i32 0
@TS_STATUS_REJECTION = global i32 0
@.str = [39 x i8] c"Error during serial number generation.\00"
define i32* @def_serial_cb(%struct.TS_resp_ctx* %0, i8* nocapture readnone %1) {
%3 = tail call i32* (...) @ASN1_INTEGER_new()
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @ASN1_INTEGER_set(i32* %3, i32 1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %5, %2
%9 = load i32, i32* @ERR_R_MALLOC_FAILURE
%10 = tail call i32 @TSerror(i32 %9)
%11 = load i32, i32* @TS_STATUS_REJECTION
%12 = tail call i32 @TS_RESP_CTX_set_status_info(%struct.TS_resp_ctx* %0, i32 %11, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %5, %8
%14 = phi i32* [ null, %8 ], [ %3, %5 ]
ret i32* %14
}