#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*/ buf;

/* Variables and functions */
char *getenv(char *);
int /*<<< orphan*/ setenv(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int);
char *strdup(char *);
int /*<<< orphan*/ tzset();
char *tz_push_off(int utc_off) {
  char *oldtz = getenv("TZ");
  if (oldtz)
    oldtz = strdup(oldtz);
  int pos_off = utc_off;
  if (pos_off < 0)
    pos_off *= -1;
  char buf[32];
  snprintf(buf, sizeof(buf), "UTC+%+02d:%02d", utc_off / 60, pos_off % 60);
  setenv("TZ", buf, 1);
  tzset();
  return oldtz;
}


x86 assembly (clang, -O0):
<tz_push_off>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe9e(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1183 <tz_push_off+0x33>
mov    -0x10(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    119a <tz_push_off+0x4a>
imul   $0xffffffff,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %edx,%r8d
mov    $0x20,%esi
lea    0xe3e(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe2b(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    $0x0,%al
call   1060 <tzset@plt>
mov    -0x10(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tz_push_off>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %edi,%ebp
lea    0xea1(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1176 <tz_push_off+0x26>
mov    %rax,%rdi
call   1070 <strdup@plt>
mov    %rax,%rbx
jmp    1178 <tz_push_off+0x28>
xor    %ebx,%ebx
mov    %ebp,%r8d
neg    %r8d
cmovs  %ebp,%r8d
movslq %ebp,%rcx
imul   $0xffffffff88888889,%rcx,%rax
shr    $0x20,%rax
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x5,%ecx
add    %eax,%ecx
mov    $0x88888889,%eax
imul   %r8,%rax
shr    $0x25,%rax
imul   $0x3c,%eax,%eax
sub    %eax,%r8d
lea    0xe4d(%rip),%rdx
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1050 <snprintf@plt>
lea    0xe33(%rip),%rdi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
xor    %eax,%eax
call   1060 <tzset@plt>
mov    %rbx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"TZ\00"
@.str.1 = [15 x i8] c"UTC+%+02d:%02d\00"
define i8* @tz_push_off(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [32 x i8]
store i32 %0, i32* %2
%6 = call i8* @getenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i8* @strdup(i8* %10)
store i8* %11, i8** %3
br label %12
12: ; preds = %9, %1
%13 = load i32, i32* %2
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %4
%18 = mul nsw i32 %17, -1
store i32 %18, i32* %4
br label %19
19: ; preds = %16, %12
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%21 = load i32, i32* %2
%22 = sdiv i32 %21, 60
%23 = load i32, i32* %4
%24 = srem i32 %23, 60
%25 = call i32 @snprintf(i8* %20, i32 32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %24)
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%27 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %26, i32 1)
%28 = call i32 (...) @tzset()
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
@.str = [3 x i8] c"TZ\00"
@.str.1 = [15 x i8] c"UTC+%+02d:%02d\00"
define noalias i8* @tz_push_off(i32 %0) {
%2 = alloca [32 x i8]
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = tail call i8* @strdup(i8* %3)
br label %7
7: ; preds = %5, %1
%8 = phi i8* [ %6, %5 ], [ null, %1 ]
%9 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%11 = sdiv i32 %0, 60
%12 = urem i32 %9, 60
%13 = call i32 @snprintf(i8* %10, i32 32, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
%14 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10, i32 1)
%15 = call i32 (...) @tzset()
ret i8* %8
}