#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*/ TS_RESP_CTX;
typedef int /*<<< orphan*/ ASN1_INTEGER;

/* Variables and functions */
int /*<<< orphan*/ TS_INFO_ADD_INFO_NOT_AVAILABLE;
int /*<<< orphan*/ TS_RESP_CTX_add_failure_info(int /*<<< orphan*/ *,
                                                int /*<<< orphan*/);
int /*<<< orphan*/ TS_RESP_CTX_set_status_info(int /*<<< orphan*/ *,
                                               int /*<<< orphan*/, char *);
int /*<<< orphan*/ TS_STATUS_REJECTION;
int /*<<< orphan*/ *next_serial(char const *);
int /*<<< orphan*/ save_ts_serial(char const *, int /*<<< orphan*/ *);
ASN1_INTEGER *serial_cb(TS_RESP_CTX *ctx, void *data) {
  const char *serial_file = (const char *)data;
  ASN1_INTEGER *serial = next_serial(serial_file);
  if (!serial) {
    TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION,
                                "Error during serial number "
                                "generation.");
    TS_RESP_CTX_add_failure_info(ctx, TS_INFO_ADD_INFO_NOT_AVAILABLE);
  } else
    save_ts_serial(serial_file, serial);
  return serial;
}


x86 assembly (clang, -O0):
<serial_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <next_serial@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a0 <serial_cb+0x60>
mov    -0x8(%rbp),%rdi
mov    0x2e5d(%rip),%rax
mov    (%rax),%esi
lea    0xe7c(%rip),%rdx
call   1030 <TS_RESP_CTX_set_status_info@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
call   1060 <TS_RESP_CTX_add_failure_info@plt>
jmp    11ad <serial_cb+0x6d>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <save_ts_serial@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_cb>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <next_serial@plt>
mov    %rax,%r15
test   %rax,%rax
je     1168 <serial_cb+0x28>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <save_ts_serial@plt>
jmp    1191 <serial_cb+0x51>
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
lea    0xe88(%rip),%rdx
mov    %r14,%rdi
call   1030 <TS_RESP_CTX_set_status_info@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1060 <TS_RESP_CTX_add_failure_info@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@TS_STATUS_REJECTION = global i32 0
@.str = [39 x i8] c"Error during serial number generation.\00"
@TS_INFO_ADD_INFO_NOT_AVAILABLE = global i32 0
define i32* @serial_cb(i32* %0, i8* %1) {
%3 = tail call i32* @next_serial(i8* %1)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @TS_STATUS_REJECTION
%7 = tail call i32 @TS_RESP_CTX_set_status_info(i32* %0, i32 %6, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @TS_INFO_ADD_INFO_NOT_AVAILABLE
%9 = tail call i32 @TS_RESP_CTX_add_failure_info(i32* %0, i32 %8)
br label %12
10: ; preds = %2
%11 = tail call i32 @save_ts_serial(i8* %1, i32* %3)
br label %12
12: ; preds = %10, %5
ret i32* %3
}