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

/* Type definitions */
struct TYPE_3__ {
  char *data;
  int type;
  int /*<<< orphan*/ length;
};
typedef TYPE_1__ ASN1_TIME;

/* Variables and functions */
int ASN1_time_parse(char const *, int /*<<< orphan*/, int /*<<< orphan*/ *,
                    int);
int /*<<< orphan*/ free(char *);
char *strdup(char const *);
int /*<<< orphan*/ strlen(char const *);
int ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode) {
  int type;
  char *tmp;
  if ((type = ASN1_time_parse(str, strlen(str), NULL, mode)) == -1)
    return (0);
  if (mode != 0 && mode != type)
    return (0);
  if (s == NULL)
    return (1);
  if ((tmp = strdup(str)) == NULL)
    return (0);
  free(s->data);
  s->data = tmp;
  s->length = strlen(tmp);
  s->type = type;
  return (1);
}


x86 assembly (clang, -O0):
<ASN1_TIME_set_string_internal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%edx
call   1050 <ASN1_time_parse@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    118e <ASN1_TIME_set_string_internal+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    1224 <ASN1_TIME_set_string_internal+0xe4>
cmpl   $0x0,-0x1c(%rbp)
je     11b0 <ASN1_TIME_set_string_internal+0x70>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
je     11b0 <ASN1_TIME_set_string_internal+0x70>
movl   $0x0,-0x4(%rbp)
jmp    1224 <ASN1_TIME_set_string_internal+0xe4>
cmpq   $0x0,-0x10(%rbp)
jne    11c7 <ASN1_TIME_set_string_internal+0x87>
movl   $0x1,-0x4(%rbp)
jmp    1224 <ASN1_TIME_set_string_internal+0xe4>
mov    -0x18(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11ea <ASN1_TIME_set_string_internal+0xaa>
movl   $0x0,-0x4(%rbp)
jmp    1224 <ASN1_TIME_set_string_internal+0xe4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_TIME_set_string_internal>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
xor    %r15d,%r15d
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
mov    %ebp,%ecx
call   1050 <ASN1_time_parse@plt>
cmp    $0xffffffff,%eax
je     11b0 <ASN1_TIME_set_string_internal+0x70>
mov    %eax,%r12d
test   %ebp,%ebp
je     117a <ASN1_TIME_set_string_internal+0x3a>
cmp    %ebp,%r12d
jne    11b0 <ASN1_TIME_set_string_internal+0x70>
test   %r14,%r14
je     11aa <ASN1_TIME_set_string_internal+0x6a>
mov    %rbx,%rdi
call   1060 <strdup@plt>
test   %rax,%rax
je     11b0 <ASN1_TIME_set_string_internal+0x70>
mov    %rax,%rbx
mov    (%r14),%rdi
call   1030 <free@plt>
mov    %rbx,(%r14)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,0xc(%r14)
mov    %r12d,0x8(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8*, i32, i32 }
define i32 @ASN1_TIME_set_string_internal(%struct.TYPE_3__* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %6
%11 = load i8*, i8** %6
%12 = call i32 @strlen(i8* %11)
%13 = load i32, i32* %7
%14 = call i32 @ASN1_time_parse(i8* %10, i32 %12, i32* null, i32 %13)
store i32 %14, i32* %8
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 0, i32* %4
br label %49
17: ; preds = %3
%18 = load i32, i32* %7
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 0, i32* %4
br label %49
25: ; preds = %20, %17
%26 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%27 = icmp eq %struct.TYPE_3__* %26, null
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 1, i32* %4
br label %49
29: ; preds = %25
%30 = load i8*, i8** %6
%31 = call i8* @strdup(i8* %30)
store i8* %31, i8** %9
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 0, i32* %4
br label %49
34: ; preds = %29
%35 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%36 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %35, i32 0, i32 0
%37 = load i8*, i8** %36
%38 = call i32 @free(i8* %37)
%39 = load i8*, i8** %9
%40 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%41 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %40, i32 0, i32 0
store i8* %39, i8** %41
%42 = load i8*, i8** %9
%43 = call i32 @strlen(i8* %42)
%44 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%45 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %44, i32 0, i32 2
store i32 %43, i32* %45
%46 = load i32, i32* %8
%47 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%48 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %47, i32 0, i32 1
store i32 %46, i32* %48
store i32 1, i32* %4
br label %49
49: ; preds = %34, %33, %28, %24, %16
%50 = load i32, i32* %4
ret i32 %50
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8*, i32, i32 }
define i32 @ASN1_TIME_set_string_internal(%struct.TYPE_3__* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @ASN1_time_parse(i8* %1, i32 %4, i32* null, i32 %2)
%6 = icmp eq i32 %5, -1
br i1 %6, label %23, label %7
7: ; preds = %3
%8 = icmp eq i32 %2, 0
%9 = icmp eq i32 %5, %2
%10 = select i1 %8, i1 true, i1 %9
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = icmp eq %struct.TYPE_3__* %0, null
br i1 %12, label %23, label %13
13: ; preds = %11
%14 = tail call i8* @strdup(i8* %1)
%15 = icmp eq i8* %14, null
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%18 = load i8*, i8** %17
%19 = tail call i32 @free(i8* %18)
store i8* %14, i8** %17
%20 = tail call i32 @strlen(i8* %14)
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 2
store i32 %20, i32* %21
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
store i32 %5, i32* %22
br label %23
23: ; preds = %13, %11, %7, %3, %16
%24 = phi i32 [ 1, %16 ], [ 0, %3 ], [ 0, %7 ], [ 1, %11 ], [ 0, %13 ]
ret i32 %24
}