#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*/ get_gmtime(struct tm *);
int /*<<< orphan*/ get_localtime(struct tm *);
char *getenv(char *);
int /*<<< orphan*/ strcmp(char *, char *);
time_t get_time(struct tm *rectime) {
  static int utc = 0;
  char *e;
  if (!utc) {
    if ((e = getenv("S_TIME_DEF_TIME")) != NULL) {
      utc = !strcmp(e, "UTC");
    }
    utc++;
  }
  if (utc == 2)
    return get_gmtime(rectime);
  else
    return get_localtime(rectime);
}


x86 assembly (clang, -O0):
<get_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpl   $0x0,0x2ef1(%rip)
jne    11a5 <get_time+0x65>
lea    0xea0(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1196 <get_time+0x56>
mov    -0x18(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,0x2eae(%rip)
mov    0x2ea8(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e9f(%rip)
cmpl   $0x2,0x2e98(%rip)
jne    11c3 <get_time+0x83>
mov    -0x10(%rbp),%rdi
call   1050 <get_gmtime@plt>
mov    %eax,-0x4(%rbp)
jmp    11cf <get_time+0x8f>
mov    -0x10(%rbp),%rdi
call   1060 <get_localtime@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time>:
push   %rbx
mov    %rdi,%rbx
mov    0x2efa(%rip),%eax
test   %eax,%eax
jne    1186 <get_time+0x46>
lea    0xeab(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     117b <get_time+0x3b>
lea    0xeaa(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
cmp    $0x1,%eax
mov    $0x1,%eax
adc    $0x0,%eax
jmp    1180 <get_time+0x40>
mov    $0x1,%eax
mov    %eax,0x2ebe(%rip)
mov    %rbx,%rdi
cmp    $0x2,%eax
jne    1194 <get_time+0x54>
pop    %rbx
jmp    1050 <get_gmtime@plt>
pop    %rbx
jmp    1060 <get_localtime@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@get_time.utc = internal global i32 0
@.str = [16 x i8] c"S_TIME_DEF_TIME\00"
@.str.1 = [4 x i8] c"UTC\00"
define i32 @get_time(%struct.tm* %0) {
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca i8*
store %struct.tm* %0, %struct.tm** %3
%5 = load i32, i32* @get_time.utc
%6 = icmp ne i32 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %1
%8 = call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i8*, i8** %4
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
%15 = zext i1 %14 to i32
store i32 %15, i32* @get_time.utc
br label %16
16: ; preds = %10, %7
%17 = load i32, i32* @get_time.utc
%18 = add nsw i32 %17, 1
store i32 %18, i32* @get_time.utc
br label %19
19: ; preds = %16, %1
%20 = load i32, i32* @get_time.utc
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load %struct.tm*, %struct.tm** %3
%24 = call i32 @get_gmtime(%struct.tm* %23)
store i32 %24, i32* %2
br label %28
25: ; preds = %19
%26 = load %struct.tm*, %struct.tm** %3
%27 = call i32 @get_localtime(%struct.tm* %26)
store i32 %27, i32* %2
br label %28
28: ; preds = %25, %22
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@get_time.utc = internal unnamed_addr global i32 0
@.str = [16 x i8] c"S_TIME_DEF_TIME\00"
@.str.1 = [4 x i8] c"UTC\00"
define i32 @get_time(%struct.tm* %0) {
%2 = load i32, i32* @get_time.utc
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = tail call i8* @getenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* %5, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 2, i32 1
br label %11
11: ; preds = %7, %4
%12 = phi i32 [ %10, %7 ], [ 1, %4 ]
store i32 %12, i32* @get_time.utc
br label %13
13: ; preds = %11, %1
%14 = phi i32 [ %12, %11 ], [ %2, %1 ]
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @get_gmtime(%struct.tm* %0)
br label %20
18: ; preds = %13
%19 = tail call i32 @get_localtime(%struct.tm* %0)
br label %20
20: ; preds = %18, %16
%21 = phi i32 [ %17, %16 ], [ %19, %18 ]
ret i32 %21
}