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

/* Variables and functions */
int atoi(char *);
int mktime(struct tm *);
int /*<<< orphan*/ mon2num(char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *, char *, char *,
                          char *, char *, char *);
int strlen(char *);
time_t whenp(char *p, struct tm *tms) {
  char dd[100], mm[100], yy[100];
  char hh[100], mi[100], ss[100], tz[100];
  time_t t;
  tz[0] = '\0';
  sscanf(p, "%[^/]/%[^/]/%[^:]:%[^:]:%[^:]:%s %s", dd, mm, yy, hh, mi, ss, tz);
  tms->tm_sec = atoi(ss);
  tms->tm_min = atoi(mi);
  tms->tm_hour = atoi(hh);
  tms->tm_mday = atoi(dd);
  tms->tm_mon = mon2num(mm);
  tms->tm_year = atoi(yy) - 1900;
  t = mktime(tms);
  if (t != -1 && strlen(tz) == 5) {
    int d = 60 * atoi(tz + 3);
    tz[3] = '\0';
    d += 3600 * atoi(tz + 1);
    if (tz[0] == '+')
      t -= d;
    else
      t += d;
  }
  return t;
}


x86 assembly (clang, -O0):
<whenp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x320(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    -0xf0(%rbp),%rcx
lea    -0x160(%rbp),%r8
lea    -0x1d0(%rbp),%r9
lea    -0x240(%rbp),%r11
lea    -0x2b0(%rbp),%r10
lea    -0x320(%rbp),%rax
lea    0xe5d(%rip),%rsi
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <sscanf@plt>
lea    -0x2b0(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x240(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
lea    -0x1d0(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
lea    -0x80(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
lea    -0xf0(%rbp),%rdi
call   1070 <mon2num@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x14(%rax)
lea    -0x160(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
sub    $0x76c,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <mktime@plt>
mov    %eax,-0x324(%rbp)
cmpl   $0xffffffff,-0x324(%rbp)
je     12e9 <whenp+0x199>
lea    -0x320(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x5,%eax
jne    12e9 <whenp+0x199>
lea    -0x320(%rbp),%rdi
add    $0x3,%rdi
call   1060 <atoi@plt>
imul   $0x3c,%eax,%eax
mov    %eax,-0x328(%rbp)
movb   $0x0,-0x31d(%rbp)
lea    -0x320(%rbp),%rdi
add    $0x1,%rdi
call   1060 <atoi@plt>
imul   $0xe10,%eax,%eax
add    -0x328(%rbp),%eax
mov    %eax,-0x328(%rbp)
movsbl -0x320(%rbp),%eax
cmp    $0x2b,%eax
jne    12d2 <whenp+0x182>
mov    -0x328(%rbp),%ecx
mov    -0x324(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x324(%rbp)
jmp    12e4 <whenp+0x194>
mov    -0x328(%rbp),%eax
add    -0x324(%rbp),%eax
mov    %eax,-0x324(%rbp)
jmp    12e9 <whenp+0x199>
mov    -0x324(%rbp),%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<whenp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x308,%rsp
mov    %rsi,%rbx
movb   $0x0,(%rsp)
sub    $0x8,%rsp
lea    0x8(%rsp),%rax
lea    0xe8(%rsp),%r13
lea    0x158(%rsp),%rbp
lea    0xe78(%rip),%rsi
lea    0x2a8(%rsp),%r12
lea    0x238(%rsp),%r15
lea    0x78(%rsp),%r8
lea    0x1c8(%rsp),%r14
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r9
push   %rax
push   %r13
push   %rbp
call   1040 <sscanf@plt>
add    $0x20,%rsp
mov    %r13,%rdi
call   1060 <atoi@plt>
mov    %eax,(%rbx)
mov    %rbp,%rdi
call   1060 <atoi@plt>
mov    %eax,0x4(%rbx)
mov    %r14,%rdi
call   1060 <atoi@plt>
mov    %eax,0x8(%rbx)
mov    %r12,%rdi
call   1060 <atoi@plt>
mov    %eax,0xc(%rbx)
mov    %r15,%rdi
call   1070 <mon2num@plt>
mov    %eax,0x14(%rbx)
lea    0x70(%rsp),%rdi
call   1060 <atoi@plt>
add    $0xfffff894,%eax
mov    %eax,0x10(%rbx)
mov    %rbx,%rdi
call   1050 <mktime@plt>
cmp    $0xffffffff,%eax
je     1252 <whenp+0x102>
mov    %eax,%ebx
mov    %rsp,%rdi
call   1030 <strlen@plt>
cmp    $0x5,%eax
jne    1257 <whenp+0x107>
lea    0x3(%rsp),%rdi
call   1060 <atoi@plt>
imul   $0x3c,%eax,%ebp
movb   $0x0,0x3(%rsp)
lea    0x1(%rsp),%rdi
call   1060 <atoi@plt>
imul   $0xe10,%eax,%eax
add    %ebp,%eax
mov    %eax,%ecx
neg    %ecx
cmpb   $0x2b,(%rsp)
cmovne %eax,%ecx
add    %ecx,%ebx
jmp    1257 <whenp+0x107>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x308,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [36 x i8] c"%[^/]/%[^/]/%[^:]:%[^:]:%[^:]:%s %s\00"
define i32 @whenp(i8* %0, %struct.tm* %1) {
%3 = alloca i8*
%4 = alloca %struct.tm*
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
%10 = alloca [100 x i8]
%11 = alloca [100 x i8]
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %3
store %struct.tm* %1, %struct.tm** %4
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
store i8 0, i8* %14
%15 = load i8*, i8** %3
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%23 = call i32 @sscanf(i8* %15, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i8* %18, i8* %19, i8* %20, i8* %21, i8* %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%25 = call i32 @atoi(i8* %24)
%26 = load %struct.tm*, %struct.tm** %4
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 0
store i32 %25, i32* %27
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%29 = call i32 @atoi(i8* %28)
%30 = load %struct.tm*, %struct.tm** %4
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 1
store i32 %29, i32* %31
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%33 = call i32 @atoi(i8* %32)
%34 = load %struct.tm*, %struct.tm** %4
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 2
store i32 %33, i32* %35
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%37 = call i32 @atoi(i8* %36)
%38 = load %struct.tm*, %struct.tm** %4
%39 = getelementptr inbounds %struct.tm, %struct.tm* %38, i32 0, i32 3
store i32 %37, i32* %39
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%41 = call i32 @mon2num(i8* %40)
%42 = load %struct.tm*, %struct.tm** %4
%43 = getelementptr inbounds %struct.tm, %struct.tm* %42, i32 0, i32 5
store i32 %41, i32* %43
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%45 = call i32 @atoi(i8* %44)
%46 = sub nsw i32 %45, 1900
%47 = load %struct.tm*, %struct.tm** %4
%48 = getelementptr inbounds %struct.tm, %struct.tm* %47, i32 0, i32 4
store i32 %46, i32* %48
%49 = load %struct.tm*, %struct.tm** %4
%50 = call i32 @mktime(%struct.tm* %49)
store i32 %50, i32* %12
%51 = load i32, i32* %12
%52 = icmp ne i32 %51, -1
br i1 %52, label %53, label %82
53: ; preds = %2
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%55 = call i32 @strlen(i8* %54)
%56 = icmp eq i32 %55, 5
br i1 %56, label %57, label %82
57: ; preds = %53
%58 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%59 = getelementptr inbounds i8, i8* %58, i64 3
%60 = call i32 @atoi(i8* %59)
%61 = mul nsw i32 60, %60
store i32 %61, i32* %13
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 3
store i8 0, i8* %62
%63 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%64 = getelementptr inbounds i8, i8* %63, i64 1
%65 = call i32 @atoi(i8* %64)
%66 = mul nsw i32 3600, %65
%67 = load i32, i32* %13
%68 = add nsw i32 %67, %66
store i32 %68, i32* %13
%69 = getelementptr inbounds [100 x i8], [100 x i8]* %11, i64 0, i64 0
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 43
br i1 %72, label %73, label %77
73: ; preds = %57
%74 = load i32, i32* %13
%75 = load i32, i32* %12
%76 = sub nsw i32 %75, %74
store i32 %76, i32* %12
br label %81
77: ; preds = %57
%78 = load i32, i32* %13
%79 = load i32, i32* %12
%80 = add nsw i32 %79, %78
store i32 %80, i32* %12
br label %81
81: ; preds = %77, %73
br label %82
82: ; preds = %81, %53, %2
%83 = load i32, i32* %12
ret i32 %83
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [36 x i8] c"%[^/]/%[^/]/%[^:]:%[^:]:%[^:]:%s %s\00"
define i32 @whenp(i8* nocapture %0, %struct.tm* nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
store i8 0, i8* %16
%17 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11, i8* %12, i8* %13, i8* %14, i8* %15, i8* %16)
%18 = call i32 @atoi(i8* %15)
%19 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
store i32 %18, i32* %19
%20 = call i32 @atoi(i8* %14)
%21 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
store i32 %20, i32* %21
%22 = call i32 @atoi(i8* %13)
%23 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
store i32 %22, i32* %23
%24 = call i32 @atoi(i8* %10)
%25 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 3
store i32 %24, i32* %25
%26 = call i32 @mon2num(i8* %11)
%27 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 5
store i32 %26, i32* %27
%28 = call i32 @atoi(i8* %12)
%29 = add nsw i32 %28, -1900
%30 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 4
store i32 %29, i32* %30
%31 = call i32 @mktime(%struct.tm* %1)
%32 = icmp eq i32 %31, -1
br i1 %32, label %49, label %33
33: ; preds = %2
%34 = call i32 @strlen(i8* %16)
%35 = icmp eq i32 %34, 5
br i1 %35, label %36, label %49
36: ; preds = %33
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 3
%38 = call i32 @atoi(i8* %37)
%39 = mul nsw i32 %38, 60
store i8 0, i8* %37
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 1
%41 = call i32 @atoi(i8* %40)
%42 = mul nsw i32 %41, 3600
%43 = add nsw i32 %42, %39
%44 = load i8, i8* %16
%45 = icmp eq i8 %44, 43
%46 = sub i32 0, %43
%47 = select i1 %45, i32 %46, i32 %43
%48 = add i32 %47, %31
br label %49
49: ; preds = %36, %33, %2
%50 = phi i32 [ %48, %36 ], [ %31, %33 ], [ -1, %2 ]
ret i32 %50
}