#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;
};
typedef int /*<<< orphan*/ atom_datetime;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_escaped(char *, int);
int /*<<< orphan*/ printf(char *);
scalar_t__ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void print_updated(struct tm *datetime) {
  if (datetime == NULL) {
    time_t current_time = time(NULL);
    datetime = localtime(&current_time);
  }
  char atom_datetime[32] = {0};
  if (datetime != NULL) {
    if (strftime(atom_datetime, sizeof(atom_datetime), "%Y-%m-%dT%TZ",
                 datetime) == 0) {
      atom_datetime[0] = '\0';
    }
  }
  if (atom_datetime[0] != 0) {
    printf("\t\t<updated>");
    print_escaped(atom_datetime, false);
    printf("</updated>\n");
  }
}


x86 assembly (clang, -O0):
<print_updated>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1190 <print_updated+0x30>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
cmpq   $0x0,-0x8(%rbp)
je     11d7 <print_updated+0x77>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x20,%esi
lea    0xe41(%rip),%rdx
call   1070 <strftime@plt>
cmp    $0x0,%rax
jne    11d2 <print_updated+0x72>
movb   $0x0,-0x30(%rbp)
jmp    11d7 <print_updated+0x77>
movsbl -0x30(%rbp),%eax
cmp    $0x0,%eax
je     1207 <print_updated+0xa7>
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1080 <print_escaped@plt>
lea    0xe17(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_updated>:
sub    $0x28,%rsp
test   %rdi,%rdi
je     117a <print_updated+0x1a>
mov    %rdi,%rcx
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
jmp    11a0 <print_updated+0x40>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,(%rsp)
mov    %rsp,%rdi
call   1030 <localtime@plt>
mov    %rax,%rcx
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
test   %rax,%rax
je     11e1 <print_updated+0x81>
lea    0xe59(%rip),%rdx
mov    %rsp,%rdi
mov    $0x20,%esi
call   1070 <strftime@plt>
test   %rax,%rax
je     11e1 <print_updated+0x81>
cmpb   $0x0,(%rsp)
je     11e1 <print_updated+0x81>
lea    0xe47(%rip),%rdi
call   1050 <printf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1080 <print_escaped@plt>
lea    0xe3d(%rip),%rdi
call   1040 <puts@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [13 x i8] c"%Y-%m-%dT%TZ\00"
@.str.1 = [12 x i8] c"\09\09<updated>\00"
@.str.2 = [12 x i8] c"</updated>\0A\00"
define void @print_updated(%struct.tm* %0) {
%2 = alloca %struct.tm*
%3 = alloca i32
%4 = alloca [32 x i8]
store %struct.tm* %0, %struct.tm** %2
%5 = load %struct.tm*, %struct.tm** %2
%6 = icmp eq %struct.tm* %5, null
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = call i32 @time(i32* null)
store i32 %8, i32* %3
%9 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %9, %struct.tm** %2
br label %10
10: ; preds = %7, %1
%11 = bitcast [32 x i8]* %4 to i8*
%12 = load %struct.tm*, %struct.tm** %2
%13 = icmp ne %struct.tm* %12, null
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%16 = load %struct.tm*, %struct.tm** %2
%17 = call i64 @strftime(i8* %15, i32 32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.tm* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
store i8 0, i8* %20
br label %21
21: ; preds = %19, %14
br label %22
22: ; preds = %21, %10
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%30 = call i32 @print_escaped(i8* %29, i32 0)
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %27, %22
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [13 x i8] c"%Y-%m-%dT%TZ\00"
@.str.1 = [12 x i8] c"\09\09<updated>\00"
@str = [11 x i8] c"</updated>\00"
define void @print_updated(%struct.tm* %0) {
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = icmp eq %struct.tm* %0, null
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
br label %13
7: ; preds = %1
%8 = bitcast i32* %2 to i8*
%9 = tail call i32 @time(i32* null)
store i32 %9, i32* %2
%10 = call %struct.tm* @localtime(i32* %2)
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%12 = icmp eq %struct.tm* %10, null
br i1 %12, label %26, label %13
13: ; preds = %5, %7
%14 = phi %struct.tm* [ %0, %5 ], [ %10, %7 ]
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%16 = call i64 @strftime(i8* %15, i32 32, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %struct.tm* %14)
%17 = icmp eq i64 %16, 0
%18 = load i8, i8* %15
%19 = icmp eq i8 %18, 0
%20 = select i1 %17, i1 true, i1 %19
br i1 %20, label %26, label %21
21: ; preds = %13
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @print_escaped(i8* %22, i32 0)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %26
26: ; preds = %13, %7, %21
%27 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
ret void
}