#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 {
  int dummy;
};

/* Variables and functions */
scalar_t__ strptime(char *, char *, struct tm *);
int extractISOTime(char *timestr, struct tm *utm) {
  if (strptime(timestr, "%Y-%m-%dT%H:%M:%S", utm))
    return (0);
  if (strptime(timestr, "%Y/%m/%dT%H:%M:%S", utm))
    return (0);
  if (strptime(timestr, "%Y:%m:%dT%H:%M:%S", utm))
    return (0);
  if (strptime(timestr, "%Y-%m-%dT%H-%M-%S", utm))
    return (0);
  return (-1);
}


x86 assembly (clang, -O0):
<extractISOTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xed1(%rip),%rsi
call   1030 <strptime@plt>
cmp    $0x0,%rax
je     114a <extractISOTime+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    11cf <extractISOTime+0xbf>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xeb9(%rip),%rsi
call   1030 <strptime@plt>
cmp    $0x0,%rax
je     1174 <extractISOTime+0x64>
movl   $0x0,-0x4(%rbp)
jmp    11cf <extractISOTime+0xbf>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xea1(%rip),%rsi
call   1030 <strptime@plt>
cmp    $0x0,%rax
je     119e <extractISOTime+0x8e>
movl   $0x0,-0x4(%rbp)
jmp    11cf <extractISOTime+0xbf>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe89(%rip),%rsi
call   1030 <strptime@plt>
cmp    $0x0,%rax
je     11c8 <extractISOTime+0xb8>
movl   $0x0,-0x4(%rbp)
jmp    11cf <extractISOTime+0xbf>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractISOTime>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rsi
mov    %r14,%rdx
call   1030 <strptime@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1176 <extractISOTime+0x66>
lea    0xedb(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <strptime@plt>
test   %rax,%rax
jne    1176 <extractISOTime+0x66>
lea    0xed6(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <strptime@plt>
test   %rax,%rax
jne    1176 <extractISOTime+0x66>
lea    0xed1(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <strptime@plt>
cmp    $0x1,%rax
sbb    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%dT%H:%M:%S\00"
@.str.1 = [18 x i8] c"%Y/%m/%dT%H:%M:%S\00"
@.str.2 = [18 x i8] c"%Y:%m:%dT%H:%M:%S\00"
@.str.3 = [18 x i8] c"%Y-%m-%dT%H-%M-%S\00"
define i32 @extractISOTime(i8* %0, %struct.tm* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.tm*
store i8* %0, i8** %4
store %struct.tm* %1, %struct.tm** %5
%6 = load i8*, i8** %4
%7 = load %struct.tm*, %struct.tm** %5
%8 = call i64 @strptime(i8* %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %30
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = load %struct.tm*, %struct.tm** %5
%14 = call i64 @strptime(i8* %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 0, i32* %3
br label %30
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = load %struct.tm*, %struct.tm** %5
%20 = call i64 @strptime(i8* %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %17
store i32 0, i32* %3
br label %30
23: ; preds = %17
%24 = load i8*, i8** %4
%25 = load %struct.tm*, %struct.tm** %5
%26 = call i64 @strptime(i8* %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 0, i32* %3
br label %30
29: ; preds = %23
store i32 -1, i32* %3
br label %30
30: ; preds = %29, %28, %22, %16, %10
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%dT%H:%M:%S\00"
@.str.1 = [18 x i8] c"%Y/%m/%dT%H:%M:%S\00"
@.str.2 = [18 x i8] c"%Y:%m:%dT%H:%M:%S\00"
@.str.3 = [18 x i8] c"%Y-%m-%dT%H-%M-%S\00"
define i32 @extractISOTime(i8* %0, %struct.tm* %1) {
%3 = tail call i64 @strptime(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = tail call i64 @strptime(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = tail call i64 @strptime(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call i64 @strptime(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %1)
%13 = icmp eq i64 %12, 0
%14 = sext i1 %13 to i32
br label %15
15: ; preds = %11, %8, %5, %2
%16 = phi i32 [ 0, %2 ], [ 0, %5 ], [ 0, %8 ], [ %14, %11 ]
ret i32 %16
}