#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_10__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ time_t;
struct TYPE_10__ {
  int flags;
  scalar_t__ type;
};
typedef TYPE_1__ ASN1_TIME;

/* Variables and functions */
TYPE_1__ *ASN1_GENERALIZEDTIME_adj(TYPE_1__ *, int /*<<< orphan*/, int, long);
int ASN1_STRING_FLAG_MSTRING;
TYPE_1__ *ASN1_TIME_adj(TYPE_1__ *, int /*<<< orphan*/, int, long);
TYPE_1__ *ASN1_UTCTIME_adj(TYPE_1__ *, int /*<<< orphan*/, int, long);
scalar_t__ V_ASN1_GENERALIZEDTIME;
scalar_t__ V_ASN1_UTCTIME;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s, int offset_day, long offset_sec,
                            time_t *in_tm) {
  time_t t;
  if (in_tm)
    t = *in_tm;
  else
    time(&t);
  if (s && !(s->flags & ASN1_STRING_FLAG_MSTRING)) {
    if (s->type == V_ASN1_UTCTIME)
      return ASN1_UTCTIME_adj(s, t, offset_day, offset_sec);
    if (s->type == V_ASN1_GENERALIZEDTIME)
      return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec);
  }
  return ASN1_TIME_adj(s, t, offset_day, offset_sec);
}


