#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*/ tm1;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ ASN1_TIME;

/* Variables and functions */
int /*<<< orphan*/ ASN1_TIME_set_tm(int /*<<< orphan*/ *, struct tm *);
int ASN1_time_parse(char *, int /*<<< orphan*/, struct tm *,
                    int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strlen(char *);
int setCertificateTime(ASN1_TIME *x509time, char *timestring) {
  struct tm tm1;
  memset(&tm1, 0, sizeof(tm1));
  if (ASN1_time_parse(timestring, strlen(timestring), &tm1, 0) == -1)
    return (-1);
  if (!ASN1_TIME_set_tm(x509time, &tm1))
    return (-1);
  return 0;
}


x86 assembly (clang, -O0):
<setCertificateTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
lea    -0x20(%rbp),%rdx
xor    %ecx,%ecx
call   1050 <ASN1_time_parse@plt>
cmp    $0xffffffff,%eax
jne    1197 <setCertificateTime+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <setCertificateTime+0x80>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <ASN1_TIME_set_tm@plt>
cmp    $0x0,%eax
jne    11b9 <setCertificateTime+0x79>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <setCertificateTime+0x80>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setCertificateTime>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1050 <ASN1_time_parse@plt>
cmp    $0xffffffff,%eax
je     1193 <setCertificateTime+0x53>
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1060 <ASN1_TIME_set_tm@plt>
cmp    $0x1,%eax
sbb    %eax,%eax
jmp    1198 <setCertificateTime+0x58>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
define i32 @setCertificateTime(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca %struct.tm
store i32* %0, i32** %4
store i8* %1, i8** %5
%7 = call i32 @memset(%struct.tm* %6, i32 0, i32 4)
%8 = load i8*, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @ASN1_time_parse(i8* %8, i32 %10, %struct.tm* %6, i32 0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -1, i32* %3
br label %20
14: ; preds = %2
%15 = load i32*, i32** %4
%16 = call i32 @ASN1_TIME_set_tm(i32* %15, %struct.tm* %6)
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %14
store i32 -1, i32* %3
br label %20
19: ; preds = %14
store i32 0, i32* %3
br label %20
20: ; preds = %19, %18, %13
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
%struct.tm = type { i32 }
define i32 @setCertificateTime(i32* %0, i8* %1) {
%3 = alloca %struct.tm
%4 = bitcast %struct.tm* %3 to i8*
%5 = call i32 @memset(%struct.tm* %3, i32 0, i32 4)
%6 = call i32 @strlen(i8* %1)
%7 = call i32 @ASN1_time_parse(i8* %1, i32 %6, %struct.tm* %3, i32 0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = call i32 @ASN1_TIME_set_tm(i32* %0, %struct.tm* %3)
%11 = icmp eq i32 %10, 0
%12 = sext i1 %11 to i32
br label %13
13: ; preds = %9, %2
%14 = phi i32 [ -1, %2 ], [ %12, %9 ]
ret i32 %14
}