#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 */
struct tm {
  scalar_t__ tm_isdst;
  scalar_t__ tm_yday;
  scalar_t__ tm_wday;
  void *tm_year;
  void *tm_mon;
  void *tm_mday;
  void *tm_sec;
  void *tm_min;
  void *tm_hour;
};

/* Variables and functions */
void *flu_stoll(char *, int, int);
char *strchr(char *, char);
int ptime(char *s, struct tm *tm) {
  char *d = strchr(s, 'T');
  if (d == NULL)
    d = strchr(s, '.');
  if (d == NULL)
    return 1;
  if (*d == 'T') {
    tm->tm_hour = flu_stoll(d + 1, 2, 10);
    tm->tm_min = flu_stoll(d + 4, 2, 10);
    tm->tm_sec = flu_stoll(d + 7, 2, 10);
    d = strchr(s, '-');
    tm->tm_year = flu_stoll(s + 0, d - s, 10) - 1900;
    tm->tm_mon = flu_stoll(d + 1, 2, 10) - 1;
    d = strchr(d + 1, '-');
    tm->tm_mday = flu_stoll(d + 1, 2, 10);
  } else {
    tm->tm_hour = flu_stoll(d + 1, 2, 10);
    tm->tm_min = flu_stoll(d + 3, 2, 10);
    tm->tm_sec = flu_stoll(d + 5, 2, 10);
    tm->tm_mday = flu_stoll(d - 2, 2, 10);
    tm->tm_mon = flu_stoll(d - 4, 2, 10) - 1;
    tm->tm_year = flu_stoll(s, d - 4 - s, 10) - 1900;
  }
  tm->tm_wday = 0;
  tm->tm_yday = 0;
  tm->tm_isdst = 0;
  return 0;
}


