#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 tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
struct tm *gmtime(int /*<<< orphan*/ const *);
int snprintf(char *, int, char *, int, int, int, int, int, int);
char *zulutime1(const time_t *timep) {
  static char zulu[22];
  int rc;
  struct tm *tms = gmtime(timep);
  bzero(zulu, 22);
  if (NULL == tms) {
    return NULL;
  }
  rc = snprintf(zulu, 22, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ", tms->tm_year + 1900,
                tms->tm_mon + 1, tms->tm_mday, tms->tm_hour, tms->tm_min,
                tms->tm_sec);
  if (rc < 0)
    return NULL;
  return zulu;
}


x86 assembly (clang, -O0):
<zulutime1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,-0x20(%rbp)
lea    0x2f00(%rip),%rdi
mov    $0x16,%esi
call   1040 <bzero@plt>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    1173 <zulutime1+0x43>
movq   $0x0,-0x8(%rbp)
jmp    11f4 <zulutime1+0xc4>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x76c,%ecx
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%r8d
add    $0x1,%r8d
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%r9d
mov    -0x20(%rbp),%rax
mov    0xc(%rax),%r11d
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%eax
lea    0x2e9f(%rip),%rdi
mov    $0x16,%esi
lea    0xe43(%rip),%rdx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <snprintf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11e9 <zulutime1+0xb9>
movq   $0x0,-0x8(%rbp)
jmp    11f4 <zulutime1+0xc4>
lea    0x2e60(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zulutime1>:
push   %r14
push   %rbx
push   %rax
call   1050 <gmtime@plt>
mov    %rax,%rbx
lea    0x2f0d(%rip),%r14
mov    %r14,%rdi
mov    $0x16,%esi
call   1040 <bzero@plt>
test   %rbx,%rbx
je     119e <zulutime1+0x6e>
mov    $0x76c,%ecx
add    (%rbx),%ecx
mov    0x4(%rbx),%r8d
mov    0x8(%rbx),%r9d
add    $0x1,%r8d
mov    0xc(%rbx),%r10d
mov    0x10(%rbx),%eax
mov    0x14(%rbx),%ebx
sub    $0x8,%rsp
lea    0xe83(%rip),%rdx
mov    %r14,%rdi
mov    $0x16,%esi
push   %rbx
push   %rax
push   %r10
call   1030 <snprintf@plt>
add    $0x20,%rsp
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
cmovns %r14,%rax
jmp    11a0 <zulutime1+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@zulutime1.zulu = internal global [22 x i8] zeroinitializer
@.str = [31 x i8] c"%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ\00"
define i8* @zulutime1(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct.tm*
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call %struct.tm* @gmtime(i32* %6)
store %struct.tm* %7, %struct.tm** %5
%8 = call i32 @bzero(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @zulutime1.zulu, i64 0, i64 0), i32 22)
%9 = load %struct.tm*, %struct.tm** %5
%10 = icmp eq %struct.tm* null, %9
br i1 %10, label %11, label %12
11: ; preds = %1
store i8* null, i8** %2
br label %38
12: ; preds = %1
%13 = load %struct.tm*, %struct.tm** %5
%14 = getelementptr inbounds %struct.tm, %struct.tm* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1900
%17 = load %struct.tm*, %struct.tm** %5
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 1
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1
%21 = load %struct.tm*, %struct.tm** %5
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 2
%23 = load i32, i32* %22
%24 = load %struct.tm*, %struct.tm** %5
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 3
%26 = load i32, i32* %25
%27 = load %struct.tm*, %struct.tm** %5
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 4
%29 = load i32, i32* %28
%30 = load %struct.tm*, %struct.tm** %5
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 5
%32 = load i32, i32* %31
%33 = call i32 @snprintf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @zulutime1.zulu, i64 0, i64 0), i32 22, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %20, i32 %23, i32 %26, i32 %29, i32 %32)
store i32 %33, i32* %4
%34 = load i32, i32* %4
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %12
store i8* null, i8** %2
br label %38
37: ; preds = %12
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @zulutime1.zulu, i64 0, i64 0), i8** %2
br label %38
38: ; preds = %37, %36, %11
%39 = load i8*, i8** %2
ret i8* %39
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@zulutime1.zulu = internal global [22 x i8] zeroinitializer
@.str = [31 x i8] c"%.4d-%.2d-%.2dT%.2d:%.2d:%.2dZ\00"
define i8* @zulutime1(i32* %0) {
%2 = tail call %struct.tm* @gmtime(i32* %0)
%3 = tail call i32 @bzero(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @zulutime1.zulu, i64 0, i64 0), i32 22)
%4 = icmp eq %struct.tm* %2, null
br i1 %4, label %23, label %5
5: ; preds = %1
%6 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
%7 = load i32, i32* %6
%8 = add nsw i32 %7, 1900
%9 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
%12 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 4
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 5
%19 = load i32, i32* %18
%20 = tail call i32 @snprintf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @zulutime1.zulu, i64 0, i64 0), i32 22, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11, i32 %13, i32 %15, i32 %17, i32 %19)
%21 = icmp slt i32 %20, 0
%22 = select i1 %21, i8* null, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @zulutime1.zulu, i64 0, i64 0)
br label %23
23: ; preds = %5, %1
%24 = phi i8* [ null, %1 ], [ %22, %5 ]
ret i8* %24
}