#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 */
struct tm *gmtime(int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *date_stamp(int utc) {
  struct tm *cas;
  static char tt[32];
  time_t secs = time(NULL);
  if (utc)
    cas = gmtime(&secs);
  else
    cas = localtime(&secs);
  strftime(tt, 30, "%x", cas);
  return tt;
}


x86 assembly (clang, -O0):
<date_stamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1173 <date_stamp+0x33>
lea    -0x14(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x10(%rbp)
jmp    1180 <date_stamp+0x40>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
lea    0x2ec5(%rip),%rdi
mov    $0x1e,%esi
lea    0xe69(%rip),%rdx
call   1050 <strftime@plt>
lea    0x2ead(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<date_stamp>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
test   %ebx,%ebx
je     1162 <date_stamp+0x22>
call   1060 <gmtime@plt>
jmp    1167 <date_stamp+0x27>
call   1030 <localtime@plt>
lea    0x2ee2(%rip),%rbx
lea    0xe8b(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1e,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@date_stamp.tt = internal global [32 x i8] zeroinitializer
@.str = [3 x i8] c"%x\00"
define i8* @date_stamp(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 @time(i32* null)
store i32 %5, i32* %4
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call %struct.tm* @gmtime(i32* %4)
store %struct.tm* %9, %struct.tm** %3
br label %12
10: ; preds = %1
%11 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %11, %struct.tm** %3
br label %12
12: ; preds = %10, %8
%13 = load %struct.tm*, %struct.tm** %3
%14 = call i32 @strftime(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @date_stamp.tt, i64 0, i64 0), i32 30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %13)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @date_stamp.tt, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@date_stamp.tt = internal global [32 x i8] zeroinitializer
@.str = [3 x i8] c"%x\00"
define i8* @date_stamp(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %2
%5 = icmp eq i32 %0, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call %struct.tm* @gmtime(i32* %2)
br label %10
8: ; preds = %1
%9 = call %struct.tm* @localtime(i32* %2)
br label %10
10: ; preds = %8, %6
%11 = phi %struct.tm* [ %7, %6 ], [ %9, %8 ]
%12 = call i32 @strftime(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @date_stamp.tt, i64 0, i64 0), i32 30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %11)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @date_stamp.tt, i64 0, i64 0)
}