x86 assembly (clang, -O0):
<X509_time_adj_ex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1170 <X509_time_adj_ex+0x30>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    1179 <X509_time_adj_ex+0x39>
lea    -0x2c(%rbp),%rdi
call   1060 <time@plt>
cmpq   $0x0,-0x10(%rbp)
je     1209 <X509_time_adj_ex+0xc9>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e57(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1209 <X509_time_adj_ex+0xc9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e25(%rip),%rcx
cmp    (%rcx),%rax
jne    11d0 <X509_time_adj_ex+0x90>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1040 <ASN1_UTCTIME_adj@plt>
mov    %rax,-0x8(%rbp)
jmp    1220 <X509_time_adj_ex+0xe0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e01(%rip),%rcx
cmp    (%rcx),%rax
jne    1204 <X509_time_adj_ex+0xc4>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1030 <ASN1_GENERALIZEDTIME_adj@plt>
mov    %rax,-0x8(%rbp)
jmp    1220 <X509_time_adj_ex+0xe0>
jmp    1209 <X509_time_adj_ex+0xc9>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
call   1050 <ASN1_TIME_adj@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_time_adj_ex>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
test   %rcx,%rcx
je     1162 <X509_time_adj_ex+0x22>
mov    (%rcx),%eax
mov    %eax,0xc(%rsp)
test   %rbx,%rbx
jne    1171 <X509_time_adj_ex+0x31>
jmp    117e <X509_time_adj_ex+0x3e>
lea    0xc(%rsp),%rdi
call   1060 <time@plt>
test   %rbx,%rbx
je     117e <X509_time_adj_ex+0x3e>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
test   %eax,(%rbx)
je     1198 <X509_time_adj_ex+0x58>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %r14,%rcx
call   1050 <ASN1_TIME_adj@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x8(%rbx),%rax
mov    0x2e2d(%rip),%rcx
cmp    (%rcx),%rax
jne    11bb <X509_time_adj_ex+0x7b>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %r14,%rcx
call   1040 <ASN1_UTCTIME_adj@plt>
jmp    118f <X509_time_adj_ex+0x4f>
mov    0x2e1e(%rip),%rcx
cmp    (%rcx),%rax
jne    117e <X509_time_adj_ex+0x3e>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %r14,%rcx
call   1030 <ASN1_GENERALIZEDTIME_adj@plt>
jmp    118f <X509_time_adj_ex+0x4f>

LLVM IR (-O0):
%struct.TYPE_10__ = type { i32, i64 }
@ASN1_STRING_FLAG_MSTRING = global i32 0
@V_ASN1_UTCTIME = global i64 0
@V_ASN1_GENERALIZEDTIME = global i64 0
define %struct.TYPE_10__* @X509_time_adj_ex(%struct.TYPE_10__* %0, i32 %1, i64 %2, i32* %3) {
%5 = alloca %struct.TYPE_10__*
%6 = alloca %struct.TYPE_10__*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i32
store %struct.TYPE_10__* %0, %struct.TYPE_10__** %6
store i32 %1, i32* %7
store i64 %2, i64* %8
store i32* %3, i32** %9
%11 = load i32*, i32** %9
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = load i32*, i32** %9
%15 = load i32, i32* %14
store i32 %15, i32* %10
br label %18
16: ; preds = %4
%17 = call i32 @time(i32* %10)
br label %18
18: ; preds = %16, %13
%19 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%20 = icmp ne %struct.TYPE_10__* %19, null
br i1 %20, label %21, label %53
21: ; preds = %18
%22 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%23 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = load i32, i32* @ASN1_STRING_FLAG_MSTRING
%26 = and i32 %24, %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %53, label %28
28: ; preds = %21
%29 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%30 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %29, i32 0, i32 1
%31 = load i64, i64* %30
%32 = load i64, i64* @V_ASN1_UTCTIME
%33 = icmp eq i64 %31, %32
br i1 %33, label %34, label %40
34: ; preds = %28
%35 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%36 = load i32, i32* %10
%37 = load i32, i32* %7
%38 = load i64, i64* %8
%39 = call %struct.TYPE_10__* @ASN1_UTCTIME_adj(%struct.TYPE_10__* %35, i32 %36, i32 %37, i64 %38)
store %struct.TYPE_10__* %39, %struct.TYPE_10__** %5
br label %59
40: ; preds = %28
%41 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%42 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %41, i32 0, i32 1
%43 = load i64, i64* %42
%44 = load i64, i64* @V_ASN1_GENERALIZEDTIME
%45 = icmp eq i64 %43, %44
br i1 %45, label %46, label %52
46: ; preds = %40
%47 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%48 = load i32, i32* %10
%49 = load i32, i32* %7
%50 = load i64, i64* %8
%51 = call %struct.TYPE_10__* @ASN1_GENERALIZEDTIME_adj(%struct.TYPE_10__* %47, i32 %48, i32 %49, i64 %50)
store %struct.TYPE_10__* %51, %struct.TYPE_10__** %5
br label %59
52: ; preds = %40
br label %53
53: ; preds = %52, %21, %18
%54 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%55 = load i32, i32* %10
%56 = load i32, i32* %7
%57 = load i64, i64* %8
%58 = call %struct.TYPE_10__* @ASN1_TIME_adj(%struct.TYPE_10__* %54, i32 %55, i32 %56, i64 %57)
store %struct.TYPE_10__* %58, %struct.TYPE_10__** %5
br label %59
59: ; preds = %53, %46, %34
%60 = load %struct.TYPE_10__*, %struct.TYPE_10__** %5
ret %struct.TYPE_10__* %60
}

LLVM IR (-O2):
%struct.TYPE_10__ = type { i32, i64 }
@ASN1_STRING_FLAG_MSTRING = global i32 0
@V_ASN1_UTCTIME = global i64 0
@V_ASN1_GENERALIZEDTIME = global i64 0
define %struct.TYPE_10__* @X509_time_adj_ex(%struct.TYPE_10__* %0, i32 %1, i64 %2, i32* %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = icmp eq i32* %3, null
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = load i32, i32* %3
store i32 %9, i32* %5
br label %12
10: ; preds = %4
%11 = call i32 @time(i32* %5)
br label %12
12: ; preds = %10, %8
%13 = icmp eq %struct.TYPE_10__* %0, null
br i1 %13, label %34, label %14
14: ; preds = %12
%15 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %0, i64 0, i32 0
%16 = load i32, i32* %15
%17 = load i32, i32* @ASN1_STRING_FLAG_MSTRING
%18 = and i32 %17, %16
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %34
20: ; preds = %14
%21 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %0, i64 0, i32 1
%22 = load i64, i64* %21
%23 = load i64, i64* @V_ASN1_UTCTIME
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32, i32* %5
%27 = call %struct.TYPE_10__* @ASN1_UTCTIME_adj(%struct.TYPE_10__* %0, i32 %26, i32 %1, i64 %2)
br label %37
28: ; preds = %20
%29 = load i64, i64* @V_ASN1_GENERALIZEDTIME
%30 = icmp eq i64 %22, %29
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %5
%33 = call %struct.TYPE_10__* @ASN1_GENERALIZEDTIME_adj(%struct.TYPE_10__* %0, i32 %32, i32 %1, i64 %2)
br label %37
34: ; preds = %28, %14, %12
%35 = load i32, i32* %5
%36 = call %struct.TYPE_10__* @ASN1_TIME_adj(%struct.TYPE_10__* %0, i32 %35, i32 %1, i64 %2)
br label %37
37: ; preds = %34, %31, %25
%38 = phi %struct.TYPE_10__* [ %36, %34 ], [ %27, %25 ], [ %33, %31 ]
ret %struct.TYPE_10__* %38
}