#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 scalar_t__ time_t;
struct tm {
  int tm_isdst;
};

/* Variables and functions */
scalar_t__ isdigit(char);
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
scalar_t__ mktime(struct tm *);
long parse_timezone(char *);
char *strptime(char const *, char *, struct tm *);
time_t xep82_datetime(const char *stamp) {
  struct tm tm;
  long offset;
  char *s;
  memset(&tm, 0, sizeof(struct tm));
  if ((s = strptime(stamp, "%Y-%m-%dT%T", &tm)) == NULL)
    return (time_t)-1;
  if (*s++ == '.')
    while (isdigit(*s))
      s++;
  tm.tm_isdst = -1;
  offset = *s != '\0' ? parse_timezone(s) : 0;
  return mktime(&tm) - offset;
}


x86 assembly (clang, -O0):
<xep82_datetime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <strptime@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    119b <xep82_datetime+0x4b>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1234 <xep82_datetime+0xe4>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11e7 <xep82_datetime+0x97>
jmp    11bb <xep82_datetime+0x6b>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11e2 <xep82_datetime+0x92>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11bb <xep82_datetime+0x6b>
jmp    11e7 <xep82_datetime+0x97>
movl   $0xffffffff,-0x18(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1210 <xep82_datetime+0xc0>
mov    -0x28(%rbp),%rdi
call   1050 <parse_timezone@plt>
mov    %rax,-0x30(%rbp)
jmp    121b <xep82_datetime+0xcb>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    121b <xep82_datetime+0xcb>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
call   1060 <mktime@plt>
sub    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xep82_datetime>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1070 <strptime@plt>
test   %rax,%rax
je     11a4 <xep82_datetime+0x54>
mov    %rax,%rbx
cmpb   $0x2e,(%rax)
jne    11ad <xep82_datetime+0x5d>
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1190 <xep82_datetime+0x40>
jmp    11b1 <xep82_datetime+0x61>
mov    $0xffffffffffffffff,%rax
jmp    11d7 <xep82_datetime+0x87>
add    $0x1,%rbx
movl   $0xffffffff,(%rsp)
cmpb   $0x0,(%rbx)
je     11ca <xep82_datetime+0x7a>
mov    %rbx,%rdi
call   1050 <parse_timezone@plt>
mov    %rax,%rbx
jmp    11cc <xep82_datetime+0x7c>
xor    %ebx,%ebx
mov    %rsp,%rdi
call   1060 <mktime@plt>
sub    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [12 x i8] c"%Y-%m-%dT%T\00"
define i64 @xep82_datetime(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca %struct.tm
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %3
%7 = call i32 @memset(%struct.tm* %4, i32 0, i32 4)
%8 = load i8*, i8** %3
%9 = call i8* @strptime(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
store i8* %9, i8** %6
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i64 -1, i64* %2
br label %43
12: ; preds = %1
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %6
%15 = load i8, i8* %13
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 46
br i1 %17, label %18, label %28
18: ; preds = %12
br label %19
19: ; preds = %24, %18
%20 = load i8*, i8** %6
%21 = load i8, i8* %20
%22 = call i64 @isdigit(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %6
br label %19
27: ; preds = %19
br label %28
28: ; preds = %27, %12
%29 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
store i32 -1, i32* %29
%30 = load i8*, i8** %6
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i8*, i8** %6
%36 = call i64 @parse_timezone(i8* %35)
br label %38
37: ; preds = %28
br label %38
38: ; preds = %37, %34
%39 = phi i64 [ %36, %34 ], [ 0, %37 ]
store i64 %39, i64* %5
%40 = call i64 @mktime(%struct.tm* %4)
%41 = load i64, i64* %5
%42 = sub nsw i64 %40, %41
store i64 %42, i64* %2
br label %43
43: ; preds = %38, %11
%44 = load i64, i64* %2
ret i64 %44
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [12 x i8] c"%Y-%m-%dT%T\00"
define i64 @xep82_datetime(i8* %0) {
%2 = alloca %struct.tm
%3 = bitcast %struct.tm* %2 to i8*
%4 = call i32 @memset(%struct.tm* %2, i32 0, i32 4)
%5 = call i8* @strptime(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.tm* %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %28, label %7
7: ; preds = %1
%8 = getelementptr inbounds i8, i8* %5, i64 1
%9 = load i8, i8* %5
%10 = icmp eq i8 %9, 46
br i1 %10, label %11, label %17
11: ; preds = %7, %11
%12 = phi i8* [ %16, %11 ], [ %8, %7 ]
%13 = load i8, i8* %12
%14 = call i64 @isdigit(i8 signext %13)
%15 = icmp eq i64 %14, 0
%16 = getelementptr inbounds i8, i8* %12, i64 1
br i1 %15, label %17, label %11
17: ; preds = %11, %7
%18 = phi i8* [ %8, %7 ], [ %12, %11 ]
%19 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
store i32 -1, i32* %19
%20 = load i8, i8* %18
%21 = icmp eq i8 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = call i64 @parse_timezone(i8* %18)
br label %24
24: ; preds = %17, %22
%25 = phi i64 [ %23, %22 ], [ 0, %17 ]
%26 = call i64 @mktime(%struct.tm* %2)
%27 = sub nsw i64 %26, %25
br label %28
28: ; preds = %1, %24
%29 = phi i64 [ %27, %24 ], [ -1, %1 ]
ret i64 %29
}