#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 int /*<<< orphan*/ time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
  int /*<<< orphan*/ tm_mday;
};

/* Variables and functions */
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int sscanf(char *, char *, int *, int *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ timegm(struct tm *);
time_t ipapwd_gentime_to_time_t(char *timestr) {
  struct tm tm;
  time_t rtime = 0;
  int ret;
  if (timestr != NULL) {
    memset(&tm, 0, sizeof(struct tm));
    ret = sscanf(timestr, "%04u%02u%02u%02u%02u%02u", &tm.tm_year, &tm.tm_mon,
                 &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
    if (ret == 6) {
      tm.tm_year -= 1900;
      tm.tm_mon -= 1;
      rtime = timegm(&tm);
    }
  }
  return rtime;
}


x86 assembly (clang, -O0):
<ipapwd_gentime_to_time_t>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11d5 <ipapwd_gentime_to_time_t+0xa5>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x20(%rbp),%rcx
add    $0x4,%rcx
lea    -0x20(%rbp),%r8
add    $0x14,%r8
lea    -0x20(%rbp),%r9
add    $0x10,%r9
lea    -0x20(%rbp),%r10
add    $0xc,%r10
lea    -0x20(%rbp),%rax
add    $0x8,%rax
lea    0xe6b(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <sscanf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x6,-0x28(%rbp)
jne    11d0 <ipapwd_gentime_to_time_t+0xa0>
mov    -0x20(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <timegm@plt>
mov    %eax,-0x24(%rbp)
jmp    11d5 <ipapwd_gentime_to_time_t+0xa5>
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ipapwd_gentime_to_time_t>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %rdi,%rdi
je     11a8 <ipapwd_gentime_to_time_t+0x78>
mov    %rdi,%rbx
lea    0x8(%rsp),%r14
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
lea    0xc(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0x18(%rsp),%r9
lea    0x14(%rsp),%r10
lea    0x10(%rsp),%rax
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
push   %rax
push   %r10
call   1040 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
jne    11aa <ipapwd_gentime_to_time_t+0x7a>
addl   $0xfffff894,0x8(%rsp)
ff
addl   $0xffffffff,0xc(%rsp)
lea    0x8(%rsp),%rdi
call   1050 <timegm@plt>
mov    %eax,%ebp
jmp    11aa <ipapwd_gentime_to_time_t+0x7a>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [25 x i8] c"%04u%02u%02u%02u%02u%02u\00"
define i32 @ipapwd_gentime_to_time_t(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
%6 = load i8*, i8** %2
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %29
8: ; preds = %1
%9 = call i32 @memset(%struct.tm* %3, i32 0, i32 24)
%10 = load i8*, i8** %2
%11 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
%12 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 1
%13 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 5
%14 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 4
%15 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 3
%16 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 2
%17 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %11, i32* %12, i32* %13, i32* %14, i32* %15, i32* %16)
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 6
br i1 %19, label %20, label %28
20: ; preds = %8
%21 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
%22 = load i32, i32* %21
%23 = sub nsw i32 %22, 1900
store i32 %23, i32* %21
%24 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 1
%25 = load i32, i32* %24
%26 = sub nsw i32 %25, 1
store i32 %26, i32* %24
%27 = call i32 @timegm(%struct.tm* %3)
store i32 %27, i32* %4
br label %28
28: ; preds = %20, %8
br label %29
29: ; preds = %28, %1
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [25 x i8] c"%04u%02u%02u%02u%02u%02u\00"
define i32 @ipapwd_gentime_to_time_t(i8* %0) {
%2 = alloca %struct.tm
%3 = bitcast %struct.tm* %2 to i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %21, label %5
5: ; preds = %1
%6 = call i32 @memset(%struct.tm* %2, i32 0, i32 24)
%7 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
%8 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
%9 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 5
%10 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 4
%11 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 3
%12 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 2
%13 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12)
%14 = icmp eq i32 %13, 6
br i1 %14, label %15, label %21
15: ; preds = %5
%16 = load i32, i32* %7
%17 = add nsw i32 %16, -1900
store i32 %17, i32* %7
%18 = load i32, i32* %8
%19 = add nsw i32 %18, -1
store i32 %19, i32* %8
%20 = call i32 @timegm(%struct.tm* %2)
br label %21
21: ; preds = %5, %15, %1
%22 = phi i32 [ %20, %15 ], [ 0, %5 ], [ 0, %1 ]
ret i32 %22
}