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

/* Variables and functions */
int /*<<< orphan*/ ct_numb(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
char *asctime_r(const struct tm *t, char *buf) {
  char *ncp;
  strcpy(buf, "Thu Jan 01 00:00:00 1970\n");
  ncp = &"SunMonTueWedThuFriSat"[t->tm_wday * 3];
  buf[0] = *ncp++;
  buf[1] = *ncp++;
  buf[2] = *ncp;
  ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[t->tm_mon * 3];
  buf[4] = *ncp++;
  buf[5] = *ncp++;
  buf[6] = *ncp;
  ct_numb(buf + 8, t->tm_mday);
  ct_numb(buf + 11, t->tm_hour + 100);
  ct_numb(buf + 14, t->tm_min + 100);
  ct_numb(buf + 17, t->tm_sec + 100);
  if (t->tm_year >= 100) {
    buf[20] = '2';
    buf[21] = '0';
  }
  ct_numb(buf + 22, t->tm_year + 100);
  return buf;
}


x86 assembly (clang, -O0):
<asctime_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rax
imul   $0x3,(%rax),%eax
movslq %eax,%rcx
lea    0xec9(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x8(%rbp),%rax
imul   $0x3,0x4(%rax),%eax
movslq %eax,%rcx
lea    0xe8a(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x10(%rbp),%rdi
add    $0x8,%rdi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%esi
call   1030 <ct_numb@plt>
mov    -0x10(%rbp),%rdi
add    $0xb,%rdi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
add    $0x64,%esi
call   1030 <ct_numb@plt>
mov    -0x10(%rbp),%rdi
add    $0xe,%rdi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%esi
add    $0x64,%esi
call   1030 <ct_numb@plt>
mov    -0x10(%rbp),%rdi
add    $0x11,%rdi
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%esi
add    $0x64,%esi
call   1030 <ct_numb@plt>
mov    -0x8(%rbp),%rax
cmpl   $0x64,0x18(%rax)
jl     1261 <asctime_r+0x141>
mov    -0x10(%rbp),%rax
movb   $0x32,0x14(%rax)
mov    -0x10(%rbp),%rax
movb   $0x30,0x15(%rax)
mov    -0x10(%rbp),%rdi
add    $0x16,%rdi
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%esi
add    $0x64,%esi
call   1030 <ct_numb@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asctime_r>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xecf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
movslq (%r14),%rax
lea    (%rax,%rax,2),%rax
lea    0xed3(%rip),%rcx
movzwl (%rcx,%rax,1),%edx
mov    %dx,(%rbx)
mov    0x2(%rcx,%rax,1),%al
mov    %al,0x2(%rbx)
movslq 0x4(%r14),%rax
lea    (%rax,%rax,2),%rax
lea    0xecc(%rip),%rcx
movzwl (%rcx,%rax,1),%edx
mov    %dx,0x4(%rbx)
mov    0x2(%rcx,%rax,1),%al
mov    %al,0x6(%rbx)
lea    0x8(%rbx),%rdi
mov    0x8(%r14),%esi
call   1030 <ct_numb@plt>
lea    0xb(%rbx),%rdi
mov    0xc(%r14),%esi
add    $0x64,%esi
call   1030 <ct_numb@plt>
lea    0xe(%rbx),%rdi
mov    0x10(%r14),%esi
add    $0x64,%esi
call   1030 <ct_numb@plt>
lea    0x11(%rbx),%rdi
mov    0x14(%r14),%esi
add    $0x64,%esi
call   1030 <ct_numb@plt>
mov    0x18(%r14),%esi
cmp    $0x64,%esi
jl     11c3 <asctime_r+0xa3>
movw   $0x3032,0x14(%rbx)
mov    0x18(%r14),%esi
lea    0x16(%rbx),%rdi
add    $0x64,%esi
call   1030 <ct_numb@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [26 x i8] c"Thu Jan 01 00:00:00 1970\0A\00"
@.str.1 = [22 x i8] c"SunMonTueWedThuFriSat\00"
@.str.2 = [37 x i8] c"JanFebMarAprMayJunJulAugSepOctNovDec\00"
define i8* @asctime_r(%struct.tm* %0, i8* %1) {
%3 = alloca %struct.tm*
%4 = alloca i8*
%5 = alloca i8*
store %struct.tm* %0, %struct.tm** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = load %struct.tm*, %struct.tm** %3
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = mul nsw i32 %10, 3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [22 x i8], [22 x i8]* @.str.1, i64 0, i64 %12
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %5
%16 = load i8, i8* %14
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 0
store i8 %16, i8* %18
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %5
%21 = load i8, i8* %19
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8 %21, i8* %23
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 2
store i8 %25, i8* %27
%28 = load %struct.tm*, %struct.tm** %3
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 1
%30 = load i32, i32* %29
%31 = mul nsw i32 %30, 3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [37 x i8], [37 x i8]* @.str.2, i64 0, i64 %32
store i8* %33, i8** %5
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
%36 = load i8, i8* %34
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 4
store i8 %36, i8* %38
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %5
%41 = load i8, i8* %39
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i64 5
store i8 %41, i8* %43
%44 = load i8*, i8** %5
%45 = load i8, i8* %44
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i64 6
store i8 %45, i8* %47
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 8
%50 = load %struct.tm*, %struct.tm** %3
%51 = getelementptr inbounds %struct.tm, %struct.tm* %50, i32 0, i32 2
%52 = load i32, i32* %51
%53 = call i32 @ct_numb(i8* %49, i32 %52)
%54 = load i8*, i8** %4
%55 = getelementptr inbounds i8, i8* %54, i64 11
%56 = load %struct.tm*, %struct.tm** %3
%57 = getelementptr inbounds %struct.tm, %struct.tm* %56, i32 0, i32 3
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 100
%60 = call i32 @ct_numb(i8* %55, i32 %59)
%61 = load i8*, i8** %4
%62 = getelementptr inbounds i8, i8* %61, i64 14
%63 = load %struct.tm*, %struct.tm** %3
%64 = getelementptr inbounds %struct.tm, %struct.tm* %63, i32 0, i32 4
%65 = load i32, i32* %64
%66 = add nsw i32 %65, 100
%67 = call i32 @ct_numb(i8* %62, i32 %66)
%68 = load i8*, i8** %4
%69 = getelementptr inbounds i8, i8* %68, i64 17
%70 = load %struct.tm*, %struct.tm** %3
%71 = getelementptr inbounds %struct.tm, %struct.tm* %70, i32 0, i32 5
%72 = load i32, i32* %71
%73 = add nsw i32 %72, 100
%74 = call i32 @ct_numb(i8* %69, i32 %73)
%75 = load %struct.tm*, %struct.tm** %3
%76 = getelementptr inbounds %struct.tm, %struct.tm* %75, i32 0, i32 6
%77 = load i32, i32* %76
%78 = icmp sge i32 %77, 100
br i1 %78, label %79, label %84
79: ; preds = %2
%80 = load i8*, i8** %4
%81 = getelementptr inbounds i8, i8* %80, i64 20
store i8 50, i8* %81
%82 = load i8*, i8** %4
%83 = getelementptr inbounds i8, i8* %82, i64 21
store i8 48, i8* %83
br label %84
84: ; preds = %79, %2
%85 = load i8*, i8** %4
%86 = getelementptr inbounds i8, i8* %85, i64 22
%87 = load %struct.tm*, %struct.tm** %3
%88 = getelementptr inbounds %struct.tm, %struct.tm* %87, i32 0, i32 6
%89 = load i32, i32* %88
%90 = add nsw i32 %89, 100
%91 = call i32 @ct_numb(i8* %86, i32 %90)
%92 = load i8*, i8** %4
ret i8* %92
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [26 x i8] c"Thu Jan 01 00:00:00 1970\0A\00"
@.str.1 = [22 x i8] c"SunMonTueWedThuFriSat\00"
@.str.2 = [37 x i8] c"JanFebMarAprMayJunJulAugSepOctNovDec\00"
define i8* @asctime_r(%struct.tm* nocapture %0, i8* returned %1) {
%3 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
%5 = load i32, i32* %4
%6 = mul nsw i32 %5, 3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [22 x i8], [22 x i8]* @.str.1, i64 0, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %8
store i8 %10, i8* %1
%11 = getelementptr inbounds i8, i8* %8, i64 2
%12 = load i8, i8* %9
%13 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %12, i8* %13
%14 = load i8, i8* %11
%15 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %14, i8* %15
%16 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 1
%17 = load i32, i32* %16
%18 = mul nsw i32 %17, 3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [37 x i8], [37 x i8]* @.str.2, i64 0, i64 %19
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %20
%23 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %22, i8* %23
%24 = getelementptr inbounds i8, i8* %20, i64 2
%25 = load i8, i8* %21
%26 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %25, i8* %26
%27 = load i8, i8* %24
%28 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %27, i8* %28
%29 = getelementptr inbounds i8, i8* %1, i64 8
%30 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 2
%31 = load i32, i32* %30
%32 = tail call i32 @ct_numb(i8* %29, i32 %31)
%33 = getelementptr inbounds i8, i8* %1, i64 11
%34 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 3
%35 = load i32, i32* %34
%36 = add nsw i32 %35, 100
%37 = tail call i32 @ct_numb(i8* %33, i32 %36)
%38 = getelementptr inbounds i8, i8* %1, i64 14
%39 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 4
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 100
%42 = tail call i32 @ct_numb(i8* %38, i32 %41)
%43 = getelementptr inbounds i8, i8* %1, i64 17
%44 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 5
%45 = load i32, i32* %44
%46 = add nsw i32 %45, 100
%47 = tail call i32 @ct_numb(i8* %43, i32 %46)
%48 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 6
%49 = load i32, i32* %48
%50 = icmp sgt i32 %49, 99
br i1 %50, label %51, label %55
51: ; preds = %2
%52 = getelementptr inbounds i8, i8* %1, i64 20
store i8 50, i8* %52
%53 = getelementptr inbounds i8, i8* %1, i64 21
store i8 48, i8* %53
%54 = load i32, i32* %48
br label %55
55: ; preds = %51, %2
%56 = phi i32 [ %54, %51 ], [ %49, %2 ]
%57 = getelementptr inbounds i8, i8* %1, i64 22
%58 = add nsw i32 %56, 100
%59 = tail call i32 @ct_numb(i8* %57, i32 %58)
ret i8* %1
}