#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*/ sprintf(char *, char *, int, int, int, int, char *);
char *Tmfmt(long t, char *s) {
  int h = (t / 10000000L);
  char *p;
  if (h < 12) {
    if (!h)
      h += 12;
    p = "am";
  } else {
    if (h > 12)
      h -= 12;
    p = "pm";
  }
  sprintf(s, "%d:%02d:%02d.%03d%s", h, (int)((t / 100000L) % 100L),
          (int)((t / 1000L) % 100L), (int)(t % 1000), p);
  return s;
}


x86 assembly (clang, -O0):
<Tmfmt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x989680,%ecx
cqto
idiv   %rcx
mov    %eax,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jge    115e <Tmfmt+0x4e>
cmpl   $0x0,-0x14(%rbp)
jne    114e <Tmfmt+0x3e>
mov    -0x14(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x14(%rbp)
lea    0xeab(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    117c <Tmfmt+0x6c>
cmpl   $0xc,-0x14(%rbp)
jle    1171 <Tmfmt+0x61>
mov    -0x14(%rbp),%eax
sub    $0xc,%eax
mov    %eax,-0x14(%rbp)
lea    0xe8b(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x186a0,%ecx
cqto
idiv   %rcx
mov    $0x64,%ecx
cqto
idiv   %rcx
mov    %edx,%ecx
mov    -0x8(%rbp),%rax
mov    $0x3e8,%esi
cqto
idiv   %rsi
mov    $0x64,%esi
cqto
idiv   %rsi
mov    %edx,%r8d
mov    -0x8(%rbp),%rax
mov    $0x3e8,%esi
cqto
idiv   %rsi
mov    %rdx,%rax
mov    -0x24(%rbp),%edx
mov    %eax,%r9d
mov    -0x20(%rbp),%rax
lea    0xe29(%rip),%rsi
mov    %rax,(%rsp)
call   1030 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Tmfmt>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r9
movabs $0xd6bf94d5e57a42bd,%rcx
94 bf d6
mov    %rdi,%rax
imul   %rcx
add    %rdi,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x17,%rdx
add    %eax,%edx
cmp    $0xb,%edx
jg     1152 <Tmfmt+0x42>
test   %edx,%edx
mov    $0xc,%ebx
cmovne %edx,%ebx
lea    0xeb0(%rip),%rsi
jmp    1162 <Tmfmt+0x52>
lea    -0xc(%rdx),%ebx
cmp    $0xc,%edx
cmove  %edx,%ebx
lea    0xea1(%rip),%rsi
movabs $0x29f16b11c6d1e109,%rcx
6b f1 29
mov    %r9,%rax
imul   %rcx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0xe,%rdx
add    %rdx,%rcx
movabs $0xa3d70a3d70a3d70b,%rdi
0a d7 a3
mov    %rcx,%rax
imul   %rdi
add    %rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x6,%rdx
add    %eax,%edx
imul   $0x64,%edx,%eax
sub    %eax,%ecx
movabs $0x20c49ba5e353f7cf,%rdx
9b c4 20
mov    %r9,%rax
imul   %rdx
mov    %rdx,%r8
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x7,%r8
add    %rax,%r8
mov    %r8,%rax
imul   %rdi
add    %r8,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x6,%rdx
add    %eax,%edx
imul   $0x64,%edx,%eax
imul   $0x3e8,%r8d,%edx
sub    %eax,%r8d
sub    %edx,%r9d
mov    %rsi,(%rsp)
lea    0xe0f(%rip),%rsi
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <sprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"am\00"
@.str.1 = [3 x i8] c"pm\00"
@.str.2 = [20 x i8] c"%d:%02d:%02d.%03d%s\00"
define i8* @Tmfmt(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i64 %0, i64* %3
store i8* %1, i8** %4
%7 = load i64, i64* %3
%8 = sdiv i64 %7, 10000000
%9 = trunc i64 %8 to i32
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 12
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 12
store i32 %17, i32* %5
br label %18
18: ; preds = %15, %12
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %6
br label %26
19: ; preds = %2
%20 = load i32, i32* %5
%21 = icmp sgt i32 %20, 12
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %5
%24 = sub nsw i32 %23, 12
store i32 %24, i32* %5
br label %25
25: ; preds = %22, %19
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %26
26: ; preds = %25, %18
%27 = load i8*, i8** %4
%28 = load i32, i32* %5
%29 = load i64, i64* %3
%30 = sdiv i64 %29, 100000
%31 = srem i64 %30, 100
%32 = trunc i64 %31 to i32
%33 = load i64, i64* %3
%34 = sdiv i64 %33, 1000
%35 = srem i64 %34, 100
%36 = trunc i64 %35 to i32
%37 = load i64, i64* %3
%38 = srem i64 %37, 1000
%39 = trunc i64 %38 to i32
%40 = load i8*, i8** %6
%41 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %28, i32 %32, i32 %36, i32 %39, i8* %40)
%42 = load i8*, i8** %4
ret i8* %42
}

LLVM IR (-O2):
@.str = [3 x i8] c"am\00"
@.str.1 = [3 x i8] c"pm\00"
@.str.2 = [20 x i8] c"%d:%02d:%02d.%03d%s\00"
define i8* @Tmfmt(i64 %0, i8* returned writeonly %1) {
%3 = sdiv i64 %0, 10000000
%4 = trunc i64 %3 to i32
%5 = icmp slt i32 %4, 12
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = icmp eq i32 %4, 0
%8 = select i1 %7, i32 12, i32 %4
br label %13
9: ; preds = %2
%10 = icmp eq i32 %4, 12
%11 = add nsw i32 %4, -12
%12 = select i1 %10, i32 12, i32 %11
br label %13
13: ; preds = %9, %6
%14 = phi i32 [ %8, %6 ], [ %12, %9 ]
%15 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %6 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %9 ]
%16 = sdiv i64 %0, 100000
%17 = srem i64 %16, 100
%18 = trunc i64 %17 to i32
%19 = sdiv i64 %0, 1000
%20 = srem i64 %19, 100
%21 = trunc i64 %20 to i32
%22 = srem i64 %0, 1000
%23 = trunc i64 %22 to i32
%24 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %18, i32 %21, i32 %23, i8* %15)
ret i8* %1
}