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

/* Variables and functions */
int /*<<< orphan*/ gmtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int, int, int);
void ksdate_utcStringFromTimestamp(time_t timestamp, char *buffer21Chars) {
  struct tm result = {0};
  gmtime_r(&timestamp, &result);
  snprintf(buffer21Chars, 21, "%04d-%02d-%02dT%02d:%02d:%02dZ",
           result.tm_year + 1900, result.tm_mon + 1, result.tm_mday,
           result.tm_hour, result.tm_min, result.tm_sec);
}


x86 assembly (clang, -O0):
<ksdate_utcStringFromTimestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x1c,%edx
call   1050 <memset@plt>
lea    -0x4(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <gmtime_r@plt>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%ecx
add    $0x76c,%ecx
mov    -0x2c(%rbp),%r8d
add    $0x1,%r8d
mov    -0x28(%rbp),%r9d
mov    -0x24(%rbp),%r11d
mov    -0x20(%rbp),%r10d
mov    -0x1c(%rbp),%eax
mov    $0x15,%esi
lea    0xe74(%rip),%rdx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <snprintf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ksdate_utcStringFromTimestamp>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %edi,0xc(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x1c(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <gmtime_r@plt>
mov    $0x76c,%ecx
add    0x10(%rsp),%ecx
mov    0x14(%rsp),%r8d
mov    0x18(%rsp),%r9d
add    $0x1,%r8d
mov    0x1c(%rsp),%r10d
mov    0x20(%rsp),%ebx
mov    0x24(%rsp),%eax
sub    $0x8,%rsp
lea    0xe87(%rip),%rdx
mov    %r14,%rdi
mov    $0x15,%esi
push   %rax
push   %rbx
push   %r10
call   1030 <snprintf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [31 x i8] c"%04d-%02d-%02dT%02d:%02d:%02dZ\00"
define void @ksdate_utcStringFromTimestamp(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.tm
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = bitcast %struct.tm* %5 to i8*
%7 = call i32 @gmtime_r(i32* %3, %struct.tm* %5)
%8 = load i8*, i8** %4
%9 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1900
%12 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 3
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 4
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 5
%22 = load i32, i32* %21
%23 = call i32 @snprintf(i8* %8, i32 21, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %14, i32 %16, i32 %18, i32 %20, i32 %22)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [31 x i8] c"%04d-%02d-%02dT%02d:%02d:%02dZ\00"
define void @ksdate_utcStringFromTimestamp(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.tm
store i32 %0, i32* %3
%5 = bitcast %struct.tm* %4 to i8*
%6 = call i32 @gmtime_r(i32* %3, %struct.tm* %4)
%7 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1900
%10 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%20 = load i32, i32* %19
%21 = call i32 @snprintf(i8* %1, i32 21, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12, i32 %14, i32 %16, i32 %18, i32 %20)
ret void
}