#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 *, unsigned long, unsigned long);
char *time_string(unsigned long seconds) {
  static char buffer[10];
  unsigned long minutes;
  minutes = seconds / 60;
  seconds %= 60;
  if (minutes > 99)
    return "99:59+";
  sprintf(buffer, "%2lu:%02lu ", minutes, seconds);
  return buffer;
}


x86 assembly (clang, -O0):
<time_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x10(%rbp)
cmpq   $0x63,-0x18(%rbp)
jbe    115b <time_string+0x4b>
lea    0xeae(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1181 <time_string+0x71>
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0x2ebf(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2eac(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_string>:
push   %rbx
cmp    $0x176f,%rdi
jbe    1123 <time_string+0x13>
lea    0xedf(%rip),%rbx
jmp    114d <time_string+0x3d>
movzwl %di,%eax
imul   $0x8889,%eax,%edx
shr    $0x15,%edx
imul   $0x3c,%edx,%eax
sub    %eax,%edi
movzwl %di,%ecx
lea    0x2eeb(%rip),%rbx
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@time_string.buffer = internal global [10 x i8] zeroinitializer
@.str = [7 x i8] c"99:59+\00"
@.str.1 = [12 x i8] c"%2lu:%02lu \00"
define i8* @time_string(i64 %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = udiv i64 %5, 60
store i64 %6, i64* %4
%7 = load i64, i64* %3
%8 = urem i64 %7, 60
store i64 %8, i64* %3
%9 = load i64, i64* %4
%10 = icmp ugt i64 %9, 99
br i1 %10, label %11, label %12
11: ; preds = %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2
br label %16
12: ; preds = %1
%13 = load i64, i64* %4
%14 = load i64, i64* %3
%15 = call i32 @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @time_string.buffer, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 %13, i64 %14)
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @time_string.buffer, i64 0, i64 0), i8** %2
br label %16
16: ; preds = %12, %11
%17 = load i8*, i8** %2
ret i8* %17
}

LLVM IR (-O2):
@time_string.buffer = internal global [10 x i8] zeroinitializer
@.str = [7 x i8] c"99:59+\00"
@.str.1 = [12 x i8] c"%2lu:%02lu \00"
define i8* @time_string(i64 %0) {
%2 = icmp ugt i64 %0, 5999
br i1 %2, label %10, label %3
3: ; preds = %1
%4 = trunc i64 %0 to i16
%5 = udiv i16 %4, 60
%6 = zext i16 %5 to i64
%7 = urem i16 %4, 60
%8 = zext i16 %7 to i64
%9 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @time_string.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 %6, i64 %8)
br label %10
10: ; preds = %1, %3
%11 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @time_string.buffer, i64 0, i64 0), %3 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %11
}