#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*/ time_t;
struct tm {
  int tm_year;
  int /*<<< orphan*/ tm_mon;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
  int /*<<< orphan*/ tm_mday;
};

/* Variables and functions */
int sscanf(char *, char *, int *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           char *);
size_t strlen(char *);
int /*<<< orphan*/ timegm(struct tm *);
time_t grid_asn1TimeToTimeT(char *asn1time, size_t len) {
  char zone;
  struct tm time_tm;
  if (len == 0)
    len = strlen(asn1time);
  if ((len != 13) && (len != 15))
    return 0;
  if ((len == 13) &&
      ((sscanf(asn1time, "%02d%02d%02d%02d%02d%02d%c", &(time_tm.tm_year),
               &(time_tm.tm_mon), &(time_tm.tm_mday), &(time_tm.tm_hour),
               &(time_tm.tm_min), &(time_tm.tm_sec), &zone) != 7) ||
       (zone != 'Z')))
    return 0;
  if ((len == 15) &&
      ((sscanf(asn1time, "20%02d%02d%02d%02d%02d%02d%c", &(time_tm.tm_year),
               &(time_tm.tm_mon), &(time_tm.tm_mday), &(time_tm.tm_hour),
               &(time_tm.tm_min), &(time_tm.tm_sec), &zone) != 7) ||
       (zone != 'Z')))
    return 0;
  if (time_tm.tm_year < 90)
    time_tm.tm_year += 100;
  --(time_tm.tm_mon);
  return timegm(&time_tm);
}


