#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(int /*<<< orphan*/);
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++))
      ;
  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    1233 <xep82_datetime+0xe3>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11e6 <xep82_datetime+0x96>
jmp    11bb <xep82_datetime+0x6b>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11e1 <xep82_datetime+0x91>
jmp    11bb <xep82_datetime+0x6b>
jmp    11e6 <xep82_datetime+0x96>
movl   $0xffffffff,-0x18(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120f <xep82_datetime+0xbf>
mov    -0x28(%rbp),%rdi
call   1050 <parse_timezone@plt>
mov    %rax,-0x30(%rbp)
jmp    121a <xep82_datetime+0xca>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    121a <xep82_datetime+0xca>
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     11ba <xep82_datetime+0x6a>
mov    %rax,%rbx
add    $0x1,%rbx
cmpb   $0x2e,(%rax)
jne    11a1 <xep82_datetime+0x51>
nopl   0x0(%rax)
movsbl (%rbx),%edi
add    $0x1,%rbx
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1190 <xep82_datetime+0x40>
movl   $0xffffffff,(%rsp)
cmpb   $0x0,(%rbx)
je     11c3 <xep82_datetime+0x73>
mov    %rbx,%rdi
call   1050 <parse_timezone@plt>
mov    %rax,%rbx
jmp    11c5 <xep82_datetime+0x75>
mov    $0xffffffffffffffff,%rax
jmp    11d0 <xep82_datetime+0x80>
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 = %26, %18
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %6
%22 = load i8, i8* %20
%23 = sext i8 %22 to i32
%24 = call i64 @isdigit(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %19
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 %29, 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 %18
11: ; preds = %7, %11
%12 = phi i8* [ %13, %11 ], [ %8, %7 ]
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %12
%15 = sext i8 %14 to i32
%16 = call i64 @isdigit(i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %11
18: ; preds = %11, %7
%19 = phi i8* [ %8, %7 ], [ %13, %11 ]
%20 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
store i32 -1, i32* %20
%21 = load i8, i8* %19
%22 = icmp eq i8 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %18
%24 = call i64 @parse_timezone(i8* %19)
br label %25
25: ; preds = %18, %23
%26 = phi i64 [ %24, %23 ], [ 0, %18 ]
%27 = call i64 @mktime(%struct.tm* %2)
%28 = sub nsw i64 %27, %26
br label %29
29: ; preds = %1, %25
%30 = phi i64 [ %28, %25 ], [ -1, %1 ]
ret i64 %30
}