#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 */
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  int /*<<< orphan*/ type;
};
typedef int /*<<< orphan*/ CMS_SignerInfo;
typedef TYPE_1__ ASN1_TIME;

/* Variables and functions */
int /*<<< orphan*/ ASN1_TIME_free(TYPE_1__ *);
int /*<<< orphan*/ CMS_F_CMS_ADD1_SIGNINGTIME;
scalar_t__ CMS_signed_add1_attr_by_NID(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                       int /*<<< orphan*/, TYPE_1__ *, int);
int /*<<< orphan*/ CMSerr(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ NID_pkcs9_signingTime;
TYPE_1__ *X509_gmtime_adj(int /*<<< orphan*/ *, int /*<<< orphan*/);
int cms_add1_signingTime(CMS_SignerInfo *si, ASN1_TIME *t) {
  ASN1_TIME *tt;
  int r = 0;
  if (t)
    tt = t;
  else
    tt = X509_gmtime_adj(NULL, 0);
  if (!tt)
    goto merr;
  if (CMS_signed_add1_attr_by_NID(si, NID_pkcs9_signingTime, tt->type, tt,
                                  -1) <= 0)
    goto merr;
  r = 1;
merr:
  if (!t)
    ASN1_TIME_free(tt);
  if (!r)
    CMSerr(CMS_F_CMS_ADD1_SIGNINGTIME, ERR_R_MALLOC_FAILURE);
  return r;
}


x86 assembly (clang, -O0):
<cms_add1_signingTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116f <cms_add1_signingTime+0x2f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    117e <cms_add1_signingTime+0x3e>
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
call   1030 <X509_gmtime_adj@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118e <cms_add1_signingTime+0x4e>
jmp    11c6 <cms_add1_signingTime+0x86>
mov    -0x8(%rbp),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rcx
mov    $0xffffffff,%r8d
call   1050 <CMS_signed_add1_attr_by_NID@plt>
cmp    $0x0,%rax
jg     11bf <cms_add1_signingTime+0x7f>
jmp    11c6 <cms_add1_signingTime+0x86>
movl   $0x1,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11da <cms_add1_signingTime+0x9a>
mov    -0x18(%rbp),%rdi
call   1060 <ASN1_TIME_free@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    11fb <cms_add1_signingTime+0xbb>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    0x2dec(%rip),%rax
mov    (%rax),%esi
call   1040 <CMSerr@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cms_add1_signingTime>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rsi,%rbx
test   %rsi,%rsi
jne    116a <cms_add1_signingTime+0x2a>
xor    %r14d,%r14d
xor    %edi,%edi
xor    %esi,%esi
call   1030 <X509_gmtime_adj@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11ae <cms_add1_signingTime+0x6e>
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    %r12,%rdi
mov    %rbx,%rcx
mov    $0xffffffff,%r8d
call   1050 <CMS_signed_add1_attr_by_NID@plt>
mov    %rax,%r12
xor    %r14d,%r14d
test   %rax,%rax
setg   %r14b
test   %r15,%r15
je     119f <cms_add1_signingTime+0x5f>
test   %r12,%r12
jg     11cc <cms_add1_signingTime+0x8c>
jmp    11b5 <cms_add1_signingTime+0x75>
mov    %rbx,%rdi
call   1060 <ASN1_TIME_free@plt>
test   %r12,%r12
jg     11cc <cms_add1_signingTime+0x8c>
jmp    11b5 <cms_add1_signingTime+0x75>
xor    %edi,%edi
call   1060 <ASN1_TIME_free@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
call   1040 <CMSerr@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32 }
@NID_pkcs9_signingTime = global i32 0
@CMS_F_CMS_ADD1_SIGNINGTIME = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define i32 @cms_add1_signingTime(i32* %0, %struct.TYPE_6__* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_6__*
%5 = alloca %struct.TYPE_6__*
%6 = alloca i32
store i32* %0, i32** %3
store %struct.TYPE_6__* %1, %struct.TYPE_6__** %4
store i32 0, i32* %6
%7 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%8 = icmp ne %struct.TYPE_6__* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
store %struct.TYPE_6__* %10, %struct.TYPE_6__** %5
br label %13
11: ; preds = %2
%12 = call %struct.TYPE_6__* @X509_gmtime_adj(i32* null, i32 0)
store %struct.TYPE_6__* %12, %struct.TYPE_6__** %5
br label %13
13: ; preds = %11, %9
%14 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%15 = icmp ne %struct.TYPE_6__* %14, null
br i1 %15, label %17, label %16
16: ; preds = %13
br label %28
17: ; preds = %13
%18 = load i32*, i32** %3
%19 = load i32, i32* @NID_pkcs9_signingTime
%20 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%21 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%24 = call i64 @CMS_signed_add1_attr_by_NID(i32* %18, i32 %19, i32 %22, %struct.TYPE_6__* %23, i32 -1)
%25 = icmp sle i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %17
br label %28
27: ; preds = %17
store i32 1, i32* %6
br label %28
28: ; preds = %27, %26, %16
%29 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%30 = icmp ne %struct.TYPE_6__* %29, null
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load %struct.TYPE_6__*, %struct.TYPE_6__** %5
%33 = call i32 @ASN1_TIME_free(%struct.TYPE_6__* %32)
br label %34
34: ; preds = %31, %28
%35 = load i32, i32* %6
%36 = icmp ne i32 %35, 0
br i1 %36, label %41, label %37
37: ; preds = %34
%38 = load i32, i32* @CMS_F_CMS_ADD1_SIGNINGTIME
%39 = load i32, i32* @ERR_R_MALLOC_FAILURE
%40 = call i32 @CMSerr(i32 %38, i32 %39)
br label %41
41: ; preds = %37, %34
%42 = load i32, i32* %6
ret i32 %42
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32 }
@NID_pkcs9_signingTime = global i32 0
@CMS_F_CMS_ADD1_SIGNINGTIME = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define i32 @cms_add1_signingTime(i32* %0, %struct.TYPE_6__* %1) {
%3 = icmp eq %struct.TYPE_6__* %1, null
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = tail call %struct.TYPE_6__* @X509_gmtime_adj(i32* null, i32 0)
%6 = icmp eq %struct.TYPE_6__* %5, null
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @ASN1_TIME_free(%struct.TYPE_6__* null)
br label %21
9: ; preds = %2, %4
%10 = phi %struct.TYPE_6__* [ %5, %4 ], [ %1, %2 ]
%11 = load i32, i32* @NID_pkcs9_signingTime
%12 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %10, i64 0, i32 0
%13 = load i32, i32* %12
%14 = tail call i64 @CMS_signed_add1_attr_by_NID(i32* %0, i32 %11, i32 %13, %struct.TYPE_6__* %10, i32 -1)
%15 = icmp slt i64 %14, 1
%16 = xor i1 %15, true
%17 = zext i1 %16 to i32
br i1 %3, label %18, label %20
18: ; preds = %9
%19 = tail call i32 @ASN1_TIME_free(%struct.TYPE_6__* %10)
br i1 %15, label %21, label %26
20: ; preds = %9
br i1 %15, label %21, label %26
21: ; preds = %7, %18, %20
%22 = phi i32 [ %17, %18 ], [ %17, %20 ], [ 0, %7 ]
%23 = load i32, i32* @CMS_F_CMS_ADD1_SIGNINGTIME
%24 = load i32, i32* @ERR_R_MALLOC_FAILURE
%25 = tail call i32 @CMSerr(i32 %23, i32 %24)
br label %26
26: ; preds = %18, %21, %20
%27 = phi i32 [ %17, %18 ], [ %22, %21 ], [ %17, %20 ]
ret i32 %27
}