#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 tm_isdst;
  int tm_mon;
  int tm_year;
  scalar_t__ tm_min;
  scalar_t__ tm_hour;
  int /*<<< orphan*/ tm_mday;
  scalar_t__ tm_sec;
};

/* Variables and functions */
scalar_t__ mktime(struct tm *);
int sscanf(char *, char *, int /*<<< orphan*/ *, int *, int *, scalar_t__ *,
           scalar_t__ *);
scalar_t__ time(int /*<<< orphan*/ *);
int rw_get_epoch(char *s) {
  struct tm t;
  t.tm_hour = t.tm_min = 0;
  t.tm_sec = 0;
  t.tm_isdst = -1;
  if (sscanf(s, "%d/%d/%d %d:%d", &t.tm_mday, &t.tm_mon, &t.tm_year, &t.tm_hour,
             &t.tm_min) < 3)
    return -1;
  t.tm_mon -= 1;
  t.tm_year -= 1900;
  return (int)(mktime(&t) - time(NULL));
}


x86 assembly (clang, -O0):
<rw_get_epoch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0xffffffff,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rdx
add    $0x20,%rdx
lea    -0x40(%rbp),%rcx
add    $0x4,%rcx
lea    -0x40(%rbp),%r8
add    $0x8,%r8
lea    -0x40(%rbp),%r9
add    $0x18,%r9
lea    -0x40(%rbp),%rax
add    $0x10,%rax
lea    0xe72(%rip),%rsi
mov    %rax,(%rsp)
call   1040 <sscanf@plt>
cmp    $0x3,%eax
jge    11ac <rw_get_epoch+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e3 <rw_get_epoch+0xb3>
mov    -0x3c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x38(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <mktime@plt>
mov    %rax,-0x48(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1030 <time@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rw_get_epoch>:
push   %rbx
sub    $0x40,%rsp
lea    0x20(%rsp),%rax
lea    0x28(%rsp),%r9
movq   $0x0,0x38(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x20(%rsp)
movl   $0xffffffff,0x10(%rsp)
ff
lea    0x30(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x18(%rsp),%r8
mov    %rax,(%rsp)
lea    0xe8e(%rip),%rsi
call   1040 <sscanf@plt>
mov    $0xffffffff,%ebx
cmp    $0x3,%eax
jl     11a4 <rw_get_epoch+0x74>
addl   $0xffffffff,0x14(%rsp)
addl   $0xfffff894,0x18(%rsp)
ff
lea    0x10(%rsp),%rdi
call   1050 <mktime@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1030 <time@plt>
sub    %eax,%ebx
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret

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

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