x86 assembly (clang, -O0):
<grid_asn1TimeToTimeT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1158 <grid_asn1TimeToTimeT+0x28>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0xd,-0x18(%rbp)
je     117a <grid_asn1TimeToTimeT+0x4a>
cmpq   $0xf,-0x18(%rbp)
je     117a <grid_asn1TimeToTimeT+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    1298 <grid_asn1TimeToTimeT+0x168>
cmpq   $0xd,-0x18(%rbp)
jne    11f5 <grid_asn1TimeToTimeT+0xc5>
mov    -0x10(%rbp),%rdi
lea    -0x38(%rbp),%rdx
lea    -0x38(%rbp),%rcx
add    $0x4,%rcx
lea    -0x38(%rbp),%r8
add    $0x14,%r8
lea    -0x38(%rbp),%r9
add    $0x10,%r9
lea    -0x38(%rbp),%r11
add    $0xc,%r11
lea    -0x38(%rbp),%r10
add    $0x8,%r10
lea    0xe46(%rip),%rsi
lea    -0x19(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <sscanf@plt>
cmp    $0x7,%eax
jne    11e9 <grid_asn1TimeToTimeT+0xb9>
movsbl -0x19(%rbp),%eax
cmp    $0x5a,%eax
je     11f5 <grid_asn1TimeToTimeT+0xc5>
movl   $0x0,-0x4(%rbp)
jmp    1298 <grid_asn1TimeToTimeT+0x168>
cmpq   $0xf,-0x18(%rbp)
jne    1270 <grid_asn1TimeToTimeT+0x140>
mov    -0x10(%rbp),%rdi
lea    -0x38(%rbp),%rdx
lea    -0x38(%rbp),%rcx
add    $0x4,%rcx
lea    -0x38(%rbp),%r8
add    $0x14,%r8
lea    -0x38(%rbp),%r9
add    $0x10,%r9
lea    -0x38(%rbp),%r11
add    $0xc,%r11
lea    -0x38(%rbp),%r10
add    $0x8,%r10
lea    0xdc9(%rip),%rsi
lea    -0x19(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <sscanf@plt>
cmp    $0x7,%eax
jne    1264 <grid_asn1TimeToTimeT+0x134>
movsbl -0x19(%rbp),%eax
cmp    $0x5a,%eax
je     1270 <grid_asn1TimeToTimeT+0x140>
movl   $0x0,-0x4(%rbp)
jmp    1298 <grid_asn1TimeToTimeT+0x168>
cmpl   $0x5a,-0x38(%rbp)
jge    1283 <grid_asn1TimeToTimeT+0x153>
mov    -0x38(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
lea    -0x38(%rbp),%rdi
call   1050 <timegm@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_asn1TimeToTimeT>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
test   %rsi,%rsi
jne    1149 <grid_asn1TimeToTimeT+0x19>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
mov    %rsi,%rax
and    $0xfffffffffffffffd,%rax
xor    %ebp,%ebp
cmp    $0xd,%rax
jne    11ff <grid_asn1TimeToTimeT+0xcf>
cmp    $0xf,%rsi
je     1193 <grid_asn1TimeToTimeT+0x63>
cmp    $0xd,%rsi
jne    11de <grid_asn1TimeToTimeT+0xae>
lea    0x14(%rsp),%rcx
lea    0x24(%rsp),%r8
lea    0x20(%rsp),%r9
lea    0x1c(%rsp),%r10
lea    0x18(%rsp),%r11
sub    $0x8,%rsp
lea    0x17(%rsp),%rax
lea    0xe71(%rip),%rsi
jmp    11bc <grid_asn1TimeToTimeT+0x8c>
lea    0x14(%rsp),%rcx
lea    0x24(%rsp),%r8
lea    0x20(%rsp),%r9
lea    0x1c(%rsp),%r10
lea    0x18(%rsp),%r11
sub    $0x8,%rsp
lea    0x17(%rsp),%rax
lea    0xe44(%rip),%rsi
lea    0x18(%rsp),%rdx
mov    %rbx,%rdi
push   %rax
push   %r11
push   %r10
call   1040 <sscanf@plt>
add    $0x20,%rsp
cmp    $0x7,%eax
jne    11ff <grid_asn1TimeToTimeT+0xcf>
cmpb   $0x5a,0xf(%rsp)
jne    11ff <grid_asn1TimeToTimeT+0xcf>
mov    0x10(%rsp),%eax
cmp    $0x59,%eax
jg     11ee <grid_asn1TimeToTimeT+0xbe>
add    $0x64,%eax
mov    %eax,0x10(%rsp)
addl   $0xffffffff,0x14(%rsp)
lea    0x10(%rsp),%rdi
call   1050 <timegm@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [27 x i8] c"%02d%02d%02d%02d%02d%02d%c\00"
@.str.1 = [29 x i8] c"20%02d%02d%02d%02d%02d%02d%c\00"
define i32 @grid_asn1TimeToTimeT(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8
%7 = alloca %struct.tm
store i8* %0, i8** %4
store i64 %1, i64* %5
%8 = load i64, i64* %5
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %5
br label %13
13: ; preds = %10, %2
%14 = load i64, i64* %5
%15 = icmp ne i64 %14, 13
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i64, i64* %5
%18 = icmp ne i64 %17, 15
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 0, i32* %3
br label %69
20: ; preds = %16, %13
%21 = load i64, i64* %5
%22 = icmp eq i64 %21, 13
br i1 %22, label %23, label %38
23: ; preds = %20
%24 = load i8*, i8** %4
%25 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 0
%26 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 1
%27 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 5
%28 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 4
%29 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 3
%30 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 2
%31 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32* %25, i32* %26, i32* %27, i32* %28, i32* %29, i32* %30, i8* %6)
%32 = icmp ne i32 %31, 7
br i1 %32, label %37, label %33
33: ; preds = %23
%34 = load i8, i8* %6
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 90
br i1 %36, label %37, label %38
37: ; preds = %33, %23
store i32 0, i32* %3
br label %69
38: ; preds = %33, %20
%39 = load i64, i64* %5
%40 = icmp eq i64 %39, 15
br i1 %40, label %41, label %56
41: ; preds = %38
%42 = load i8*, i8** %4
%43 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 0
%44 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 1
%45 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 5
%46 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 4
%47 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 3
%48 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 2
%49 = call i32 @sscanf(i8* %42, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32* %43, i32* %44, i32* %45, i32* %46, i32* %47, i32* %48, i8* %6)
%50 = icmp ne i32 %49, 7
br i1 %50, label %55, label %51
51: ; preds = %41
%52 = load i8, i8* %6
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 90
br i1 %54, label %55, label %56
55: ; preds = %51, %41
store i32 0, i32* %3
br label %69
56: ; preds = %51, %38
%57 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 0
%58 = load i32, i32* %57
%59 = icmp slt i32 %58, 90
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 0
%62 = load i32, i32* %61
%63 = add nsw i32 %62, 100
store i32 %63, i32* %61
br label %64
64: ; preds = %60, %56
%65 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 1
%66 = load i32, i32* %65
%67 = add nsw i32 %66, -1
store i32 %67, i32* %65
%68 = call i32 @timegm(%struct.tm* %7)
store i32 %68, i32* %3
br label %69
69: ; preds = %64, %55, %37, %19
%70 = load i32, i32* %3
ret i32 %70
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [27 x i8] c"%02d%02d%02d%02d%02d%02d%c\00"
@.str.1 = [29 x i8] c"20%02d%02d%02d%02d%02d%02d%c\00"
define i32 @grid_asn1TimeToTimeT(i8* nocapture %0, i64 %1) {
%3 = alloca i8
%4 = alloca %struct.tm
%5 = bitcast %struct.tm* %4 to i8*
%6 = icmp eq i64 %1, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i64 @strlen(i8* dereferenceable(1) %0)
br label %9
9: ; preds = %7, %2
%10 = phi i64 [ %8, %7 ], [ %1, %2 ]
%11 = and i64 %10, -3
%12 = icmp eq i64 %11, 13
br i1 %12, label %13, label %49
13: ; preds = %9
switch i64 %10, label %38 [
i64 13, label %14
i64 15, label %26
]
14: ; preds = %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%16 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%17 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%18 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%19 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%20 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%21 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32* %15, i32* %16, i32* %17, i32* %18, i32* %19, i32* %20, i8* %3)
%22 = icmp ne i32 %21, 7
%23 = load i8, i8* %3
%24 = icmp ne i8 %23, 90
%25 = select i1 %22, i1 true, i1 %24
br i1 %25, label %49, label %38
26: ; preds = %13
%27 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%28 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%29 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%30 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%31 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%32 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%33 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32* %27, i32* %28, i32* %29, i32* %30, i32* %31, i32* %32, i8* %3)
%34 = icmp ne i32 %33, 7
%35 = load i8, i8* %3
%36 = icmp ne i8 %35, 90
%37 = select i1 %34, i1 true, i1 %36
br i1 %37, label %49, label %38
38: ; preds = %14, %13, %26
%39 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%40 = load i32, i32* %39
%41 = icmp slt i32 %40, 90
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = add nsw i32 %40, 100
store i32 %43, i32* %39
br label %44
44: ; preds = %42, %38
%45 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%46 = load i32, i32* %45
%47 = add nsw i32 %46, -1
store i32 %47, i32* %45
%48 = call i32 @timegm(%struct.tm* %4)
br label %49
49: ; preds = %26, %14, %9, %44
%50 = phi i32 [ %48, %44 ], [ 0, %9 ], [ 0, %14 ], [ 0, %26 ]
ret i32 %50
}