#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
int /*<<< orphan*/ mktime(struct tm *);
int /*<<< orphan*/ perror(char *);
scalar_t__ setenv(char *, char *, int);
int /*<<< orphan*/ stderr;
char *strptime(char const *, char *, struct tm *);
time_t strtotime(const char *time) {
  struct tm tm;
  char *ret;
  memset(&tm, 0, sizeof(struct tm));
  if (setenv("TZ", "UTC", 1) != 0) {
    perror("Setting UTC timezone");
    exit(1);
  }
  ret = strptime(time, "%Y-%m-%d %H:%M:%S", &tm);
  if (ret == 0) {
    fprintf(stderr,
            "time '%s' is not in the required format "
            "(try YYYY-mm-dd HH:MM:SS)\n",
            time);
    exit(1);
  }
  return mktime(&tm);
}


x86 assembly (clang, -O0):
<strtotime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    0xe6d(%rip),%rdi
lea    0xe69(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
cmp    $0x0,%rax
je     11c4 <strtotime+0x54>
lea    0xe52(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe4d(%rip),%rsi
lea    -0x10(%rbp),%rdx
call   1090 <strptime@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    120a <strtotime+0x9a>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe33(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x10(%rbp),%rdi
call   1060 <mktime@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtotime>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
lea    0xe70(%rip),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
test   %rax,%rax
jne    11cf <strtotime+0x5f>
lea    0xe6f(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1090 <strptime@plt>
test   %rax,%rax
je     11e5 <strtotime+0x75>
lea    0x8(%rsp),%rdi
call   1060 <mktime@plt>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe31(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"TZ\00"
@.str.1 = [4 x i8] c"UTC\00"
@.str.2 = [21 x i8] c"Setting UTC timezone\00"
@.str.3 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@stderr = global i32 0
@.str.4 = [67 x i8] c"time '%s' is not in the required format (try YYYY-mm-dd HH:MM:SS)\0A\00"
define i32 @strtotime(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm
%4 = alloca i8*
store i8* %0, i8** %2
%5 = call i32 @memset(%struct.tm* %3, i32 0, i32 4)
%6 = call i64 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i8* @strptime(i8* %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %3)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %2
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.4, i64 0, i64 0), i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %11
%22 = call i32 @mktime(%struct.tm* %3)
ret i32 %22
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [3 x i8] c"TZ\00"
@.str.1 = [4 x i8] c"UTC\00"
@.str.2 = [21 x i8] c"Setting UTC timezone\00"
@.str.3 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@stderr = global i32 0
@.str.4 = [67 x i8] c"time '%s' is not in the required format (try YYYY-mm-dd HH:MM:SS)\0A\00"
define i32 @strtotime(i8* %0) {
%2 = alloca %struct.tm
%3 = bitcast %struct.tm* %2 to i8*
%4 = call i32 @memset(%struct.tm* %2, i32 0, i32 4)
%5 = call i64 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = call i8* @strptime(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %2)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = call i32 @mktime(%struct.tm* %2)
ret i32 %18
}