#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) {
  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)
cmpl   $0xe10,-0x10(%rbp)
jle    1172 <UI_PrintTime+0x62>
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    0xe9a(%rip),%rdx
mov    $0x0,%al
call   1030 <Com_sprintf@plt>
jmp    11d0 <UI_PrintTime+0xc0>
cmpl   $0x3c,-0x10(%rbp)
jle    11b3 <UI_PrintTime+0xa3>
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    0xe66(%rip),%rdx
mov    $0x0,%al
call   1030 <Com_sprintf@plt>
jmp    11cb <UI_PrintTime+0xbb>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%ecx
lea    0xe50(%rip),%rdx
mov    $0x0,%al
call   1030 <Com_sprintf@plt>
jmp    11d0 <UI_PrintTime+0xc0>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UI_PrintTime>:
mov    %edx,%eax
cmp    $0xe11,%edx
jl     114a <UI_PrintTime+0x3a>
mov    %eax,%edx
mov    $0x91a2b3c5,%ecx
imul   %rdx,%rcx
shr    $0x2b,%rcx
imul   $0xe10,%ecx,%edx
sub    %edx,%eax
imul   $0x8889,%eax,%r8d
shr    $0x15,%r8d
lea    0xebd(%rip),%rdx
xor    %eax,%eax
jmp    1030 <Com_sprintf@plt>
cmp    $0x3d,%eax
jl     1172 <UI_PrintTime+0x62>
movzwl %ax,%ecx
imul   $0x8889,%ecx,%ecx
shr    $0x15,%ecx
imul   $0x3c,%ecx,%edx
sub    %edx,%eax
movzwl %ax,%r8d
lea    0xea2(%rip),%rdx
xor    %eax,%eax
jmp    1030 <Com_sprintf@plt>
lea    0xe9b(%rip),%rdx
mov    %eax,%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 = icmp sgt i32 %7, 3600
br i1 %8, label %9, label %18
9: ; preds = %3
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = sdiv i32 %12, 3600
%14 = load i32, i32* %6
%15 = srem i32 %14, 3600
%16 = sdiv i32 %15, 60
%17 = call i32 (i8*, i32, i8*, i32, ...) @Com_sprintf(i8* %10, i32 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %16)
br label %35
18: ; preds = %3
%19 = load i32, i32* %6
%20 = icmp sgt i32 %19, 60
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i8*, i8** %4
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = sdiv i32 %24, 60
%26 = load i32, i32* %6
%27 = srem i32 %26, 60
%28 = call i32 (i8*, i32, i8*, i32, ...) @Com_sprintf(i8* %22, i32 %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %27)
br label %34
29: ; preds = %18
%30 = load i8*, i8** %4
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = call i32 (i8*, i32, i8*, i32, ...) @Com_sprintf(i8* %30, i32 %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %29, %21
br label %35
35: ; preds = %34, %9
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 = icmp sgt i32 %2, 3600
br i1 %4, label %5, label %12
5: ; preds = %3
%6 = udiv i32 %2, 3600
%7 = urem i32 %2, 3600
%8 = trunc i32 %7 to i16
%9 = udiv i16 %8, 60
%10 = zext i16 %9 to i32
%11 = 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 %6, i32 %10)
br label %23
12: ; preds = %3
%13 = icmp sgt i32 %2, 60
br i1 %13, label %14, label %21
14: ; preds = %12
%15 = trunc i32 %2 to i16
%16 = udiv i16 %15, 60
%17 = zext i16 %16 to i32
%18 = urem i16 %15, 60
%19 = zext i16 %18 to i32
%20 = 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 %17, i32 %19)
br label %23
21: ; preds = %12
%22 = 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 %2)
br label %23
23: ; preds = %14, %21, %5
ret void
}