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

/* Variables and functions */
int mktime(struct tm *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putenv(char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ strptime(char *, char *, struct tm *);
int main() {
  extern char *tzname[2];
  extern long timezone;
  extern int daylight;
  char time_buf[100];
  char format_str[] = "%Y-%m-%d %H:%M %z";
  char time_str[] = "1984-01-01 00:00 -0500";
  struct tm time_struct;
  putenv("TZ=UTC");
  strptime(time_str, format_str, &time_struct);
  int i = mktime(&time_struct);
  strftime(time_buf, 100, "%Y-%m-%d %H:%M %Z %z", &time_struct);
  printf("%s\n", time_buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xe91(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    0xe8b(%rip),%ax
mov    %ax,-0x80(%rbp)
mov    0xe90(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    0xe85(%rip),%eax
mov    %eax,-0xa0(%rbp)
mov    0xe7c(%rip),%ax
mov    %ax,-0x9c(%rbp)
mov    0xe71(%rip),%al
mov    %al,-0x9a(%rbp)
lea    0xe65(%rip),%rdi
call   1040 <putenv@plt>
lea    -0xb0(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0xb8(%rbp),%rdx
call   1070 <strptime@plt>
lea    -0xb8(%rbp),%rdi
call   1050 <mktime@plt>
mov    %eax,-0xbc(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x64,%esi
lea    0xe2b(%rip),%rdx
lea    -0xb8(%rbp),%rcx
call   1060 <strftime@plt>
lea    -0x70(%rbp),%rsi
lea    0xe29(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xb8,%rsp
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x7a,0x20(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movabs $0x303035302d2030,%rax
mov    %rax,0x3f(%rsp)
lea    0xea8(%rip),%rdi
call   1040 <putenv@plt>
lea    0x30(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdx
call   1070 <strptime@plt>
mov    %rbx,%rdi
call   1050 <mktime@plt>
lea    0xe84(%rip),%rdx
lea    0x50(%rsp),%r14
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbx,%rcx
call   1060 <strftime@plt>
lea    0xe7d(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@__const.main.format_str = [18 x i8] c"%Y-%m-%d %H:%M %z\00"
@__const.main.time_str = [23 x i8] c"1984-01-01 00:00 -0500\00"
@.str = [7 x i8] c"TZ=UTC\00"
@.str.1 = [21 x i8] c"%Y-%m-%d %H:%M %Z %z\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [18 x i8]
%4 = alloca [23 x i8]
%5 = alloca %struct.tm
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [18 x i8]* %3 to i8*
%8 = bitcast [23 x i8]* %4 to i8*
%9 = call i32 @putenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [23 x i8], [23 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%12 = call i32 @strptime(i8* %10, i8* %11, %struct.tm* %5)
%13 = call i32 @mktime(%struct.tm* %5)
store i32 %13, i32* %6
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @strftime(i8* %14, i32 100, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %5)
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@__const.main.format_str = [18 x i8] c"%Y-%m-%d %H:%M %z\00"
@__const.main.time_str = [23 x i8] c"1984-01-01 00:00 -0500\00"
@.str = [7 x i8] c"TZ=UTC\00"
@.str.1 = [21 x i8] c"%Y-%m-%d %H:%M %Z %z\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [18 x i8]
%3 = alloca [23 x i8]
%4 = alloca %struct.tm
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [23 x i8], [23 x i8]* %3, i64 0, i64 0
%8 = bitcast %struct.tm* %4 to i8*
%9 = tail call i32 @putenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @strptime(i8* %7, i8* %6, %struct.tm* %4)
%11 = call i32 @mktime(%struct.tm* %4)
%12 = call i32 @strftime(i8* %5, i32 100, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %4)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
ret i32 0
}