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

/* Variables and functions */
int portable_timegm(struct tm *);
int /*<<< orphan*/ sscanf(char const *, char const *, int *, int *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          int /*<<< orphan*/ *, int /*<<< orphan*/ *);
time_t ConvertToUnixTime(const char *StringTime, const char *Format,
                         int TZOffsetHours, int TZOffsetMinutes) {
  if (StringTime == NULL || Format == NULL) {
    return 0;
  }
  struct tm Time;
  Time.tm_wday = 0;
  Time.tm_yday = 0;
  Time.tm_isdst = 0;
  sscanf(StringTime, Format, &Time.tm_year, &Time.tm_mon, &Time.tm_mday,
         &Time.tm_hour, &Time.tm_min, &Time.tm_sec);
  Time.tm_year -= 1900;
  Time.tm_mon -= 1;
  time_t thetime = portable_timegm(&Time);
  thetime -= TZOffsetHours * 60 * 60;
  thetime -= TZOffsetMinutes * 60;
  return thetime;
}


x86 assembly (clang, -O0):
<ConvertToUnixTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114c <ConvertToUnixTime+0x2c>
cmpq   $0x0,-0x18(%rbp)
jne    1158 <ConvertToUnixTime+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11f3 <ConvertToUnixTime+0xd3>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x50(%rbp),%rcx
add    $0x4,%rcx
lea    -0x50(%rbp),%r8
add    $0x14,%r8
lea    -0x50(%rbp),%r9
add    $0x10,%r9
lea    -0x50(%rbp),%r10
add    $0xc,%r10
lea    -0x50(%rbp),%rax
add    $0x8,%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <sscanf@plt>
mov    -0x50(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4c(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <portable_timegm@plt>
mov    %eax,-0x54(%rbp)
imul   $0x3c,-0x1c(%rbp),%eax
imul   $0x3c,%eax,%ecx
mov    -0x54(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x54(%rbp)
imul   $0x3c,-0x20(%rbp),%ecx
mov    -0x54(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConvertToUnixTime>:
xor    %eax,%eax
test   %rdi,%rdi
je     119f <ConvertToUnixTime+0x7f>
test   %rsi,%rsi
je     119f <ConvertToUnixTime+0x7f>
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %ecx,%ebx
mov    %edx,%ebp
lea    0x4(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
lea    0xc(%rsp),%r10
lea    0x8(%rsp),%rax
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rsp)
movq   $0x0,0x28(%rsp)
mov    %rsp,%r14
mov    %r14,%rdx
push   %rax
push   %r10
call   1040 <sscanf@plt>
add    $0x10,%rsp
addl   $0xfffff894,(%rsp)
addl   $0xffffffff,0x4(%rsp)
mov    %r14,%rdi
call   1030 <portable_timegm@plt>
mov    %eax,%ecx
imul   $0xfffff1f0,%ebp,%edx
imul   $0xffffffc4,%ebx,%eax
add    %edx,%eax
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i64, i64, i64 }
define i32 @ConvertToUnixTime(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.tm
%11 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%12 = load i8*, i8** %6
%13 = icmp eq i8* %12, null
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = load i8*, i8** %7
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %18
17: ; preds = %14, %4
store i32 0, i32* %5
br label %48
18: ; preds = %14
%19 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 8
store i64 0, i64* %19
%20 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 7
store i64 0, i64* %20
%21 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 6
store i64 0, i64* %21
%22 = load i8*, i8** %6
%23 = load i8*, i8** %7
%24 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%25 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 1
%26 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 5
%27 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 4
%28 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 3
%29 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 2
%30 = call i32 @sscanf(i8* %22, i8* %23, i32* %24, i32* %25, i32* %26, i32* %27, i32* %28, i32* %29)
%31 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%32 = load i32, i32* %31
%33 = sub nsw i32 %32, 1900
store i32 %33, i32* %31
%34 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 1
%35 = load i32, i32* %34
%36 = sub nsw i32 %35, 1
store i32 %36, i32* %34
%37 = call i32 @portable_timegm(%struct.tm* %10)
store i32 %37, i32* %11
%38 = load i32, i32* %8
%39 = mul nsw i32 %38, 60
%40 = mul nsw i32 %39, 60
%41 = load i32, i32* %11
%42 = sub nsw i32 %41, %40
store i32 %42, i32* %11
%43 = load i32, i32* %9
%44 = mul nsw i32 %43, 60
%45 = load i32, i32* %11
%46 = sub nsw i32 %45, %44
store i32 %46, i32* %11
%47 = load i32, i32* %11
store i32 %47, i32* %5
br label %48
48: ; preds = %18, %17
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i64, i64, i64 }
define i32 @ConvertToUnixTime(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca %struct.tm
%6 = icmp eq i8* %0, null
%7 = icmp eq i8* %1, null
%8 = or i1 %6, %7
br i1 %8, label %29, label %9
9: ; preds = %4
%10 = bitcast %struct.tm* %5 to i8*
%11 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 6
%12 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%13 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%14 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 5
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%16 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%17 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%18 = bitcast i64* %11 to i8*
%19 = call i32 @sscanf(i8* %0, i8* %1, i32* %12, i32* %13, i32* %14, i32* %15, i32* %16, i32* %17)
%20 = load i32, i32* %12
%21 = add nsw i32 %20, -1900
store i32 %21, i32* %12
%22 = load i32, i32* %13
%23 = add nsw i32 %22, -1
store i32 %23, i32* %13
%24 = call i32 @portable_timegm(%struct.tm* %5)
%25 = mul i32 %2, -3600
%26 = mul i32 %3, -60
%27 = add i32 %26, %25
%28 = add i32 %27, %24
br label %29
29: ; preds = %4, %9
%30 = phi i32 [ %28, %9 ], [ 0, %4 ]
ret i32 %30
}