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

/* Variables and functions */
int EXIT_SUCCESS;
char *asctime(struct tm const *);
char *asctime_r(struct tm const *, char *);
int /*<<< orphan*/ assert(int);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int, int);
scalar_t__ strcmp(char *, char *);
int main(void) {
  char *buf;
  struct tm const tm = {
      .tm_sec = 20,
      .tm_min = 21,
      .tm_hour = 22,
      .tm_mday = 10,
      .tm_mon = 11,
      .tm_year = 112,
  };
  char *res;
  buf = malloc(4096);
  assert(buf != NULL);
  memset(buf, 23, 4096);
  res = asctime_r(&tm, buf);
  assert(strcmp(res, asctime(&tm)) == 0);
  assert(strcmp(res, "Sun Dec 10 22:21:20 2012\n") == 0);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x1000,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x17,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rsi
lea    -0x28(%rbp),%rdi
call   1080 <asctime_r@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x28(%rbp),%rdi
call   1030 <asctime@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x30(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0xea2(%rip),%rax
mov    %rax,0x10(%rsp)
movups 0xe86(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x1000,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0x17,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <asctime_r@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <asctime@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xe34(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    0x2ddf(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@__const.main.tm = %struct.tm { i32 20, i32 21, i32 22, i32 10, i32 11, i32 112 }
@.str = [26 x i8] c"Sun Dec 10 22:21:20 2012\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca %struct.tm
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast %struct.tm* %3 to i8*
%6 = call i8* @malloc(i32 4096)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = icmp ne i8* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8*, i8** %2
%12 = call i32 @memset(i8* %11, i32 23, i32 4096)
%13 = load i8*, i8** %2
%14 = call i8* @asctime_r(%struct.tm* %3, i8* %13)
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = call i8* @asctime(%struct.tm* %3)
%17 = call i64 @strcmp(i8* %15, i8* %16)
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i8*, i8** %4
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@__const.main.tm = %struct.tm { i32 20, i32 21, i32 22, i32 10, i32 11, i32 112 }
@.str = [26 x i8] c"Sun Dec 10 22:21:20 2012\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.tm
%2 = bitcast %struct.tm* %1 to i8*
%3 = tail call dereferenceable_or_null(4096) i8* @malloc(i32 4096)
%4 = icmp ne i8* %3, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 @memset(i8* %3, i32 23, i32 4096)
%8 = call i8* @asctime_r(%struct.tm* %1, i8* %3)
%9 = call i8* @asctime(%struct.tm* %1)
%10 = call i64 @strcmp(i8* %8, i8* %9)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}