x86 assembly (clang, -O0):
<ptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x54,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    115f <ptime+0x3f>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1176 <ptime+0x56>
movl   $0x1,-0x4(%rbp)
jmp    1397 <ptime+0x277>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x54,%eax
jne    128e <ptime+0x16e>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x40(%rax)
mov    -0x20(%rbp),%rdi
add    $0x4,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x38(%rax)
mov    -0x20(%rbp),%rdi
add    $0x7,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
add    $0xfffffffffffff894,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x28(%rax)
jmp    136d <ptime+0x24d>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x40(%rax)
mov    -0x20(%rbp),%rdi
add    $0x3,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x38(%rax)
mov    -0x20(%rbp),%rdi
add    $0x5,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    -0x20(%rbp),%rdi
add    $0xfffffffffffffffe,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x20(%rbp),%rdi
add    $0xfffffffffffffffc,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,%rcx
add    $0xfffffffffffff894,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,0x10(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0x54,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1158 <ptime+0x38>
mov    %r14,%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     12b8 <ptime+0x198>
mov    (%rbx),%bpl
lea    0x1(%rbx),%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,0x40(%r15)
cmp    $0x54,%bpl
jne    121d <ptime+0xfd>
lea    0x4(%rbx),%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,0x38(%r15)
add    $0x7,%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,0x30(%r15)
mov    %r14,%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
mov    %ebx,%esi
sub    %r14d,%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
add    $0xfffffffffffff894,%rax
mov    %rax,0x18(%r15)
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,0x20(%r15)
mov    %rbx,%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
lea    0x1(%rax),%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,0x28(%r15)
jmp    129c <ptime+0x17c>
lea    0x3(%rbx),%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,0x38(%r15)
lea    0x5(%rbx),%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,0x30(%r15)
lea    -0x2(%rbx),%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
mov    %rax,0x28(%r15)
add    $0xfffffffffffffffc,%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,0x20(%r15)
sub    %r14d,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0xa,%edx
call   1040 <flu_stoll@plt>
add    $0xfffffffffffff894,%rax
mov    %rax,0x18(%r15)
xorps  %xmm0,%xmm0
movups %xmm0,(%r15)
movq   $0x0,0x10(%r15)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%eax
jmp    12ad <ptime+0x18d>

LLVM IR (-O0):
%struct.tm = type { i64, i64, i64, i8*, i8*, i8*, i8*, i8*, i8* }
define i32 @ptime(i8* %0, %struct.tm* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.tm*
%6 = alloca i8*
store i8* %0, i8** %4
store %struct.tm* %1, %struct.tm** %5
%7 = load i8*, i8** %4
%8 = call i8* @strchr(i8* %7, i8 signext 84)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i8* @strchr(i8* %12, i8 signext 46)
store i8* %13, i8** %6
br label %14
14: ; preds = %11, %2
%15 = load i8*, i8** %6
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 1, i32* %3
br label %113
18: ; preds = %14
%19 = load i8*, i8** %6
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 84
br i1 %22, label %23, label %67
23: ; preds = %18
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = call i8* @flu_stoll(i8* %25, i32 2, i32 10)
%27 = load %struct.tm*, %struct.tm** %5
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 8
store i8* %26, i8** %28
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i64 4
%31 = call i8* @flu_stoll(i8* %30, i32 2, i32 10)
%32 = load %struct.tm*, %struct.tm** %5
%33 = getelementptr inbounds %struct.tm, %struct.tm* %32, i32 0, i32 7
store i8* %31, i8** %33
%34 = load i8*, i8** %6
%35 = getelementptr inbounds i8, i8* %34, i64 7
%36 = call i8* @flu_stoll(i8* %35, i32 2, i32 10)
%37 = load %struct.tm*, %struct.tm** %5
%38 = getelementptr inbounds %struct.tm, %struct.tm* %37, i32 0, i32 6
store i8* %36, i8** %38
%39 = load i8*, i8** %4
%40 = call i8* @strchr(i8* %39, i8 signext 45)
store i8* %40, i8** %6
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i64 0
%43 = load i8*, i8** %6
%44 = load i8*, i8** %4
%45 = ptrtoint i8* %43 to i64
%46 = ptrtoint i8* %44 to i64
%47 = sub i64 %45, %46
%48 = trunc i64 %47 to i32
%49 = call i8* @flu_stoll(i8* %42, i32 %48, i32 10)
%50 = getelementptr i8, i8* %49, i64 -1900
%51 = load %struct.tm*, %struct.tm** %5
%52 = getelementptr inbounds %struct.tm, %struct.tm* %51, i32 0, i32 3
store i8* %50, i8** %52
%53 = load i8*, i8** %6
%54 = getelementptr inbounds i8, i8* %53, i64 1
%55 = call i8* @flu_stoll(i8* %54, i32 2, i32 10)
%56 = getelementptr i8, i8* %55, i64 -1
%57 = load %struct.tm*, %struct.tm** %5
%58 = getelementptr inbounds %struct.tm, %struct.tm* %57, i32 0, i32 4
store i8* %56, i8** %58
%59 = load i8*, i8** %6
%60 = getelementptr inbounds i8, i8* %59, i64 1
%61 = call i8* @strchr(i8* %60, i8 signext 45)
store i8* %61, i8** %6
%62 = load i8*, i8** %6
%63 = getelementptr inbounds i8, i8* %62, i64 1
%64 = call i8* @flu_stoll(i8* %63, i32 2, i32 10)
%65 = load %struct.tm*, %struct.tm** %5
%66 = getelementptr inbounds %struct.tm, %struct.tm* %65, i32 0, i32 5
store i8* %64, i8** %66
br label %106
67: ; preds = %18
%68 = load i8*, i8** %6
%69 = getelementptr inbounds i8, i8* %68, i64 1
%70 = call i8* @flu_stoll(i8* %69, i32 2, i32 10)
%71 = load %struct.tm*, %struct.tm** %5
%72 = getelementptr inbounds %struct.tm, %struct.tm* %71, i32 0, i32 8
store i8* %70, i8** %72
%73 = load i8*, i8** %6
%74 = getelementptr inbounds i8, i8* %73, i64 3
%75 = call i8* @flu_stoll(i8* %74, i32 2, i32 10)
%76 = load %struct.tm*, %struct.tm** %5
%77 = getelementptr inbounds %struct.tm, %struct.tm* %76, i32 0, i32 7
store i8* %75, i8** %77
%78 = load i8*, i8** %6
%79 = getelementptr inbounds i8, i8* %78, i64 5
%80 = call i8* @flu_stoll(i8* %79, i32 2, i32 10)
%81 = load %struct.tm*, %struct.tm** %5
%82 = getelementptr inbounds %struct.tm, %struct.tm* %81, i32 0, i32 6
store i8* %80, i8** %82
%83 = load i8*, i8** %6
%84 = getelementptr inbounds i8, i8* %83, i64 -2
%85 = call i8* @flu_stoll(i8* %84, i32 2, i32 10)
%86 = load %struct.tm*, %struct.tm** %5
%87 = getelementptr inbounds %struct.tm, %struct.tm* %86, i32 0, i32 5
store i8* %85, i8** %87
%88 = load i8*, i8** %6
%89 = getelementptr inbounds i8, i8* %88, i64 -4
%90 = call i8* @flu_stoll(i8* %89, i32 2, i32 10)
%91 = getelementptr i8, i8* %90, i64 -1
%92 = load %struct.tm*, %struct.tm** %5
%93 = getelementptr inbounds %struct.tm, %struct.tm* %92, i32 0, i32 4
store i8* %91, i8** %93
%94 = load i8*, i8** %4
%95 = load i8*, i8** %6
%96 = getelementptr inbounds i8, i8* %95, i64 -4
%97 = load i8*, i8** %4
%98 = ptrtoint i8* %96 to i64
%99 = ptrtoint i8* %97 to i64
%100 = sub i64 %98, %99
%101 = trunc i64 %100 to i32
%102 = call i8* @flu_stoll(i8* %94, i32 %101, i32 10)
%103 = getelementptr i8, i8* %102, i64 -1900
%104 = load %struct.tm*, %struct.tm** %5
%105 = getelementptr inbounds %struct.tm, %struct.tm* %104, i32 0, i32 3
store i8* %103, i8** %105
br label %106
106: ; preds = %67, %23
%107 = load %struct.tm*, %struct.tm** %5
%108 = getelementptr inbounds %struct.tm, %struct.tm* %107, i32 0, i32 2
store i64 0, i64* %108
%109 = load %struct.tm*, %struct.tm** %5
%110 = getelementptr inbounds %struct.tm, %struct.tm* %109, i32 0, i32 1
store i64 0, i64* %110
%111 = load %struct.tm*, %struct.tm** %5
%112 = getelementptr inbounds %struct.tm, %struct.tm* %111, i32 0, i32 0
store i64 0, i64* %112
store i32 0, i32* %3
br label %113
113: ; preds = %106, %17
%114 = load i32, i32* %3
ret i32 %114
}

LLVM IR (-O2):
%struct.tm = type { i64, i64, i64, i8*, i8*, i8*, i8*, i8*, i8* }
define i32 @ptime(i8* %0, %struct.tm* nocapture writeonly %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 84)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 46)
%7 = icmp eq i8* %6, null
br i1 %7, label %61, label %8
8: ; preds = %2, %5
%9 = phi i8* [ %6, %5 ], [ %3, %2 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 84
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = tail call i8* @flu_stoll(i8* %12, i32 2, i32 10)
%14 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 8
store i8* %13, i8** %14
br i1 %11, label %15, label %38
15: ; preds = %8
%16 = getelementptr inbounds i8, i8* %9, i64 4
%17 = tail call i8* @flu_stoll(i8* %16, i32 2, i32 10)
%18 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 7
store i8* %17, i8** %18
%19 = getelementptr inbounds i8, i8* %9, i64 7
%20 = tail call i8* @flu_stoll(i8* %19, i32 2, i32 10)
%21 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 6
store i8* %20, i8** %21
%22 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 45)
%23 = ptrtoint i8* %22 to i64
%24 = ptrtoint i8* %0 to i64
%25 = sub i64 %23, %24
%26 = trunc i64 %25 to i32
%27 = tail call i8* @flu_stoll(i8* %0, i32 %26, i32 10)
%28 = getelementptr i8, i8* %27, i64 -1900
%29 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 3
store i8* %28, i8** %29
%30 = getelementptr inbounds i8, i8* %22, i64 1
%31 = tail call i8* @flu_stoll(i8* %30, i32 2, i32 10)
%32 = getelementptr i8, i8* %31, i64 -1
%33 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 4
store i8* %32, i8** %33
%34 = tail call i8* @strchr(i8* %30, i8 signext 45)
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = tail call i8* @flu_stoll(i8* %35, i32 2, i32 10)
%37 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 5
store i8* %36, i8** %37
br label %59
38: ; preds = %8
%39 = getelementptr inbounds i8, i8* %9, i64 3
%40 = tail call i8* @flu_stoll(i8* %39, i32 2, i32 10)
%41 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 7
store i8* %40, i8** %41
%42 = getelementptr inbounds i8, i8* %9, i64 5
%43 = tail call i8* @flu_stoll(i8* %42, i32 2, i32 10)
%44 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 6
store i8* %43, i8** %44
%45 = getelementptr inbounds i8, i8* %9, i64 -2
%46 = tail call i8* @flu_stoll(i8* %45, i32 2, i32 10)
%47 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 5
store i8* %46, i8** %47
%48 = getelementptr inbounds i8, i8* %9, i64 -4
%49 = tail call i8* @flu_stoll(i8* %48, i32 2, i32 10)
%50 = getelementptr i8, i8* %49, i64 -1
%51 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 4
store i8* %50, i8** %51
%52 = ptrtoint i8* %48 to i64
%53 = ptrtoint i8* %0 to i64
%54 = sub i64 %52, %53
%55 = trunc i64 %54 to i32
%56 = tail call i8* @flu_stoll(i8* %0, i32 %55, i32 10)
%57 = getelementptr i8, i8* %56, i64 -1900
%58 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 3
store i8* %57, i8** %58
br label %59
59: ; preds = %38, %15
%60 = bitcast %struct.tm* %1 to i8*
br label %61
61: ; preds = %5, %59
%62 = phi i32 [ 0, %59 ], [ 1, %5 ]
ret i32 %62
}