#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 */
int /*<<< orphan*/ memset(struct tm *, char, int);
char *strptime(char const *, char *, struct tm *);
const char *parse_date_time(const char *input, struct tm *tm) {
  const char *cp;
  memset(tm, '\0', sizeof(*tm));
  cp = strptime(input, "%F %T", tm);
  if (cp == NULL) {
    cp = strptime(input, "%Y%m%d %T", tm);
  }
  if (cp == NULL) {
    cp = strptime(input, "%y%m%d %T", tm);
  }
  if (cp == NULL) {
    cp = strptime(input, "%s", tm);
  }
  return cp;
}


x86 assembly (clang, -O0):
<parse_date_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xeb1(%rip),%rsi
call   1040 <strptime@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117b <parse_date_time+0x5b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe94(%rip),%rsi
call   1040 <strptime@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119e <parse_date_time+0x7e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe7b(%rip),%rsi
call   1040 <strptime@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c1 <parse_date_time+0xa1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe62(%rip),%rsi
call   1040 <strptime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_date_time>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
lea    0xec0(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <strptime@plt>
test   %rax,%rax
jne    117e <parse_date_time+0x5e>
lea    0xeaf(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <strptime@plt>
test   %rax,%rax
jne    117e <parse_date_time+0x5e>
lea    0xea2(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <strptime@plt>
test   %rax,%rax
je     1186 <parse_date_time+0x66>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe8d(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strptime@plt>

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

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [6 x i8] c"%F %T\00"
@.str.1 = [10 x i8] c"%Y%m%d %T\00"
@.str.2 = [10 x i8] c"%y%m%d %T\00"
@.str.3 = [3 x i8] c"%s\00"
define i8* @parse_date_time(i8* %0, %struct.tm* %1) {
%3 = tail call i32 @memset(%struct.tm* %1, i8 signext 0, i32 4)
%4 = tail call i8* @strptime(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = tail call i8* @strptime(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = tail call i8* @strptime(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %1)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i8* @strptime(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %1)
br label %14
14: ; preds = %2, %6, %12, %9
%15 = phi i8* [ %13, %12 ], [ %10, %9 ], [ %7, %6 ], [ %4, %2 ]
ret i8* %15
}