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

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


x86 assembly (clang, -O0):
<ddate_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x40(%rbp),%rdi
lea    0x2c8d(%rip),%rsi
mov    $0x38,%edx
call   1050 <memcpy@plt>
lea    -0x4c(%rbp),%rdi
call   1060 <time@plt>
lea    -0x4c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    -0x40(%rbp,%rax,8),%rsi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x48(%rbp),%rax
mov    0xc(%rax),%ecx
add    $0x1,%ecx
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%r8d
add    $0x76c,%r8d
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rax
cmpl   $0xc,0x14(%rax)
jl     11ed <ddate_2+0xad>
mov    -0x48(%rbp),%rax
mov    0x14(%rax),%esi
sub    $0xc,%esi
mov    -0x48(%rbp),%rax
mov    0x18(%rax),%edx
mov    -0x48(%rbp),%rax
mov    0x1c(%rax),%ecx
lea    0xe72(%rip),%rdi
lea    0xe8f(%rip),%r8
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1217 <ddate_2+0xd7>
mov    -0x48(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x18(%rax),%edx
mov    -0x48(%rbp),%rax
mov    0x1c(%rax),%ecx
lea    0xe43(%rip),%rdi
lea    0xe63(%rip),%r8
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ddate_2>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    (%rax),%rax
lea    0xf21(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    0x8(%rbx),%edx
mov    0xc(%rbx),%ecx
add    $0x1,%ecx
mov    $0x76c,%r8d
add    0x10(%rbx),%r8d
lea    0xeb8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rbx),%esi
cmp    $0xc,%esi
jl     11a0 <ddate_2+0x70>
add    $0xfffffff4,%esi
mov    0x18(%rbx),%edx
mov    0x1c(%rbx),%ecx
lea    0xeb5(%rip),%rdi
lea    0xed2(%rip),%r8
jmp    11b4 <ddate_2+0x84>
mov    0x18(%rbx),%edx
mov    0x1c(%rbx),%ecx
lea    0xe9f(%rip),%rdi
lea    0xebf(%rip),%r8
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

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