#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 dummy;
};

/* Variables and functions */
char *asctime_r(struct tm const *, char *);
size_t strlen(char *);
const char *Zasctime(const struct tm *tm) {
  size_t n = 0;
  static char buf[64], *p = NULL;
  buf[0] = '\0';
  p = asctime_r(tm, buf);
  if (NULL == p)
    return p;
  buf[64 - 1] = '\0';
  n = strlen(buf);
  if ((n > (size_t)1) && ('\n' == buf[n - 1])) {
    buf[n - 1] = '\0';
  }
  return buf;
}


x86 assembly (clang, -O0):
<Zasctime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movb   $0x0,0x2f05(%rip)
mov    -0x10(%rbp),%rdi
lea    0x2efa(%rip),%rsi
call   1040 <asctime_r@plt>
mov    %rax,0x2f2e(%rip)
xor    %eax,%eax
cmp    0x2f25(%rip),%rax
jne    1171 <Zasctime+0x51>
mov    0x2f18(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d1 <Zasctime+0xb1>
movb   $0x0,0x2f07(%rip)
lea    0x2ec1(%rip),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x1,-0x18(%rbp)
jbe    11c6 <Zasctime+0xa6>
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
lea    0x2e9e(%rip),%rax
movsbl (%rax,%rcx,1),%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
jne    11c6 <Zasctime+0xa6>
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
lea    0x2e7e(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e73(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Zasctime>:
push   %rbx
movb   $0x0,0x2f18(%rip)
lea    0x2f11(%rip),%rbx
mov    %rbx,%rsi
call   1040 <asctime_r@plt>
mov    %rax,0x2f42(%rip)
test   %rax,%rax
je     1174 <Zasctime+0x54>
movb   $0x0,0x2f35(%rip)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%rax
jb     1176 <Zasctime+0x56>
lea    0x2ee1(%rip),%rbx
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1176 <Zasctime+0x56>
lea    0x2ed3(%rip),%rbx
movb   $0x0,-0x1(%rax,%rbx,1)
jmp    1176 <Zasctime+0x56>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@Zasctime.buf = internal global [64 x i8] zeroinitializer
@Zasctime.p = internal global i8* null
define i8* @Zasctime(%struct.tm* %0) {
%2 = alloca i8*
%3 = alloca %struct.tm*
%4 = alloca i64
store %struct.tm* %0, %struct.tm** %3
store i64 0, i64* %4
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 0)
%5 = load %struct.tm*, %struct.tm** %3
%6 = call i8* @asctime_r(%struct.tm* %5, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 0))
store i8* %6, i8** @Zasctime.p
%7 = load i8*, i8** @Zasctime.p
%8 = icmp eq i8* null, %7
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i8*, i8** @Zasctime.p
store i8* %10, i8** %2
br label %27
11: ; preds = %1
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 63)
%12 = call i64 @strlen(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 0))
store i64 %12, i64* %4
%13 = load i64, i64* %4
%14 = icmp ugt i64 %13, 1
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load i64, i64* %4
%17 = sub i64 %16, 1
%18 = getelementptr inbounds [64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 10, %20
br i1 %21, label %22, label %26
22: ; preds = %15
%23 = load i64, i64* %4
%24 = sub i64 %23, 1
%25 = getelementptr inbounds [64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 %24
store i8 0, i8* %25
br label %26
26: ; preds = %22, %15, %11
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 0), i8** %2
br label %27
27: ; preds = %26, %9
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@Zasctime.buf = internal global [64 x i8] zeroinitializer
@Zasctime.p = internal unnamed_addr global i8* null
define i8* @Zasctime(%struct.tm* %0) {
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 0)
%2 = tail call i8* @asctime_r(%struct.tm* %0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 0))
store i8* %2, i8** @Zasctime.p
%3 = icmp eq i8* %2, null
br i1 %3, label %13, label %4
4: ; preds = %1
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 63)
%5 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 0))
%6 = icmp ugt i64 %5, 1
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = add i64 %5, -1
%9 = getelementptr inbounds [64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 10
br i1 %11, label %12, label %13
12: ; preds = %7
store i8 0, i8* %9
br label %13
13: ; preds = %4, %7, %12, %1
%14 = phi i8* [ null, %1 ], [ getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 0), %12 ], [ getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 0), %7 ], [ getelementptr inbounds ([64 x i8], [64 x i8]* @Zasctime.buf, i64 0, i64 0), %4 ]
ret i8* %14
}