#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_F_DEF_SERIAL_CB;
int /*<<< orphan*/ TS_RESP_CTX_set_status_info(struct TS_resp_ctx *,
                                               int /*<<< orphan*/, char *);
int /*<<< orphan*/ TS_STATUS_REJECTION;
int /*<<< orphan*/ TSerr(int /*<<< orphan*/, 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:
  TSerr(TS_F_DEF_SERIAL_CB, 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   1060 <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    11cc <def_serial_cb+0x8c>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
mov    0x2e44(%rip),%rax
mov    (%rax),%esi
call   1040 <TSerr@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
lea    0xe41(%rip),%rdx
call   1050 <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   1060 <ASN1_INTEGER_set@plt>
test   %eax,%eax
jne    1198 <def_serial_cb+0x58>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
call   1040 <TSerr@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
lea    0xe72(%rip),%rdx
mov    %r14,%rdi
call   1050 <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 }
@TS_F_DEF_SERIAL_CB = global i32 0
@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 %25
18: ; preds = %15, %10
%19 = load i32, i32* @TS_F_DEF_SERIAL_CB
%20 = load i32, i32* @ERR_R_MALLOC_FAILURE
%21 = call i32 @TSerr(i32 %19, i32 %20)
%22 = load %struct.TS_resp_ctx*, %struct.TS_resp_ctx** %4
%23 = load i32, i32* @TS_STATUS_REJECTION
%24 = call i32 @TS_RESP_CTX_set_status_info(%struct.TS_resp_ctx* %22, i32 %23, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store i32* null, i32** %3
br label %25
25: ; preds = %18, %16
%26 = load i32*, i32** %3
ret i32* %26
}

LLVM IR (-O2):
%struct.TS_resp_ctx = type { i32 }
@TS_F_DEF_SERIAL_CB = global i32 0
@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 %14
8: ; preds = %5, %2
%9 = load i32, i32* @TS_F_DEF_SERIAL_CB
%10 = load i32, i32* @ERR_R_MALLOC_FAILURE
%11 = tail call i32 @TSerr(i32 %9, i32 %10)
%12 = load i32, i32* @TS_STATUS_REJECTION
%13 = tail call i32 @TS_RESP_CTX_set_status_info(%struct.TS_resp_ctx* %0, i32 %12, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %5, %8
%15 = phi i32* [ null, %8 ], [ %3, %5 ]
ret i32* %15
}