#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  size_t tm_wday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  time_t tim;
  struct tm *p;
  char *week[] = {"Sunday",   "Monday", "Tuesday", "Wednesday",
                  "Thursday", "Friday", "Saturday"};
  time(&tim);
  p = gmtime(&tim);
  printf("%d/%d/%d\n", (1900 + p->tm_year), (1 + p->tm_mon), p->tm_mday);
  printf("%s\n", week[p->tm_wday]);
  printf("%d:%d:%d\n", p->tm_hour, p->tm_min, p->tm_sec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2c86(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
lea    -0x8(%rbp),%rdi
call   1050 <time@plt>
lea    -0x8(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
add    $0x76c,%esi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x50(%rbp,%rax,8),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x1c(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%ecx
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <time@plt>
mov    %rbx,%rdi
call   1060 <gmtime@plt>
mov    %rax,%rbx
mov    $0x76c,%esi
add    (%rax),%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
add    $0x1,%edx
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%rax
lea    0xeca(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1030 <puts@plt>
mov    0x18(%rbx),%esi
mov    0x1c(%rbx),%edx
mov    0x20(%rbx),%ecx
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i64, i32, i32, i32 }
@.str = [7 x i8] c"Sunday\00"
@.str.1 = [7 x i8] c"Monday\00"
@.str.2 = [8 x i8] c"Tuesday\00"
@.str.3 = [10 x i8] c"Wednesday\00"
@.str.4 = [9 x i8] c"Thursday\00"
@.str.5 = [7 x i8] c"Friday\00"
@.str.6 = [9 x i8] c"Saturday\00"
@__const.main.week = [7 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [10 x i8] c"%d/%d/%d\0A\00"
@.str.8 = [4 x i8] c"%s\0A\00"
@.str.9 = [10 x i8] c"%d:%d:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca [7 x i8*]
store i32 0, i32* %1
%5 = bitcast [7 x i8*]* %4 to i8*
%6 = call i32 @time(i32* %2)
%7 = call %struct.tm* @gmtime(i32* %2)
store %struct.tm* %7, %struct.tm** %3
%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 = add nsw i32 1900, %10
%12 = load %struct.tm*, %struct.tm** %3
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
%14 = load i32, i32* %13
%15 = add nsw i32 1, %14
%16 = load %struct.tm*, %struct.tm** %3
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 2
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %11, i32 %15, i32 %18)
%20 = load %struct.tm*, %struct.tm** %3
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 3
%22 = load i64, i64* %21
%23 = getelementptr inbounds [7 x i8*], [7 x i8*]* %4, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %24)
%26 = load %struct.tm*, %struct.tm** %3
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 4
%28 = load i32, i32* %27
%29 = load %struct.tm*, %struct.tm** %3
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 5
%31 = load i32, i32* %30
%32 = load %struct.tm*, %struct.tm** %3
%33 = getelementptr inbounds %struct.tm, %struct.tm* %32, i32 0, i32 6
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %28, i32 %31, i32 %34)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i64, i32, i32, i32 }
@.str = [7 x i8] c"Sunday\00"
@.str.1 = [7 x i8] c"Monday\00"
@.str.2 = [8 x i8] c"Tuesday\00"
@.str.3 = [10 x i8] c"Wednesday\00"
@.str.4 = [9 x i8] c"Thursday\00"
@.str.5 = [7 x i8] c"Friday\00"
@.str.6 = [9 x i8] c"Saturday\00"
@reltable.main = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32)]
@.str.7 = [10 x i8] c"%d/%d/%d\0A\00"
@.str.9 = [10 x i8] c"%d:%d:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @time(i32* %1)
%4 = call %struct.tm* @gmtime(i32* %1)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i32, i32* %5
%7 = add nsw i32 %6, 1900
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%9 = load i32, i32* %8
%10 = add nsw i32 %9, 1
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %7, i32 %10, i32 %12)
%14 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%15 = load i64, i64* %14
%16 = shl i64 %15, 2
%17 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.main to i8*), i64 %16)
%18 = call i32 @puts(i8* dereferenceable(1) %17)
%19 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 6
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %20, i32 %22, i32 %24)
ret i32 0
}