#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 */
struct tm {
  int tm_year;
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
  int /*<<< orphan*/ tm_mday;
  scalar_t__ tm_mon;
};

/* Variables and functions */
int asprintf(char **, char *, int, scalar_t__, int /*<<< orphan*/,
             int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
char *utctime_string_from_tm(struct tm *tm) {
  char *ret = NULL;
  if (tm->tm_year >= 150 || tm->tm_year < 50)
    return (NULL);
  if (asprintf(&ret, "%02u%02u%02u%02u%02u%02uZ", tm->tm_year % 100,
               tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
               tm->tm_sec) == -1)
    ret = NULL;
  return (ret);
}


x86 assembly (clang, -O0):
<utctime_string_from_tm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x96,(%rax)
jge    1141 <utctime_string_from_tm+0x31>
mov    -0x10(%rbp),%rax
cmpl   $0x32,(%rax)
jge    114e <utctime_string_from_tm+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    11b8 <utctime_string_from_tm+0xa8>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
lea    -0x18(%rbp),%rdi
lea    0xe6e(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <asprintf@plt>
cmp    $0xffffffff,%eax
jne    11b0 <utctime_string_from_tm+0xa0>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utctime_string_from_tm>:
push   %rax
movq   $0x0,(%rsp)
mov    (%rdi),%eax
lea    -0x96(%rax),%ecx
cmp    $0xffffff9c,%ecx
jb     1175 <utctime_string_from_tm+0x65>
movzbl %al,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,8),%ecx
movzwl %cx,%ecx
shr    $0xc,%ecx
imul   $0x64,%ecx,%ecx
sub    %cl,%al
movzbl %al,%edx
mov    0x18(%rdi),%rcx
add    $0x1,%rcx
mov    0x10(%rdi),%r8d
mov    0xc(%rdi),%r9d
mov    0x4(%rdi),%eax
mov    0x8(%rdi),%r10d
lea    0xea5(%rip),%rsi
mov    %rsp,%rdi
push   %rax
push   %r10
call   1030 <asprintf@plt>
add    $0x10,%rsp
cmp    $0xffffffff,%eax
je     1175 <utctime_string_from_tm+0x65>
mov    (%rsp),%rax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i64 }
@.str = [26 x i8] c"%02u%02u%02u%02u%02u%02uZ\00"
define i8* @utctime_string_from_tm(%struct.tm* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm*
%4 = alloca i8*
store %struct.tm* %0, %struct.tm** %3
store i8* null, i8** %4
%5 = load %struct.tm*, %struct.tm** %3
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = icmp sge i32 %7, 150
br i1 %8, label %14, label %9
9: ; preds = %1
%10 = load %struct.tm*, %struct.tm** %3
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = icmp slt i32 %12, 50
br i1 %13, label %14, label %15
14: ; preds = %9, %1
store i8* null, i8** %2
br label %41
15: ; preds = %9
%16 = load %struct.tm*, %struct.tm** %3
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = srem i32 %18, 100
%20 = load %struct.tm*, %struct.tm** %3
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 5
%22 = load i64, i64* %21
%23 = add nsw i64 %22, 1
%24 = load %struct.tm*, %struct.tm** %3
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 4
%26 = load i32, i32* %25
%27 = load %struct.tm*, %struct.tm** %3
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 3
%29 = load i32, i32* %28
%30 = load %struct.tm*, %struct.tm** %3
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 2
%32 = load i32, i32* %31
%33 = load %struct.tm*, %struct.tm** %3
%34 = getelementptr inbounds %struct.tm, %struct.tm* %33, i32 0, i32 1
%35 = load i32, i32* %34
%36 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %19, i64 %23, i32 %26, i32 %29, i32 %32, i32 %35)
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %39
38: ; preds = %15
store i8* null, i8** %4
br label %39
39: ; preds = %38, %15
%40 = load i8*, i8** %4
store i8* %40, i8** %2
br label %41
41: ; preds = %39, %14
%42 = load i8*, i8** %2
ret i8* %42
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i64 }
@.str = [26 x i8] c"%02u%02u%02u%02u%02u%02uZ\00"
define i8* @utctime_string_from_tm(%struct.tm* nocapture %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
%5 = load i32, i32* %4
%6 = add i32 %5, -150
%7 = icmp ult i32 %6, -100
br i1 %7, label %27, label %8
8: ; preds = %1
%9 = trunc i32 %5 to i8
%10 = urem i8 %9, 100
%11 = zext i8 %10 to i32
%12 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 5
%13 = load i64, i64* %12
%14 = add nsw i64 %13, 1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 4
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 3
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 2
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 1
%22 = load i32, i32* %21
%23 = call i32 @asprintf(i8** %2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %11, i64 %14, i32 %16, i32 %18, i32 %20, i32 %22)
%24 = icmp eq i32 %23, -1
%25 = load i8*, i8** %2
%26 = select i1 %24, i8* null, i8* %25
br label %27
27: ; preds = %8, %1
%28 = phi i8* [ null, %1 ], [ %26, %8 ]
ret i8* %28
}