#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;
  scalar_t__ tm_year;
};

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, int, int, int, int,
                           scalar_t__);
char *asctime(const struct tm *timeptr) {
  static char _timebuf[26 + (8 + 3 * 9 + 7)];
  sprintf(_timebuf, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
          "SunMonTueWedThuFriSat" + (timeptr->tm_wday) * 3,
          "JanFebMarAprMayJunJulAugSepOctNovDecBad" + (timeptr->tm_mon) * 3,
          timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec,
          timeptr->tm_year + 1900);
  return _timebuf;
}


x86 assembly (clang, -O0):
<asctime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
imul   $0x3,(%rax),%eax
cltq
lea    0xef4(%rip),%rdx
add    %rax,%rdx
mov    -0x8(%rbp),%rax
imul   $0x3,0x4(%rax),%eax
cltq
lea    0xef6(%rip),%rcx
add    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%r11d
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%r10d
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rax
add    $0x76c,%rax
lea    0x2ec8(%rip),%rdi
lea    0xe81(%rip),%rsi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1030 <sprintf@plt>
lea    0x2ea7(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asctime>:
push   %r14
push   %rbx
push   %rax
movslq (%rdi),%rax
lea    (%rax,%rax,2),%rax
lea    0xefe(%rip),%rdx
add    %rax,%rdx
movslq 0x4(%rdi),%rax
lea    (%rax,%rax,2),%rax
lea    0xf02(%rip),%rcx
add    %rax,%rcx
mov    0x8(%rdi),%r8d
mov    0xc(%rdi),%r9d
mov    0x10(%rdi),%r10d
mov    0x14(%rdi),%ebx
mov    $0x76c,%eax
add    0x18(%rdi),%rax
sub    $0x8,%rsp
lea    0x2ee6(%rip),%r14
lea    0xe9f(%rip),%rsi
mov    %r14,%rdi
push   %rax
push   %rbx
push   %r10
call   1030 <sprintf@plt>
add    $0x20,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i64 }
@asctime._timebuf = internal global [68 x i8] zeroinitializer
@.str = [32 x i8] c"%.3s %.3s%3d %.2d:%.2d:%.2d %d\0A\00"
@.str.1 = [22 x i8] c"SunMonTueWedThuFriSat\00"
@.str.2 = [40 x i8] c"JanFebMarAprMayJunJulAugSepOctNovDecBad\00"
define i8* @asctime(%struct.tm* %0) {
%2 = alloca %struct.tm*
store %struct.tm* %0, %struct.tm** %2
%3 = load %struct.tm*, %struct.tm** %2
%4 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
%5 = load i32, i32* %4
%6 = mul nsw i32 %5, 3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i64 %7
%9 = load %struct.tm*, %struct.tm** %2
%10 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 1
%11 = load i32, i32* %10
%12 = mul nsw i32 %11, 3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i64 %13
%15 = load %struct.tm*, %struct.tm** %2
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 2
%17 = load i32, i32* %16
%18 = load %struct.tm*, %struct.tm** %2
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 3
%20 = load i32, i32* %19
%21 = load %struct.tm*, %struct.tm** %2
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 4
%23 = load i32, i32* %22
%24 = load %struct.tm*, %struct.tm** %2
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 5
%26 = load i32, i32* %25
%27 = load %struct.tm*, %struct.tm** %2
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 6
%29 = load i64, i64* %28
%30 = add nsw i64 %29, 1900
%31 = call i32 @sprintf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @asctime._timebuf, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %14, i32 %17, i32 %20, i32 %23, i32 %26, i64 %30)
ret i8* getelementptr inbounds ([68 x i8], [68 x i8]* @asctime._timebuf, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i64 }
@asctime._timebuf = internal global [68 x i8] zeroinitializer
@.str = [32 x i8] c"%.3s %.3s%3d %.2d:%.2d:%.2d %d\0A\00"
@.str.1 = [22 x i8] c"SunMonTueWedThuFriSat\00"
@.str.2 = [40 x i8] c"JanFebMarAprMayJunJulAugSepOctNovDecBad\00"
define i8* @asctime(%struct.tm* nocapture %0) {
%2 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = mul nsw i32 %3, 3
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds [22 x i8], [22 x i8]* @.str.1, i64 0, i64 %5
%7 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 1
%8 = load i32, i32* %7
%9 = mul nsw i32 %8, 3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [40 x i8], [40 x i8]* @.str.2, i64 0, i64 %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 4
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 5
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 6
%21 = load i64, i64* %20
%22 = add nsw i64 %21, 1900
%23 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @asctime._timebuf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %11, i32 %13, i32 %15, i32 %17, i32 %19, i64 %22)
ret i8* getelementptr inbounds ([68 x i8], [68 x i8]* @asctime._timebuf, i64 0, i64 0)
}