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

/* Variables and functions */
scalar_t__ ASN1_INTEGER_cmp(int /*<<< orphan*/ const *,
                            int /*<<< orphan*/ const *);
int /*<<< orphan*/ TS_F_TS_CHECK_NONCES;
int /*<<< orphan*/ TS_R_NONCE_MISMATCH;
int /*<<< orphan*/ TS_R_NONCE_NOT_RETURNED;
int /*<<< orphan*/ *TS_TST_INFO_get_nonce(int /*<<< orphan*/ *);
int /*<<< orphan*/ TSerr(int /*<<< orphan*/, int /*<<< orphan*/);
int TS_check_nonces(const ASN1_INTEGER *a, TS_TST_INFO *tst_info) {
  const ASN1_INTEGER *b = TS_TST_INFO_get_nonce(tst_info);
  if (!b) {
    TSerr(TS_F_TS_CHECK_NONCES, TS_R_NONCE_NOT_RETURNED);
    return 0;
  }
  if (ASN1_INTEGER_cmp(a, b) != 0) {
    TSerr(TS_F_TS_CHECK_NONCES, TS_R_NONCE_MISMATCH);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<TS_check_nonces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <TS_TST_INFO_get_nonce@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    117b <TS_check_nonces+0x4b>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
call   1030 <TSerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bc <TS_check_nonces+0x8c>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <ASN1_INTEGER_cmp@plt>
cmp    $0x0,%rax
je     11b5 <TS_check_nonces+0x85>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
call   1030 <TSerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bc <TS_check_nonces+0x8c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TS_check_nonces>:
push   %rbx
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <TS_TST_INFO_get_nonce@plt>
test   %rax,%rax
je     115a <TS_check_nonces+0x2a>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <ASN1_INTEGER_cmp@plt>
test   %rax,%rax
je     1175 <TS_check_nonces+0x45>
mov    0x2e98(%rip),%rax
jmp    1161 <TS_check_nonces+0x31>
mov    0x2e67(%rip),%rax
mov    0x2e70(%rip),%rcx
mov    (%rcx),%edi
mov    (%rax),%esi
call   1030 <TSerr@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@TS_F_TS_CHECK_NONCES = global i32 0
@TS_R_NONCE_NOT_RETURNED = global i32 0
@TS_R_NONCE_MISMATCH = global i32 0
define i32 @TS_check_nonces(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
%7 = load i32*, i32** %5
%8 = call i32* @TS_TST_INFO_get_nonce(i32* %7)
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp ne i32* %9, null
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32, i32* @TS_F_TS_CHECK_NONCES
%13 = load i32, i32* @TS_R_NONCE_NOT_RETURNED
%14 = call i32 @TSerr(i32 %12, i32 %13)
store i32 0, i32* %3
br label %25
15: ; preds = %2
%16 = load i32*, i32** %4
%17 = load i32*, i32** %6
%18 = call i64 @ASN1_INTEGER_cmp(i32* %16, i32* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* @TS_F_TS_CHECK_NONCES
%22 = load i32, i32* @TS_R_NONCE_MISMATCH
%23 = call i32 @TSerr(i32 %21, i32 %22)
store i32 0, i32* %3
br label %25
24: ; preds = %15
store i32 1, i32* %3
br label %25
25: ; preds = %24, %20, %11
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@TS_F_TS_CHECK_NONCES = global i32 0
@TS_R_NONCE_NOT_RETURNED = global i32 0
@TS_R_NONCE_MISMATCH = global i32 0
define i32 @TS_check_nonces(i32* %0, i32* %1) {
%3 = tail call i32* @TS_TST_INFO_get_nonce(i32* %1)
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i64 @ASN1_INTEGER_cmp(i32* %0, i32* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %5, %2
%9 = phi i32* [ @TS_R_NONCE_NOT_RETURNED, %2 ], [ @TS_R_NONCE_MISMATCH, %5 ]
%10 = load i32, i32* @TS_F_TS_CHECK_NONCES
%11 = load i32, i32* %9
%12 = tail call i32 @TSerr(i32 %10, i32 %11)
br label %13
13: ; preds = %8, %5
%14 = phi i32 [ 1, %5 ], [ 0, %8 ]
ret i32 %14
}