#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 */

/* Variables and functions */
int /*<<< orphan*/ Timemark(short *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, char *);
char *Time2(char *buf) {
  short v[7], t = 0;
  Timemark(v);
  if (v[3] >= 12) {
    t = 1;
    if (v[3] > 12)
      v[3] -= 12;
  }
  sprintf(buf, "%2d:%2d %s", (int)v[3], (int)v[4], t ? "PM" : "AM");
  if (buf[3] == ' ')
    buf[3] = '0';
  return (buf);
}


x86 assembly (clang, -O0):
<Time2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movw   $0x0,-0x18(%rbp)
lea    -0x16(%rbp),%rdi
call   1030 <Timemark@plt>
movswl -0x10(%rbp),%eax
cmp    $0xc,%eax
jl     116b <Time2+0x4b>
movw   $0x1,-0x18(%rbp)
movswl -0x10(%rbp),%eax
cmp    $0xc,%eax
jle    1166 <Time2+0x46>
movswl -0x10(%rbp),%eax
sub    $0xc,%eax
mov    %ax,-0x10(%rbp)
jmp    116b <Time2+0x4b>
mov    -0x8(%rbp),%rdi
movswl -0x10(%rbp),%edx
movswl -0xe(%rbp),%ecx
movswl -0x18(%rbp),%esi
lea    0xe8c(%rip),%r8
lea    0xe82(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r8
lea    0xe69(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x20,%eax
jne    11b5 <Time2+0x95>
mov    -0x8(%rbp),%rax
movb   $0x30,0x3(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Time2>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x2(%rsp),%rdi
call   1030 <Timemark@plt>
movzwl 0x8(%rsp),%eax
cmp    $0xc,%ax
jl     114c <Time2+0x2c>
lea    0xec7(%rip),%r8
jne    1155 <Time2+0x35>
mov    $0xc,%ax
jmp    115d <Time2+0x3d>
lea    0xebb(%rip),%r8
jmp    115d <Time2+0x3d>
add    $0xfffffff4,%eax
mov    %ax,0x8(%rsp)
movswl %ax,%edx
movswl 0xa(%rsp),%ecx
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
cmpb   $0x20,0x3(%rbx)
jne    117e <Time2+0x5e>
movb   $0x30,0x3(%rbx)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%2d:%2d %s\00"
@.str.1 = [3 x i8] c"PM\00"
@.str.2 = [3 x i8] c"AM\00"
define i8* @Time2(i8* %0) {
%2 = alloca i8*
%3 = alloca [7 x i16]
%4 = alloca i16
store i8* %0, i8** %2
store i16 0, i16* %4
%5 = getelementptr inbounds [7 x i16], [7 x i16]* %3, i64 0, i64 0
%6 = call i32 @Timemark(i16* %5)
%7 = getelementptr inbounds [7 x i16], [7 x i16]* %3, i64 0, i64 3
%8 = load i16, i16* %7
%9 = sext i16 %8 to i32
%10 = icmp sge i32 %9, 12
br i1 %10, label %11, label %23
11: ; preds = %1
store i16 1, i16* %4
%12 = getelementptr inbounds [7 x i16], [7 x i16]* %3, i64 0, i64 3
%13 = load i16, i16* %12
%14 = sext i16 %13 to i32
%15 = icmp sgt i32 %14, 12
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = getelementptr inbounds [7 x i16], [7 x i16]* %3, i64 0, i64 3
%18 = load i16, i16* %17
%19 = sext i16 %18 to i32
%20 = sub nsw i32 %19, 12
%21 = trunc i32 %20 to i16
store i16 %21, i16* %17
br label %22
22: ; preds = %16, %11
br label %23
23: ; preds = %22, %1
%24 = load i8*, i8** %2
%25 = getelementptr inbounds [7 x i16], [7 x i16]* %3, i64 0, i64 3
%26 = load i16, i16* %25
%27 = sext i16 %26 to i32
%28 = getelementptr inbounds [7 x i16], [7 x i16]* %3, i64 0, i64 4
%29 = load i16, i16* %28
%30 = sext i16 %29 to i32
%31 = load i16, i16* %4
%32 = sext i16 %31 to i32
%33 = icmp ne i32 %32, 0
%34 = zext i1 %33 to i64
%35 = select i1 %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%36 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %30, i8* %35)
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i64 3
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 32
br i1 %41, label %42, label %45
42: ; preds = %23
%43 = load i8*, i8** %2
%44 = getelementptr inbounds i8, i8* %43, i64 3
store i8 48, i8* %44
br label %45
45: ; preds = %42, %23
%46 = load i8*, i8** %2
ret i8* %46
}

LLVM IR (-O2):
@.str = [11 x i8] c"%2d:%2d %s\00"
@.str.1 = [3 x i8] c"PM\00"
@.str.2 = [3 x i8] c"AM\00"
define i8* @Time2(i8* returned %0) {
%2 = alloca [7 x i16]
%3 = bitcast [7 x i16]* %2 to i8*
%4 = getelementptr inbounds [7 x i16], [7 x i16]* %2, i64 0, i64 0
%5 = call i32 @Timemark(i16* %4)
%6 = getelementptr inbounds [7 x i16], [7 x i16]* %2, i64 0, i64 3
%7 = load i16, i16* %6
%8 = icmp sgt i16 %7, 11
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = icmp eq i16 %7, 12
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = add nsw i16 %7, -12
store i16 %12, i16* %6
br label %13
13: ; preds = %9, %11, %1
%14 = phi i16 [ 12, %9 ], [ %12, %11 ], [ %7, %1 ]
%15 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %11 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %1 ]
%16 = sext i16 %14 to i32
%17 = getelementptr inbounds [7 x i16], [7 x i16]* %2, i64 0, i64 4
%18 = load i16, i16* %17
%19 = sext i16 %18 to i32
%20 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %19, i8* %15)
%21 = getelementptr inbounds i8, i8* %0, i64 3
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 32
br i1 %23, label %24, label %25
24: ; preds = %13
store i8 48, i8* %21
br label %25
25: ; preds = %24, %13
ret i8* %0
}