#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*/ Com_sprintf(char *, int, char *, int, ...);
void UI_PrintTime(char *buf, int bufsize, int time) {
  time /= 1000;
  if (time > 3600) {
    Com_sprintf(buf, bufsize, "%d hr %d min", time / 3600, (time % 3600) / 60);
  } else if (time > 60) {
    Com_sprintf(buf, bufsize, "%d min %d sec", time / 60, time % 60);
  } else {
    Com_sprintf(buf, bufsize, "%d sec", time);
  }
}


x86 assembly (clang, -O0):
<UI_PrintTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0xe10,-0x10(%rbp)
jle    1180 <UI_PrintTime+0x70>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
mov    $0xe10,%r8d
cltd
idiv   %r8d
mov    %edx,%eax
mov    $0x3c,%r8d
cltd
idiv   %r8d
mov    %eax,%r8d
lea    0xe8c(%rip),%rdx
mov    $0x0,%al
call   1030 <Com_sprintf@plt>
jmp    11de <UI_PrintTime+0xce>
cmpl   $0x3c,-0x10(%rbp)
jle    11c1 <UI_PrintTime+0xb1>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
mov    $0x3c,%r8d
cltd
idiv   %r8d
mov    %edx,%r8d
lea    0xe58(%rip),%rdx
mov    $0x0,%al
call   1030 <Com_sprintf@plt>
jmp    11d9 <UI_PrintTime+0xc9>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%ecx
lea    0xe42(%rip),%rdx
mov    $0x0,%al
call   1030 <Com_sprintf@plt>
jmp    11de <UI_PrintTime+0xce>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UI_PrintTime>:
movslq %edx,%rax
imul   $0x10624dd3,%rax,%r8
mov    %r8,%rcx
shr    $0x3f,%rcx
sar    $0x26,%r8
add    %ecx,%r8d
cmp    $0x36f268,%eax
jl     1192 <UI_PrintTime+0x82>
mov    %edx,%eax
mov    $0x95217cb1,%ecx
imul   %rax,%rcx
shr    $0x35,%rcx
movslq %r8d,%rax
imul   $0xffffffff91a2b3c5,%rax,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0xb,%eax
add    %edx,%eax
imul   $0xe10,%eax,%eax
sub    %eax,%r8d
movswl %r8w,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %r8d,%eax
movzwl %ax,%eax
movswl %ax,%edx
shr    $0xf,%eax
sar    $0x5,%edx
add    %eax,%edx
movswl %dx,%r8d
lea    0xe75(%rip),%rdx
xor    %eax,%eax
jmp    1030 <Com_sprintf@plt>
cmp    $0xee48,%edx
jl     11d6 <UI_PrintTime+0xc6>
mov    %edx,%eax
imul   $0x45e7b273,%rax,%rcx
shr    $0x2e,%rcx
movslq %r8d,%rax
imul   $0xffffffff88888889,%rax,%rax
shr    $0x20,%rax
add    %r8d,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x5,%eax
add    %edx,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%r8d
lea    0xe3e(%rip),%rdx
xor    %eax,%eax
jmp    1030 <Com_sprintf@plt>
lea    0xe37(%rip),%rdx
mov    %r8d,%ecx
xor    %eax,%eax
jmp    1030 <Com_sprintf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"%d hr %d min\00"
@.str.1 = [14 x i8] c"%d min %d sec\00"
@.str.2 = [7 x i8] c"%d sec\00"
define void @UI_PrintTime(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 i32, i32* %6
%8 = sdiv i32 %7, 1000
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp sgt i32 %9, 3600
br i1 %10, label %11, label %20
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = sdiv i32 %14, 3600
%16 = load i32, i32* %6
%17 = srem i32 %16, 3600
%18 = sdiv i32 %17, 60
%19 = call i32 (i8*, i32, i8*, i32, ...) @Com_sprintf(i8* %12, i32 %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %18)
br label %37
20: ; preds = %3
%21 = load i32, i32* %6
%22 = icmp sgt i32 %21, 60
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = load i8*, i8** %4
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = sdiv i32 %26, 60
%28 = load i32, i32* %6
%29 = srem i32 %28, 60
%30 = call i32 (i8*, i32, i8*, i32, ...) @Com_sprintf(i8* %24, i32 %25, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %29)
br label %36
31: ; preds = %20
%32 = load i8*, i8** %4
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = call i32 (i8*, i32, i8*, i32, ...) @Com_sprintf(i8* %32, i32 %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %31, %23
br label %37
37: ; preds = %36, %11
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%d hr %d min\00"
@.str.1 = [14 x i8] c"%d min %d sec\00"
@.str.2 = [7 x i8] c"%d sec\00"
define void @UI_PrintTime(i8* %0, i32 %1, i32 %2) {
%4 = sdiv i32 %2, 1000
%5 = icmp sgt i32 %2, 3600999
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = udiv i32 %2, 3600000
%8 = srem i32 %4, 3600
%9 = trunc i32 %8 to i16
%10 = sdiv i16 %9, 60
%11 = sext i16 %10 to i32
%12 = tail call i32 (i8*, i32, i8*, i32, ...) @Com_sprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %11)
br label %21
13: ; preds = %3
%14 = icmp sgt i32 %2, 60999
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = udiv i32 %2, 60000
%17 = srem i32 %4, 60
%18 = tail call i32 (i8*, i32, i8*, i32, ...) @Com_sprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
br label %21
19: ; preds = %13
%20 = tail call i32 (i8*, i32, i8*, i32, ...) @Com_sprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %4)
br label %21
21: ; preds = %15, %19, %6
ret void
}