#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 */

/* Variables and functions */
int /*<<< orphan*/ date_unix2dos(long, unsigned short *, unsigned short *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned short);
long time(int /*<<< orphan*/);
char *unix_to_sfbin_date_string(long gmt) {
  static char buf[9];
  unsigned short s_time, s_date;
  date_unix2dos(((gmt == -1) ? time(0) : gmt), &s_time, &s_date);
  sprintf(buf, "%X", ((s_date << 16) + s_time));
  return buf;
}


x86 assembly (clang, -O0):
<unix_to_sfbin_date_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0xffffffffffffffff,-0x8(%rbp)
jne    1157 <unix_to_sfbin_date_string+0x27>
xor    %edi,%edi
call   1030 <time@plt>
mov    %rax,-0x18(%rbp)
jmp    115f <unix_to_sfbin_date_string+0x2f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0xa(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <date_unix2dos@plt>
movzwl -0xc(%rbp),%eax
shl    $0x10,%eax
movzwl -0xa(%rbp),%ecx
add    %ecx,%eax
lea    0x2eb5(%rip),%rdi
lea    0xe75(%rip),%rsi
movzwl %ax,%edx
call   1050 <sprintf@plt>
lea    0x2e9f(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unix_to_sfbin_date_string>:
push   %rbx
sub    $0x10,%rsp
cmp    $0xffffffffffffffff,%rdi
jne    1145 <unix_to_sfbin_date_string+0x15>
xor    %edi,%edi
call   1030 <time@plt>
mov    %rax,%rdi
lea    0xc(%rsp),%rsi
lea    0xe(%rsp),%rdx
call   1040 <date_unix2dos@plt>
movzwl 0xc(%rsp),%edx
lea    0x2ed9(%rip),%rbx
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@unix_to_sfbin_date_string.buf = internal global [9 x i8] zeroinitializer
@.str = [3 x i8] c"%X\00"
define i8* @unix_to_sfbin_date_string(i64 %0) {
%2 = alloca i64
%3 = alloca i16
%4 = alloca i16
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = icmp eq i64 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i64 @time(i32 0)
br label %11
9: ; preds = %1
%10 = load i64, i64* %2
br label %11
11: ; preds = %9, %7
%12 = phi i64 [ %8, %7 ], [ %10, %9 ]
%13 = call i32 @date_unix2dos(i64 %12, i16* %3, i16* %4)
%14 = load i16, i16* %4
%15 = zext i16 %14 to i32
%16 = shl i32 %15, 16
%17 = load i16, i16* %3
%18 = zext i16 %17 to i32
%19 = add nsw i32 %16, %18
%20 = trunc i32 %19 to i16
%21 = call i32 @sprintf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @unix_to_sfbin_date_string.buf, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i16 zeroext %20)
ret i8* getelementptr inbounds ([9 x i8], [9 x i8]* @unix_to_sfbin_date_string.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@unix_to_sfbin_date_string.buf = internal global [9 x i8] zeroinitializer
@.str = [3 x i8] c"%X\00"
define i8* @unix_to_sfbin_date_string(i64 %0) {
%2 = alloca i16
%3 = alloca i16
%4 = bitcast i16* %2 to i8*
%5 = bitcast i16* %3 to i8*
%6 = icmp eq i64 %0, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i64 @time(i32 0)
br label %9
9: ; preds = %1, %7
%10 = phi i64 [ %8, %7 ], [ %0, %1 ]
%11 = call i32 @date_unix2dos(i64 %10, i16* %2, i16* %3)
%12 = load i16, i16* %2
%13 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @unix_to_sfbin_date_string.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i16 zeroext %12)
ret i8* getelementptr inbounds ([9 x i8], [9 x i8]* @unix_to_sfbin_date_string.buf, i64 0, i64 0)
}