#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 /*<<< orphan*/ strcpy(char *, char *);
int fr2tc(char *tc, long fr) {
  int m;
  int s;
  int f;
  if (fr > 449999 || fr < 0) {
    strcpy(tc, "00:00:00");
    return -1;
  }
  f = fr % 75;
  fr -= f;
  s = (fr / 75) % 60;
  fr -= s * 75;
  m = fr / 75 / 60;
  sprintf(tc, "%02d:%02d:%02d", m, s, f);
  return 0;
}


x86 assembly (clang, -O0):
<fr2tc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x6ddcf,-0x18(%rbp)
jg     1149 <fr2tc+0x29>
cmpq   $0x0,-0x18(%rbp)
jge    1165 <fr2tc+0x45>
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f2 <fr2tc+0xd2>
mov    -0x18(%rbp),%rax
mov    $0x4b,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x4b,%ecx
cqto
idiv   %rcx
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
mov    %eax,-0x20(%rbp)
imul   $0x4b,-0x20(%rbp),%eax
movslq %eax,%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x4b,%ecx
cqto
idiv   %rcx
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
lea    0xe23(%rip),%rsi
call   1040 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fr2tc>:
push   %rax
cmp    $0x6ddd0,%rsi
jb     113d <fr2tc+0x1d>
lea    0xecf(%rip),%rsi
call   1030 <strcpy@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret
mov    %esi,%eax
imul   $0x1b4e81b5,%rax,%rax
shr    $0x23,%rax
imul   $0x4b,%eax,%eax
mov    %esi,%r8d
sub    %eax,%r8d
sub    %r8,%rsi
movslq %esi,%rax
imul   $0x1b4e81b5,%rax,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rdx
add    %ecx,%edx
movzwl %dx,%ecx
imul   $0x8889,%ecx,%ecx
shr    $0x15,%ecx
imul   $0x3c,%ecx,%ecx
sub    %ecx,%edx
movzwl %dx,%ecx
imul   $0x4b,%edx,%edx
movzwl %dx,%edx
sub    %edx,%eax
cltq
imul   $0x7482296b,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2b,%rdx
add    %eax,%edx
lea    0xe63(%rip),%rsi
call   1040 <sprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"00:00:00\00"
@.str.1 = [15 x i8] c"%02d:%02d:%02d\00"
define i32 @fr2tc(i8* %0, i64 %1) {
%3 = icmp ugt i64 %1, 449999
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %22
6: ; preds = %2
%7 = trunc i64 %1 to i32
%8 = urem i32 %7, 75
%9 = zext i32 %8 to i64
%10 = sub nsw i64 %1, %9
%11 = trunc i64 %10 to i32
%12 = sdiv i32 %11, 75
%13 = trunc i32 %12 to i16
%14 = urem i16 %13, 60
%15 = zext i16 %14 to i32
%16 = mul nuw nsw i16 %14, 75
%17 = zext i16 %16 to i64
%18 = sub nsw i64 %10, %17
%19 = trunc i64 %18 to i32
%20 = sdiv i32 %19, 4500
%21 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %15, i32 %8)
br label %22
22: ; preds = %6, %4
%23 = phi i32 [ -1, %4 ], [ 0, %6 ]
ret i32 %23
}