#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_min;
  int tm_sec;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int, int, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void ttime_2(void) {
  struct tm *t;
  time_t now;
  time(&now);
  t = localtime(&now);
  if (t->tm_hour >= 12) {
    printf("It is now %d:%02d:%02d %s", t->tm_hour - 12, t->tm_min, t->tm_sec,
           "PM");
  } else {
    printf("It is now %d:%02d:%02d %s", t->tm_hour, t->tm_min, t->tm_sec, "AM");
  }
}


x86 assembly (clang, -O0):
<ttime_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0xc(%rbp),%rdi
call   1050 <time@plt>
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0xc,(%rax)
jl     118a <ttime_2+0x5a>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
sub    $0xc,%esi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xe87(%rip),%rdi
lea    0xe9a(%rip),%r8
call   1040 <printf@plt>
jmp    11b1 <ttime_2+0x81>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xe5b(%rip),%rdi
lea    0xe71(%rip),%r8
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ttime_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),%esi
cmp    $0xc,%esi
jl     116a <ttime_2+0x3a>
add    $0xfffffff4,%esi
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
lea    0xe9f(%rip),%rdi
lea    0xeb2(%rip),%r8
jmp    117e <ttime_2+0x4e>
mov    0x4(%rax),%edx
mov    0x8(%rax),%ecx
lea    0xe89(%rip),%rdi
lea    0xe9f(%rip),%r8
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
@.str = [26 x i8] c"It is now %d:%02d:%02d %s\00"
@.str.1 = [3 x i8] c"PM\00"
@.str.2 = [3 x i8] c"AM\00"
define void @ttime_2() {
%1 = alloca %struct.tm*
%2 = alloca i32
%3 = call i32 @time(i32* %2)
%4 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %4, %struct.tm** %1
%5 = load %struct.tm*, %struct.tm** %1
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
%7 = load i32, i32* %6
%8 = icmp sge i32 %7, 12
br i1 %8, label %9, label %21
9: ; preds = %0
%10 = load %struct.tm*, %struct.tm** %1
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = sub nsw i32 %12, 12
%14 = load %struct.tm*, %struct.tm** %1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 1
%16 = load i32, i32* %15
%17 = load %struct.tm*, %struct.tm** %1
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 2
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %16, i32 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %32
21: ; preds = %0
%22 = load %struct.tm*, %struct.tm** %1
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = load %struct.tm*, %struct.tm** %1
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = load %struct.tm*, %struct.tm** %1
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 2
%30 = load i32, i32* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %27, i32 %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %21, %9
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
@.str = [26 x i8] c"It is now %d:%02d:%02d %s\00"
@.str.1 = [3 x i8] c"PM\00"
@.str.2 = [3 x i8] c"AM\00"
define void @ttime_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 i32, i32* %5
%7 = icmp sgt i32 %6, 11
br i1 %7, label %8, label %15
8: ; preds = %0
%9 = add nsw i32 %6, -12
%10 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%13 = load i32, i32* %12
%14 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11, i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %21
15: ; preds = %0
%16 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %17, i32 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %15, %8
ret void
}