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

/* Variables and functions */
scalar_t__ ceilf(float);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int);
char *pts_to_string(unsigned long pts, float fps) {
  static char buf[256];
  int hours, minutes, seconds, fracsec;
  int frame;
  static const int MPEG_CLOCK_FREQ = 90000;
  seconds = pts / MPEG_CLOCK_FREQ;
  fracsec = pts % MPEG_CLOCK_FREQ;
  minutes = seconds / 60;
  seconds = seconds % 60;
  hours = minutes / 60;
  minutes = minutes % 60;
  frame = (int)ceilf(((float)fracsec / (float)MPEG_CLOCK_FREQ) * fps);
  snprintf(buf, sizeof(buf), "%d:%02d:%02d:%d", hours, minutes, seconds, frame);
  return buf;
}


x86 assembly (clang, -O0):
<pts_to_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x15f90,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x15f90,%ecx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cvtsi2ssl -0x1c(%rbp),%xmm0
movss  0xe66(%rip),%xmm1
divss  %xmm1,%xmm0
mulss  -0xc(%rbp),%xmm0
call   1040 <ceilf@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x20(%rbp),%eax
lea    0x2e80(%rip),%rdi
mov    $0x100,%esi
lea    0xe3c(%rip),%rdx
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
lea    0x2e65(%rip),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pts_to_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movabs $0xba69dbdd3ac13d7d,%rcx
db 69 ba
mov    %rdi,%rax
mul    %rcx
shr    $0x10,%rdx
imul   $0x15f90,%edx,%eax
sub    %eax,%edi
movslq %edx,%r14
imul   $0xffffffff88888889,%r14,%rax
shr    $0x20,%rax
add    %r14d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x3c,%eax,%ecx
imul   $0xffffffff91a2b3c5,%r14,%rbx
shr    $0x20,%rbx
add    %r14d,%ebx
sub    %ecx,%r14d
mov    %ebx,%ecx
shr    $0x1f,%ecx
sar    $0xb,%ebx
add    %ecx,%ebx
movslq %eax,%r15
imul   $0xffffffff88888889,%r15,%rax
shr    $0x20,%rax
add    %r15d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x3c,%eax,%eax
cvtsi2ss %edi,%xmm1
sub    %eax,%r15d
divss  0xe56(%rip),%xmm1
mulss  %xmm1,%xmm0
call   1040 <ceilf@plt>
mov    %eax,(%rsp)
lea    0x2e83(%rip),%r12
lea    0xe40(%rip),%rdx
mov    %r12,%rdi
mov    $0x100,%esi
mov    %ebx,%ecx
mov    %r15d,%r8d
mov    %r14d,%r9d
call   1030 <snprintf@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@pts_to_string.buf = internal global [256 x i8] zeroinitializer
@pts_to_string.MPEG_CLOCK_FREQ = internal constant i32 90000
@.str = [16 x i8] c"%d:%02d:%02d:%d\00"
define i8* @pts_to_string(i64 %0, float %1) {
%3 = alloca i64
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i64 %0, i64* %3
store float %1, float* %4
%10 = load i64, i64* %3
%11 = udiv i64 %10, 90000
%12 = trunc i64 %11 to i32
store i32 %12, i32* %7
%13 = load i64, i64* %3
%14 = urem i64 %13, 90000
%15 = trunc i64 %14 to i32
store i32 %15, i32* %8
%16 = load i32, i32* %7
%17 = sdiv i32 %16, 60
store i32 %17, i32* %6
%18 = load i32, i32* %7
%19 = srem i32 %18, 60
store i32 %19, i32* %7
%20 = load i32, i32* %6
%21 = sdiv i32 %20, 60
store i32 %21, i32* %5
%22 = load i32, i32* %6
%23 = srem i32 %22, 60
store i32 %23, i32* %6
%24 = load i32, i32* %8
%25 = sitofp i32 %24 to float
%26 = fdiv float %25, 9.000000e+04
%27 = load float, float* %4
%28 = fmul float %26, %27
%29 = call i64 @ceilf(float %28)
%30 = trunc i64 %29 to i32
store i32 %30, i32* %9
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = load i32, i32* %9
%35 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pts_to_string.buf, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %31, i32 %32, i32 %33, i32 %34)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pts_to_string.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@pts_to_string.buf = internal global [256 x i8] zeroinitializer
@.str = [16 x i8] c"%d:%02d:%02d:%d\00"
define i8* @pts_to_string(i64 %0, float %1) {
%3 = udiv i64 %0, 90000
%4 = trunc i64 %3 to i32
%5 = urem i64 %0, 90000
%6 = trunc i64 %5 to i32
%7 = sdiv i32 %4, 60
%8 = srem i32 %4, 60
%9 = sdiv i32 %4, 3600
%10 = srem i32 %7, 60
%11 = sitofp i32 %6 to float
%12 = fdiv float %11, 9.000000e+04
%13 = fmul float %12, %1
%14 = tail call i64 @ceilf(float %13)
%15 = trunc i64 %14 to i32
%16 = tail call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pts_to_string.buf, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10, i32 %8, i32 %15)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pts_to_string.buf, i64 0, i64 0)
}