#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_hour;
  int tm_mon;
  int tm_mday;
  int tm_year;
  int tm_min;
};
typedef int /*<<< orphan*/ date_time;

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int, int, int, int, char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  time_t current = time(NULL);
  struct tm *ptr;
  char date_time[21];
  int hour;
  char am_or_pm;
  puts(ctime(&current));
  strftime(date_time, sizeof(date_time), "%m-%d-%Y  %I:%M%p\n",
           localtime(&current));
  puts(date_time);
  ptr = localtime(&current);
  hour = ptr->tm_hour;
  if (hour <= 11)
    am_or_pm = 'a';
  else {
    hour -= 12;
    am_or_pm = 'p';
  }
  if (hour == 0)
    hour = 12;
  printf("%.2d-%.2d-%d  %2d:%.2d%c\n", ptr->tm_mon + 1, ptr->tm_mday,
         ptr->tm_year + 1900, hour, ptr->tm_min, am_or_pm);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
call   1050 <ctime@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rcx
mov    $0x15,%esi
lea    0xe50(%rip),%rdx
call   1080 <strftime@plt>
lea    -0x30(%rbp),%rdi
call   1040 <puts@plt>
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0xb,-0x34(%rbp)
jg     11e7 <main+0x87>
movb   $0x61,-0x35(%rbp)
jmp    11f4 <main+0x94>
mov    -0x34(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x34(%rbp)
movb   $0x70,-0x35(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    1205 <main+0xa5>
movl   $0xc,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
add    $0x76c,%ecx
mov    -0x34(%rbp),%r8d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r9d
lea    0xddd(%rip),%rdi
movsbl -0x35(%rbp),%eax
mov    %eax,(%rsp)
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1050 <ctime@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <localtime@plt>
lea    0xe6a(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x15,%esi
mov    %rax,%rcx
call   1080 <strftime@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1030 <localtime@plt>
mov    (%rax),%ecx
mov    0x4(%rax),%esi
lea    -0xc(%rcx),%edi
cmp    $0xc,%ecx
cmovl  %ecx,%edi
mov    $0x61,%ecx
mov    $0x70,%ebx
cmovl  %ecx,%ebx
test   %edi,%edi
mov    0x8(%rax),%edx
mov    0x10(%rax),%r9d
mov    $0xc,%r8d
cmovne %edi,%r8d
add    $0x1,%esi
mov    $0x76c,%ecx
add    0xc(%rax),%ecx
mov    %ebx,(%rsp)
lea    0xe15(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [19 x i8] c"%m-%d-%Y %I:%M%p\0A\00"
@.str.1 = [26 x i8] c"%.2d-%.2d-%d %2d:%.2d%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca [21 x i8]
%5 = alloca i32
%6 = alloca i8
store i32 0, i32* %1
%7 = call i32 @time(i32* null)
store i32 %7, i32* %2
%8 = call i8* @ctime(i32* %2)
%9 = call i32 @puts(i8* %8)
%10 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%11 = call %struct.tm* @localtime(i32* %2)
%12 = call i32 @strftime(i8* %10, i32 21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %11)
%13 = getelementptr inbounds [21 x i8], [21 x i8]* %4, i64 0, i64 0
%14 = call i32 @puts(i8* %13)
%15 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %15, %struct.tm** %3
%16 = load %struct.tm*, %struct.tm** %3
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
%18 = load i32, i32* %17
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp sle i32 %19, 11
br i1 %20, label %21, label %22
21: ; preds = %0
store i8 97, i8* %6
br label %25
22: ; preds = %0
%23 = load i32, i32* %5
%24 = sub nsw i32 %23, 12
store i32 %24, i32* %5
store i8 112, i8* %6
br label %25
25: ; preds = %22, %21
%26 = load i32, i32* %5
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 12, i32* %5
br label %29
29: ; preds = %28, %25
%30 = load %struct.tm*, %struct.tm** %3
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 1
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
%34 = load %struct.tm*, %struct.tm** %3
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 2
%36 = load i32, i32* %35
%37 = load %struct.tm*, %struct.tm** %3
%38 = getelementptr inbounds %struct.tm, %struct.tm* %37, i32 0, i32 3
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1900
%41 = load i32, i32* %5
%42 = load %struct.tm*, %struct.tm** %3
%43 = getelementptr inbounds %struct.tm, %struct.tm* %42, i32 0, i32 4
%44 = load i32, i32* %43
%45 = load i8, i8* %6
%46 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %36, i32 %40, i32 %41, i32 %44, i8 signext %45)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32 }
@.str = [19 x i8] c"%m-%d-%Y %I:%M%p\0A\00"
@.str.1 = [26 x i8] c"%.2d-%.2d-%d %2d:%.2d%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [21 x i8]
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %1
%5 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%6 = call i8* @ctime(i32* %1)
%7 = call i32 @puts(i8* dereferenceable(1) %6)
%8 = call %struct.tm* @localtime(i32* %1)
%9 = call i32 @strftime(i8* %5, i32 21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%10 = call i32 @puts(i8* %5)
%11 = call %struct.tm* @localtime(i32* %1)
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i64 0, i32 0
%13 = load i32, i32* %12
%14 = icmp slt i32 %13, 12
%15 = add nsw i32 %13, -12
%16 = select i1 %14, i32 %13, i32 %15
%17 = select i1 %14, i8 97, i8 112
%18 = icmp eq i32 %16, 0
%19 = select i1 %18, i32 12, i32 %16
%20 = getelementptr inbounds %struct.tm, %struct.tm* %11, i64 0, i32 1
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
%23 = getelementptr inbounds %struct.tm, %struct.tm* %11, i64 0, i32 2
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.tm, %struct.tm* %11, i64 0, i32 3
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1900
%28 = getelementptr inbounds %struct.tm, %struct.tm* %11, i64 0, i32 4
%29 = load i32, i32* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %24, i32 %27, i32 %19, i32 %29, i8 signext %17)
ret i32 0
}