#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 /*<<< orphan*/ strcpy(char *, char *);
char *SC68time_str(char *buffer, int track_num, int seconds) {
  static char tmp[12] = "-- --:--";
  if (!buffer) {
    buffer = tmp;
  }
  if (track_num < 0) {
    track_num = 0;
  } else if (track_num > 99) {
    track_num = 99;
  }
  if (!track_num) {
    buffer[0] = buffer[1] = '-';
  } else {
    buffer[0] = '0' + track_num / 10;
    buffer[1] = '0' + track_num % 10;
  }
  buffer[2] = ' ';
  if (seconds < 0) {
    seconds = -1;
  } else if (seconds > 99 * 60 + 59) {
    seconds = 99 * 60 + 59;
  }
  if (seconds < 0) {
    strcpy(buffer + 3, "--:--");
  } else {
    sprintf(buffer + 3, "%02u:%02u", seconds / 60, seconds % 60);
  }
  buffer[8] = 0;
  return buffer;
}


x86 assembly (clang, -O0):
<SC68time_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1148 <SC68time_str+0x28>
lea    0x2eec(%rip),%rax
mov    %rax,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    115e <SC68time_str+0x3e>
movl   $0x0,-0xc(%rbp)
jmp    1174 <SC68time_str+0x54>
cmpl   $0x63,-0xc(%rbp)
jle    116f <SC68time_str+0x4f>
movl   $0x63,-0xc(%rbp)
jmp    1174 <SC68time_str+0x54>
cmpl   $0x0,-0xc(%rbp)
jne    1192 <SC68time_str+0x72>
mov    -0x8(%rbp),%rax
movb   $0x2d,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x2d,(%rax)
jmp    11bf <SC68time_str+0x9f>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%rax
movb   $0x20,0x2(%rax)
cmpl   $0x0,-0x10(%rbp)
jge    11dd <SC68time_str+0xbd>
movl   $0xffffffff,-0x10(%rbp)
jmp    11f6 <SC68time_str+0xd6>
cmpl   $0x176f,-0x10(%rbp)
jle    11f1 <SC68time_str+0xd1>
movl   $0x176f,-0x10(%rbp)
jmp    11f6 <SC68time_str+0xd6>
cmpl   $0x0,-0x10(%rbp)
jge    1219 <SC68time_str+0xf9>
mov    -0x8(%rbp),%rdi
add    $0x3,%rdi
lea    0xdf1(%rip),%rsi
call   1030 <strcpy@plt>
jmp    124b <SC68time_str+0x12b>
mov    -0x8(%rbp),%rdi
add    $0x3,%rdi
mov    -0x10(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x14(%rbp),%edx
lea    0xdc0(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x8(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SC68time_str>:
push   %rbx
test   %rdi,%rdi
lea    0x2f05(%rip),%rbx
cmovne %rdi,%rbx
cmp    $0x63,%esi
mov    $0x63,%eax
cmovl  %esi,%eax
test   %esi,%esi
jle    1162 <SC68time_str+0x42>
test   %eax,%eax
je     1162 <SC68time_str+0x42>
movzbl %al,%eax
imul   $0xcd,%eax,%ecx
shr    $0xb,%ecx
lea    0x30(%rcx),%esi
mov    %sil,(%rbx)
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
or     $0x30,%al
mov    %al,0x1(%rbx)
jmp    1167 <SC68time_str+0x47>
movw   $0x2d2d,(%rbx)
movb   $0x20,0x2(%rbx)
cmp    $0x176f,%edx
mov    $0x176f,%ecx
cmovl  %edx,%ecx
test   %ecx,%ecx
mov    $0xffffffff,%eax
cmovns %ecx,%eax
lea    0x3(%rbx),%rdi
test   %eax,%eax
js     11ad <SC68time_str+0x8d>
movzwl %ax,%ecx
imul   $0x8889,%ecx,%edx
shr    $0x15,%edx
imul   $0x3c,%edx,%ecx
sub    %ecx,%eax
movzwl %ax,%ecx
lea    0xe60(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11b9 <SC68time_str+0x99>
lea    0xe4c(%rip),%rsi
call   1030 <strcpy@plt>
movb   $0x0,0x8(%rbx)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@SC68time_str.tmp = internal global [12 x i8] c"-- --:--\00\00\00\00"
@.str = [6 x i8] c"--:--\00"
@.str.1 = [10 x i8] c"%02u:%02u\00"
define i8* @SC68time_str(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %3
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @SC68time_str.tmp, i64 0, i64 0), i8** %4
br label %10
10: ; preds = %9, %3
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 0, i32* %5
br label %19
14: ; preds = %10
%15 = load i32, i32* %5
%16 = icmp sgt i32 %15, 99
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 99, i32* %5
br label %18
18: ; preds = %17, %14
br label %19
19: ; preds = %18, %13
%20 = load i32, i32* %5
%21 = icmp ne i32 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %19
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8 45, i8* %24
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 0
store i8 45, i8* %26
br label %40
27: ; preds = %19
%28 = load i32, i32* %5
%29 = sdiv i32 %28, 10
%30 = add nsw i32 48, %29
%31 = trunc i32 %30 to i8
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 0
store i8 %31, i8* %33
%34 = load i32, i32* %5
%35 = srem i32 %34, 10
%36 = add nsw i32 48, %35
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 1
store i8 %37, i8* %39
br label %40
40: ; preds = %27, %22
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i64 2
store i8 32, i8* %42
%43 = load i32, i32* %6
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %40
store i32 -1, i32* %6
br label %51
46: ; preds = %40
%47 = load i32, i32* %6
%48 = icmp sgt i32 %47, 5999
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 5999, i32* %6
br label %50
50: ; preds = %49, %46
br label %51
51: ; preds = %50, %45
%52 = load i32, i32* %6
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i64 3
%57 = call i32 @strcpy(i8* %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %66
58: ; preds = %51
%59 = load i8*, i8** %4
%60 = getelementptr inbounds i8, i8* %59, i64 3
%61 = load i32, i32* %6
%62 = sdiv i32 %61, 60
%63 = load i32, i32* %6
%64 = srem i32 %63, 60
%65 = call i32 @sprintf(i8* %60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %62, i32 %64)
br label %66
66: ; preds = %58, %54
%67 = load i8*, i8** %4
%68 = getelementptr inbounds i8, i8* %67, i64 8
store i8 0, i8* %68
%69 = load i8*, i8** %4
ret i8* %69
}

LLVM IR (-O2):
@SC68time_str.tmp = internal global [12 x i8] c"-- --:--\00\00\00\00"
@.str = [6 x i8] c"--:--\00"
@.str.1 = [10 x i8] c"%02u:%02u\00"
define i8* @SC68time_str(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i8* %0, null
%5 = select i1 %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @SC68time_str.tmp, i64 0, i64 0), i8* %0
%6 = icmp slt i32 %1, 99
%7 = select i1 %6, i32 %1, i32 99
%8 = icmp slt i32 %1, 1
%9 = icmp eq i32 %7, 0
%10 = or i1 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = getelementptr inbounds i8, i8* %5, i64 1
store i8 45, i8* %12
store i8 45, i8* %5
br label %20
13: ; preds = %3
%14 = trunc i32 %7 to i8
%15 = udiv i8 %14, 10
%16 = add nuw nsw i8 %15, 48
store i8 %16, i8* %5
%17 = urem i8 %14, 10
%18 = or i8 %17, 48
%19 = getelementptr inbounds i8, i8* %5, i64 1
store i8 %18, i8* %19
br label %20
20: ; preds = %13, %11
%21 = getelementptr inbounds i8, i8* %5, i64 2
store i8 32, i8* %21
%22 = icmp slt i32 %2, 5999
%23 = select i1 %22, i32 %2, i32 5999
%24 = icmp sgt i32 %23, -1
%25 = select i1 %24, i32 %23, i32 -1
%26 = icmp slt i32 %25, 0
%27 = getelementptr inbounds i8, i8* %5, i64 3
br i1 %26, label %28, label %30
28: ; preds = %20
%29 = tail call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %37
30: ; preds = %20
%31 = trunc i32 %25 to i16
%32 = udiv i16 %31, 60
%33 = zext i16 %32 to i32
%34 = urem i16 %31, 60
%35 = zext i16 %34 to i32
%36 = tail call i32 @sprintf(i8* %27, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %35)
br label %37
37: ; preds = %30, %28
%38 = getelementptr inbounds i8, i8* %5, i64 8
store i8 0, i8* %38
ret i8* %5
}