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

/* Variables and functions */
int /*<<< orphan*/ getchar();
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  struct tm *t;
  time_t now;
  now = time(NULL);
  t = localtime(&now);
  char *zile[] = {"Luni",   "Marti",   "Miercuri", "Joi",
                  "Vineri", "Sambata", "Duminica"};
  char *luni[] = {"Ian", "Feb", "Martie", "Apr"};
  printf("Astazi este %s, %d %s %d.\n", zile[t->tm_wday - 1], t->tm_mday,
         luni[t->tm_mon], t->tm_year + 1900);
  if (t->tm_hour > 12) {
    printf("Iar ceasul este %02d:%02d:%02d PM.\n", t->tm_hour - 12, t->tm_min,
           t->tm_sec);
  } else {
    printf("Iar ceasul este %d:%02d:%02d AM.\n", t->tm_hour, t->tm_min,
           t->tm_sec);
  }
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2c3d(%rip),%rsi
mov    $0x38,%edx
call   1060 <memcpy@plt>
mov    0x2c6c(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0x2c69(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0x2c66(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c63(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sub    $0x1,%eax
cltq
mov    -0x50(%rbp,%rax,8),%rsi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x70(%rbp,%rax,8),%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r8d
add    $0x76c,%r8d
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
cmpl   $0xc,0x14(%rax)
jle    1233 <main+0xe3>
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%esi
sub    $0xc,%esi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x1c(%rax),%ecx
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1256 <main+0x106>
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x1c(%rax),%ecx
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
movslq (%rax),%rax
lea    0xf3d(%rip),%rcx
movslq -0x4(%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    0x4(%rbx),%edx
mov    0x8(%rbx),%rax
lea    0xf43(%rip),%rdi
movslq (%rdi,%rax,4),%rcx
add    %rdi,%rcx
mov    $0x76c,%r8d
add    0x10(%rbx),%r8d
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rbx),%esi
cmp    $0xd,%esi
jl     11b6 <main+0x76>
add    $0xfffffff4,%esi
mov    0x18(%rbx),%edx
mov    0x1c(%rbx),%ecx
lea    0xeaa(%rip),%rdi
jmp    11c3 <main+0x83>
mov    0x18(%rbx),%edx
mov    0x1c(%rbx),%ecx
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i64, i32, i32, i32, i32 }
@.str = [5 x i8] c"Luni\00"
@.str.1 = [6 x i8] c"Marti\00"
@.str.2 = [9 x i8] c"Miercuri\00"
@.str.3 = [4 x i8] c"Joi\00"
@.str.4 = [7 x i8] c"Vineri\00"
@.str.5 = [8 x i8] c"Sambata\00"
@.str.6 = [9 x i8] c"Duminica\00"
@__const.main.zile = [7 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 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 = [4 x i8] c"Ian\00"
@.str.8 = [4 x i8] c"Feb\00"
@.str.9 = [7 x i8] c"Martie\00"
@.str.10 = [4 x i8] c"Apr\00"
@__const.main.luni = [4 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i32 0, i32 0)]
@.str.11 = [27 x i8] c"Astazi este %s, %d %s %d.\0A\00"
@.str.12 = [36 x i8] c"Iar ceasul este %02d:%02d:%02d PM.\0A\00"
@.str.13 = [34 x i8] c"Iar ceasul este %d:%02d:%02d AM.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = alloca i32
%4 = alloca [7 x i8*]
%5 = alloca [4 x i8*]
store i32 0, i32* %1
%6 = call i32 @time(i32* null)
store i32 %6, i32* %3
%7 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %7, %struct.tm** %2
%8 = bitcast [7 x i8*]* %4 to i8*
%9 = bitcast [4 x i8*]* %5 to i8*
%10 = load %struct.tm*, %struct.tm** %2
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [7 x i8*], [7 x i8*]* %4, i64 0, i64 %14
%16 = load i8*, i8** %15
%17 = load %struct.tm*, %struct.tm** %2
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 1
%19 = load i32, i32* %18
%20 = load %struct.tm*, %struct.tm** %2
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 2
%22 = load i64, i64* %21
%23 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = load %struct.tm*, %struct.tm** %2
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 3
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1900
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i8* %16, i32 %19, i8* %24, i32 %28)
%30 = load %struct.tm*, %struct.tm** %2
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 4
%32 = load i32, i32* %31
%33 = icmp sgt i32 %32, 12
br i1 %33, label %34, label %46
34: ; preds = %0
%35 = load %struct.tm*, %struct.tm** %2
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 4
%37 = load i32, i32* %36
%38 = sub nsw i32 %37, 12
%39 = load %struct.tm*, %struct.tm** %2
%40 = getelementptr inbounds %struct.tm, %struct.tm* %39, i32 0, i32 5
%41 = load i32, i32* %40
%42 = load %struct.tm*, %struct.tm** %2
%43 = getelementptr inbounds %struct.tm, %struct.tm* %42, i32 0, i32 6
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i32 %38, i32 %41, i32 %44)
br label %57
46: ; preds = %0
%47 = load %struct.tm*, %struct.tm** %2
%48 = getelementptr inbounds %struct.tm, %struct.tm* %47, i32 0, i32 4
%49 = load i32, i32* %48
%50 = load %struct.tm*, %struct.tm** %2
%51 = getelementptr inbounds %struct.tm, %struct.tm* %50, i32 0, i32 5
%52 = load i32, i32* %51
%53 = load %struct.tm*, %struct.tm** %2
%54 = getelementptr inbounds %struct.tm, %struct.tm* %53, i32 0, i32 6
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 %49, i32 %52, i32 %55)
br label %57
57: ; preds = %46, %34
%58 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i64, i32, i32, i32, i32 }
@.str = [5 x i8] c"Luni\00"
@.str.1 = [6 x i8] c"Marti\00"
@.str.2 = [9 x i8] c"Miercuri\00"
@.str.3 = [4 x i8] c"Joi\00"
@.str.4 = [7 x i8] c"Vineri\00"
@.str.5 = [8 x i8] c"Sambata\00"
@.str.6 = [9 x i8] c"Duminica\00"
@reltable.main = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 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 = [4 x i8] c"Ian\00"
@.str.8 = [4 x i8] c"Feb\00"
@.str.9 = [7 x i8] c"Martie\00"
@.str.10 = [4 x i8] c"Apr\00"
@reltable.main.14 = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([4 x i32]* @reltable.main.14 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.8 to i64), i64 ptrtoint ([4 x i32]* @reltable.main.14 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.9 to i64), i64 ptrtoint ([4 x i32]* @reltable.main.14 to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.10 to i64), i64 ptrtoint ([4 x i32]* @reltable.main.14 to i64)) to i32)]
@.str.11 = [27 x i8] c"Astazi este %s, %d %s %d.\0A\00"
@.str.12 = [36 x i8] c"Iar ceasul este %02d:%02d:%02d PM.\0A\00"
@.str.13 = [34 x i8] c"Iar ceasul este %d:%02d:%02d AM.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call %struct.tm* @localtime(i32* %1)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%6 = load i32, i32* %5
%7 = add nsw i32 %6, -1
%8 = sext i32 %7 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.main to i8*), i64 %9)
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%14 = load i64, i64* %13
%15 = shl i64 %14, 2
%16 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.main.14 to i8*), i64 %15)
%17 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1900
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i8* %10, i32 %12, i8* %16, i32 %19)
%21 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%22 = load i32, i32* %21
%23 = icmp sgt i32 %22, 12
br i1 %23, label %24, label %31
24: ; preds = %0
%25 = add nsw i32 %22, -12
%26 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 6
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i32 %25, i32 %27, i32 %29)
br label %37
31: ; preds = %0
%32 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 6
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 %22, i32 %33, i32 %35)
br label %37
37: ; preds = %31, %24
%38 = call i32 (...) @getchar()
ret i32 0
}