#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 /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void convert_time(char *mmss, int time_ms) {
  int mins, secs;
  char smins[3];
  char ssecs[3];
  secs = time_ms / 1000;
  mins = secs / 60;
  if (mins > 59) {
    mins = 59;
    secs = 59;
  } else if (mins > 0) {
    secs = secs % (mins * 60);
  }
  sprintf(smins, "%02d", mins);
  sprintf(ssecs, "%02d", secs);
  strcpy(mmss, smins);
  strcat(mmss, ":");
  strcat(mmss, ssecs);
}


x86 assembly (clang, -O0):
<convert_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x3b,-0x10(%rbp)
jle    1178 <convert_time+0x48>
movl   $0x3b,-0x10(%rbp)
movl   $0x3b,-0x14(%rbp)
jmp    1194 <convert_time+0x64>
cmpl   $0x0,-0x10(%rbp)
jle    118f <convert_time+0x5f>
mov    -0x14(%rbp),%eax
imul   $0x3c,-0x10(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
jmp    1194 <convert_time+0x64>
lea    -0x17(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe5e(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x1a(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe4b(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x17(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1a(%rbp),%rsi
call   1040 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_time>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    $0x3b,%ecx
mov    $0x3b,%ebx
cmp    $0x36ee7f,%esi
jg     118f <convert_time+0x5f>
movslq %esi,%rax
imul   $0x10624dd3,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rbx
add    %ecx,%ebx
imul   $0x45e7b273,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x2e,%rcx
add    %eax,%ecx
cmp    $0xea60,%esi
jl     118f <convert_time+0x5f>
imul   $0x3c,%ecx,%esi
mov    %ebx,%eax
cltd
idiv   %esi
mov    %edx,%ebx
lea    0xe6a(%rip),%r15
lea    0xd(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ecx,%edx
call   1050 <sprintf@plt>
lea    0xa(%rsp),%r13
mov    %r13,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1050 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
lea    0xe39(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <strcat@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%02d\00"
@.str.1 = [2 x i8] c":\00"
define void @convert_time(i8* %0, i32 %1) {
%3 = alloca [3 x i8]
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%7 = sdiv i32 %1, 1000
%8 = sdiv i32 %1, 60000
%9 = icmp sgt i32 %1, 3599999
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = icmp sgt i32 %1, 59999
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = mul nsw i32 %8, 60
%14 = srem i32 %7, %13
br label %15
15: ; preds = %2, %10, %12
%16 = phi i32 [ %8, %12 ], [ %8, %10 ], [ 59, %2 ]
%17 = phi i32 [ %14, %12 ], [ %7, %10 ], [ 59, %2 ]
%18 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %16)
%19 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %17)
%20 = call i32 @strcpy(i8* %0, i8* %5)
%21 = call i32 @strcat(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @strcat(i8* %0, i8* %6)
ret void
}