#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 */
char *getenv(char *);
int /*<<< orphan*/ mktime(struct tm *);
int /*<<< orphan*/ setenv(char *, char *, int);
int /*<<< orphan*/ tzset();
int /*<<< orphan*/ unsetenv(char *);
void _fattmfixday(struct tm *tm) {
  char *tz;
  tz = getenv("TZ");
  setenv("TZ", "", 1);
  tzset();
  mktime(tm);
  if (tz)
    setenv("TZ", tz, 1);
  else
    unsetenv("TZ");
  tzset();
}


x86 assembly (clang, -O0):
<_fattmfixday>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8d(%rip),%rdi
lea    0xe88(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    $0x0,%al
call   1050 <tzset@plt>
mov    -0x8(%rbp),%rdi
call   1060 <mktime@plt>
cmpq   $0x0,-0x10(%rbp)
je     11b9 <_fattmfixday+0x69>
mov    -0x10(%rbp),%rsi
lea    0xe56(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
jmp    11c5 <_fattmfixday+0x75>
lea    0xe40(%rip),%rdi
call   1070 <unsetenv@plt>
mov    $0x0,%al
call   1050 <tzset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_fattmfixday>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xea1(%rip),%r15
mov    %r15,%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xe91(%rip),%rsi
mov    %r15,%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
xor    %eax,%eax
call   1050 <tzset@plt>
mov    %r14,%rdi
call   1060 <mktime@plt>
lea    0xe6c(%rip),%rdi
test   %rbx,%rbx
je     11a8 <_fattmfixday+0x58>
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
jmp    11ad <_fattmfixday+0x5d>
call   1070 <unsetenv@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <tzset@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"TZ\00"
@.str.1 = [1 x i8] zeroinitializer
define void @_fattmfixday(%struct.tm* %0) {
%2 = alloca %struct.tm*
%3 = alloca i8*
store %struct.tm* %0, %struct.tm** %2
%4 = call i8* @getenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %3
%5 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 1)
%6 = call i32 (...) @tzset()
%7 = load %struct.tm*, %struct.tm** %2
%8 = call i32 @mktime(%struct.tm* %7)
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12, i32 1)
br label %16
14: ; preds = %1
%15 = call i32 @unsetenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = call i32 (...) @tzset()
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [3 x i8] c"TZ\00"
@.str.1 = [1 x i8] zeroinitializer
define void @_fattmfixday(%struct.tm* nocapture %0) {
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = tail call i32 (...) @tzset()
%5 = tail call i32 @mktime(%struct.tm* %0)
%6 = icmp eq i8* %2, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = tail call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2, i32 1)
br label %11
9: ; preds = %1
%10 = tail call i32 @unsetenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %7
%12 = tail call i32 (...) @tzset()
ret void
}