#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_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
  int /*<<< orphan*/ tm_mon;
  int /*<<< orphan*/ tm_wday;
  scalar_t__ tm_year;
};

/* Variables and functions */
char *day_to_string(int /*<<< orphan*/);
char *month_to_string(int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, int, int, int,
                            int, scalar_t__);
char *refos_print_time(struct tm *tm) {
  static char buf[47];
  snprintf(buf, 47, "%s, %s%3d %.2d:%.2d:%.2d %d\n", day_to_string(tm->tm_wday),
           month_to_string(tm->tm_mon), tm->tm_mday, tm->tm_hour, tm->tm_min,
           tm->tm_sec, 1900 + tm->tm_year);
  return buf;
}


x86 assembly (clang, -O0):
<refos_print_time>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x38,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%edi
call   1040 <day_to_string@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edi
call   1050 <month_to_string@plt>
mov    -0x18(%rbp),%rcx
mov    %rax,%r8
mov    -0x10(%rbp),%rax
mov    (%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ebx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r11d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
add    $0x76c,%rax
lea    0x2ebd(%rip),%rdi
mov    $0x2f,%esi
lea    0xe61(%rip),%rdx
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1030 <snprintf@plt>
lea    0x2e93(%rip),%rax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<refos_print_time>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x14(%rdi),%edi
call   1040 <day_to_string@plt>
mov    %rax,%r14
mov    0x10(%rbx),%edi
call   1050 <month_to_string@plt>
mov    (%rbx),%r9d
mov    0x4(%rbx),%r10d
mov    0x8(%rbx),%r11d
mov    0xc(%rbx),%r15d
mov    $0x76c,%r12d
add    0x18(%rbx),%r12
lea    0x2ee2(%rip),%rbx
lea    0xe8b(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2f,%esi
mov    %r14,%rcx
mov    %rax,%r8
push   %r12
push   %r15
push   %r11
push   %r10
call   1030 <snprintf@plt>
add    $0x20,%rsp
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i64 }
@refos_print_time.buf = internal global [47 x i8] zeroinitializer
@.str = [29 x i8] c"%s, %s%3d %.2d:%.2d:%.2d %d\0A\00"
define i8* @refos_print_time(%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 5
%5 = load i32, i32* %4
%6 = call i8* @day_to_string(i32 %5)
%7 = load %struct.tm*, %struct.tm** %2
%8 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 4
%9 = load i32, i32* %8
%10 = call i8* @month_to_string(i32 %9)
%11 = load %struct.tm*, %struct.tm** %2
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load %struct.tm*, %struct.tm** %2
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 1
%16 = load i32, i32* %15
%17 = load %struct.tm*, %struct.tm** %2
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 2
%19 = load i32, i32* %18
%20 = load %struct.tm*, %struct.tm** %2
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 3
%22 = load i32, i32* %21
%23 = load %struct.tm*, %struct.tm** %2
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 6
%25 = load i64, i64* %24
%26 = add nsw i64 1900, %25
%27 = call i32 @snprintf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @refos_print_time.buf, i64 0, i64 0), i32 47, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %10, i32 %13, i32 %16, i32 %19, i32 %22, i64 %26)
ret i8* getelementptr inbounds ([47 x i8], [47 x i8]* @refos_print_time.buf, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32, i64 }
@refos_print_time.buf = internal global [47 x i8] zeroinitializer
@.str = [29 x i8] c"%s, %s%3d %.2d:%.2d:%.2d %d\0A\00"
define i8* @refos_print_time(%struct.tm* nocapture %0) {
%2 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 5
%3 = load i32, i32* %2
%4 = tail call i8* @day_to_string(i32 %3)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 4
%6 = load i32, i32* %5
%7 = tail call i8* @month_to_string(i32 %6)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 0, i32 1
%11 = load i32, i32* %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 6
%17 = load i64, i64* %16
%18 = add nsw i64 %17, 1900
%19 = tail call i32 @snprintf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @refos_print_time.buf, i64 0, i64 0), i32 47, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %7, i32 %9, i32 %11, i32 %13, i32 %15, i64 %18)
ret i8* getelementptr inbounds ([47 x i8], [47 x i8]* @refos_print_time.buf, i64 0, i64 0)
}