#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 scalar_t__ time_t;
struct tm {
  int tm_isdst;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ localtime_r(scalar_t__ *, struct tm *);
scalar_t__ mktime(struct tm *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putenv(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ strptime(char *, char *, struct tm *);
int /*<<< orphan*/ tzset();
void vConv(int iDbgInfo, char *szSrcDateTime, char *szSrcTZ, char *szTrgTz,
           int iOutputFormat) {
  char szEnv[64];
  struct tm mytm = {0};
  time_t mytime;
  char buf[100];
  if (iDbgInfo)
    printf("TZ from: %s to: %s"
           "\n",
           szSrcTZ, szTrgTz);
  mytm.tm_isdst = -1;
  sprintf(szEnv, "TZ=%s", szSrcTZ);
  putenv(szEnv);
  tzset();
  strptime(szSrcDateTime, "%Y-%m-%d %H:%M:%S", &mytm);
  mytime = mktime(&mytm);
  if (iDbgInfo) {
    strftime(buf, 100, "%Y-%m-%d %H:%M:%S %z(%Z)", &mytm);
    printf("%s --> %d(UnixEpoch) --> ", buf, (long)mytime);
  }
  sprintf(szEnv, "TZ=%s", szTrgTz);
  putenv(szEnv);
  tzset();
  localtime_r(&mytime, &mytm);
  if (iDbgInfo) {
    strftime(buf, 100, "%Y-%m-%d %H:%M:%S %z(%Z)", &mytm);
    printf("%s"
           "\n",
           buf, (long)mytime);
  }
  switch (iOutputFormat) {
  default:
  case 0:
    strftime(buf, 100,
             "%Y-%m-%d %H:%M:%S"
             "\n",
             &mytm);
    break;
  case 1:
    strftime(buf, 100,
             "%Y%m%d %H%M%S"
             "\n",
             &mytm);
    break;
  }
  printf(buf);
}


x86 assembly (clang, -O0):
<vConv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
lea    -0x78(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
cmpl   $0x0,-0x4(%rbp)
je     11de <vConv+0x4e>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe20(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
call   1060 <putenv@plt>
mov    $0x0,%al
call   1070 <tzset@plt>
mov    -0x10(%rbp),%rdi
lea    0xe06(%rip),%rsi
lea    -0x78(%rbp),%rdx
call   10b0 <strptime@plt>
lea    -0x78(%rbp),%rdi
call   1080 <mktime@plt>
mov    %rax,-0x80(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1269 <vConv+0xd9>
lea    -0xf0(%rbp),%rdi
mov    $0x64,%esi
lea    0xde5(%rip),%rdx
lea    -0x78(%rbp),%rcx
call   1090 <strftime@plt>
lea    -0xf0(%rbp),%rsi
mov    -0x80(%rbp),%rdx
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd9c(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x70(%rbp),%rdi
call   1060 <putenv@plt>
mov    $0x0,%al
call   1070 <tzset@plt>
lea    -0x80(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   1030 <localtime_r@plt>
cmpl   $0x0,-0x4(%rbp)
je     12d9 <vConv+0x149>
lea    -0xf0(%rbp),%rdi
mov    $0x64,%esi
lea    0xd75(%rip),%rdx
lea    -0x78(%rbp),%rcx
call   1090 <strftime@plt>
lea    -0xf0(%rbp),%rsi
mov    -0x80(%rbp),%rdx
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0xf4(%rbp)
test   %eax,%eax
je     1308 <vConv+0x178>
jmp    12ef <vConv+0x15f>
mov    -0xf4(%rbp),%eax
sub    $0x1,%eax
je     1329 <vConv+0x199>
jmp    1303 <vConv+0x173>
jmp    1308 <vConv+0x178>
lea    -0xf0(%rbp),%rdi
mov    $0x64,%esi
lea    0xd44(%rip),%rdx
lea    -0x78(%rbp),%rcx
call   1090 <strftime@plt>
jmp    1345 <vConv+0x1b5>
lea    -0xf0(%rbp),%rdi
mov    $0x64,%esi
lea    0xd36(%rip),%rdx
lea    -0x78(%rbp),%rcx
call   1090 <strftime@plt>
lea    -0xf0(%rbp),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vConv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %r8d,%r13d
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rbp
movq   $0x0,(%rsp)
test   %edi,%edi
je     12a8 <vConv+0x118>
lea    0xe3c(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
movl   $0xffffffff,(%rsp)
lea    0xe35(%rip),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %r14,%rdx
call   10a0 <sprintf@plt>
mov    %r12,%rdi
call   1060 <putenv@plt>
xor    %eax,%eax
call   1070 <tzset@plt>
lea    0xe15(%rip),%rsi
mov    %rsp,%rbx
mov    %rbp,%rdi
mov    %rbx,%rdx
call   10b0 <strptime@plt>
mov    %rbx,%rdi
call   1080 <mktime@plt>
mov    %r13d,%r14d
mov    %rax,%r13
mov    %rax,0x8(%rsp)
lea    0xdff(%rip),%rdx
lea    0x50(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x64,%esi
mov    %rbx,%rcx
call   1090 <strftime@plt>
lea    0xdfc(%rip),%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
mov    %r14d,%r13d
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
lea    0xdb1(%rip),%rsi
mov    %r15,%rdx
call   10a0 <sprintf@plt>
mov    %r12,%rdi
call   1060 <putenv@plt>
xor    %eax,%eax
call   1070 <tzset@plt>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <localtime_r@plt>
mov    %rbp,%rdi
mov    $0x64,%esi
lea    0xd96(%rip),%rdx
mov    %rbx,%rcx
call   1090 <strftime@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
jmp    1324 <vConv+0x194>
movl   $0xffffffff,(%rsp)
lea    0xd5e(%rip),%r12
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <putenv@plt>
xor    %eax,%eax
call   1070 <tzset@plt>
lea    0xd3b(%rip),%rsi
mov    %rsp,%r14
mov    %rbp,%rdi
mov    %r14,%rdx
call   10b0 <strptime@plt>
mov    %r14,%rdi
call   1080 <mktime@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <putenv@plt>
xor    %eax,%eax
call   1070 <tzset@plt>
lea    0x8(%rsp),%rdi
mov    %r14,%rsi
call   1030 <localtime_r@plt>
cmp    $0x1,%r13d
lea    0xd43(%rip),%rax
lea    0xd29(%rip),%rdx
cmove  %rax,%rdx
lea    0x50(%rsp),%rbx
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1090 <strftime@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32 }
@.str = [20 x i8] c"TZ from: %s to: %s\0A\00"
@.str.1 = [6 x i8] c"TZ=%s\00"
@.str.2 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.3 = [25 x i8] c"%Y-%m-%d %H:%M:%S %z(%Z)\00"
@.str.4 = [26 x i8] c"%s --> %d(UnixEpoch) --> \00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [19 x i8] c"%Y-%m-%d %H:%M:%S\0A\00"
@.str.7 = [15 x i8] c"%Y%m%d %H%M%S\0A\00"
define void @vConv(i32 %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [64 x i8]
%12 = alloca %struct.tm
%13 = alloca i64
%14 = alloca [100 x i8]
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%15 = bitcast %struct.tm* %12 to i8*
%16 = load i32, i32* %6
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %5
%19 = load i8*, i8** %8
%20 = load i8*, i8** %9
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20)
br label %22
22: ; preds = %18, %5
%23 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 0
store i32 -1, i32* %23
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%25 = load i8*, i8** %8
%26 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%28 = call i32 @putenv(i8* %27)
%29 = call i32 (...) @tzset()
%30 = load i8*, i8** %7
%31 = call i32 @strptime(i8* %30, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %12)
%32 = call i64 @mktime(%struct.tm* %12)
store i64 %32, i64* %13
%33 = load i32, i32* %6
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %22
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%37 = call i32 @strftime(i8* %36, i32 100, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %12)
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%39 = load i64, i64* %13
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %38, i64 %39)
br label %41
41: ; preds = %35, %22
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%43 = load i8*, i8** %9
%44 = call i32 @sprintf(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%46 = call i32 @putenv(i8* %45)
%47 = call i32 (...) @tzset()
%48 = call i32 @localtime_r(i64* %13, %struct.tm* %12)
%49 = load i32, i32* %6
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %57
51: ; preds = %41
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%53 = call i32 @strftime(i8* %52, i32 100, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %12)
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%55 = load i64, i64* %13
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %54, i64 %55)
br label %57
57: ; preds = %51, %41
%58 = load i32, i32* %10
switch i32 %58, label %59 [
i32 0, label %60
i32 1, label %63
]
59: ; preds = %57
br label %60
60: ; preds = %57, %59
%61 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%62 = call i32 @strftime(i8* %61, i32 100, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), %struct.tm* %12)
br label %66
63: ; preds = %57
%64 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%65 = call i32 @strftime(i8* %64, i32 100, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), %struct.tm* %12)
br label %66
66: ; preds = %63, %60
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %14, i64 0, i64 0
%68 = call i32 (i8*, ...) @printf(i8* %67)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32 }
@.str = [20 x i8] c"TZ from: %s to: %s\0A\00"
@.str.1 = [6 x i8] c"TZ=%s\00"
@.str.2 = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.3 = [25 x i8] c"%Y-%m-%d %H:%M:%S %z(%Z)\00"
@.str.4 = [26 x i8] c"%s --> %d(UnixEpoch) --> \00"
@.str.6 = [19 x i8] c"%Y-%m-%d %H:%M:%S\0A\00"
@.str.7 = [15 x i8] c"%Y%m%d %H%M%S\0A\00"
define void @vConv(i32 %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca [64 x i8]
%7 = alloca i64
%8 = bitcast i64* %7 to %struct.tm*
%9 = alloca i64
%10 = alloca [100 x i8]
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%12 = bitcast i64* %7 to i8*
store i64 0, i64* %7
%13 = bitcast i64* %9 to i8*
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %10, i64 0, i64 0
%15 = icmp eq i32 %0, 0
br i1 %15, label %32, label %16
16: ; preds = %5
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3)
%18 = bitcast i64* %7 to i32*
store i32 -1, i32* %18
%19 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%20 = call i32 @putenv(i8* %11)
%21 = call i32 (...) @tzset()
%22 = call i32 @strptime(i8* %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %8)
%23 = call i64 @mktime(%struct.tm* %8)
store i64 %23, i64* %9
%24 = call i32 @strftime(i8* %14, i32 100, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %8)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %14, i64 %23)
%26 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%27 = call i32 @putenv(i8* %11)
%28 = call i32 (...) @tzset()
%29 = call i32 @localtime_r(i64* %9, %struct.tm* %8)
%30 = call i32 @strftime(i8* %14, i32 100, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), %struct.tm* %8)
%31 = call i32 @puts(i8* %14)
br label %43
32: ; preds = %5
%33 = bitcast i64* %7 to i32*
store i32 -1, i32* %33
%34 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%35 = call i32 @putenv(i8* %11)
%36 = call i32 (...) @tzset()
%37 = call i32 @strptime(i8* %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %8)
%38 = call i64 @mktime(%struct.tm* %8)
store i64 %38, i64* %9
%39 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%40 = call i32 @putenv(i8* %11)
%41 = call i32 (...) @tzset()
%42 = call i32 @localtime_r(i64* %9, %struct.tm* %8)
br label %43
43: ; preds = %32, %16
%44 = icmp eq i32 %4, 1
%45 = select i1 %44, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0)
%46 = call i32 @strftime(i8* %14, i32 100, i8* %45, %struct.tm* %8)
%47 = call i32 (i8*, ...) @printf(i8* %14)
ret void
}