#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*/ printf(char *, unsigned long, ...);
void print_time(unsigned long millis) {
  unsigned long seconds;
  unsigned long minutes;
  unsigned long hours;
  if (millis < 1000) {
    printf("%lu milliseconds\n", millis);
    return;
  }
  seconds = millis / 1000;
  if (seconds < 60) {
    printf("%lu seconds\n", seconds);
    return;
  }
  minutes = seconds / 60;
  seconds %= 60;
  if (minutes < 60) {
    printf("%lu minutes, %lu seconds\n", minutes, seconds);
    return;
  }
  hours = minutes / 60;
  minutes %= 60;
  printf("%lu hours, %lu minutes\n", hours, minutes);
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x3e8,-0x8(%rbp)
jae    1141 <print_time+0x31>
mov    -0x8(%rbp),%rsi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f9 <print_time+0xe9>
mov    -0x8(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x10(%rbp)
cmpq   $0x3c,-0x10(%rbp)
jae    1175 <print_time+0x65>
mov    -0x10(%rbp),%rsi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f9 <print_time+0xe9>
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   $0x3c,-0x18(%rbp)
jae    11bf <print_time+0xaf>
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f9 <print_time+0xe9>
mov    -0x18(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x18(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
mov    %rdi,%rsi
cmp    $0x3e7,%rdi
ja     112a <print_time+0x1a>
lea    0xedd(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
mov    %rsi,%rax
shr    $0x3,%rax
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mul    %rcx
mov    %rdx,%rcx
shr    $0x4,%rcx
cmp    $0xea5f,%rsi
ja     115f <print_time+0x4f>
lea    0xeca(%rip),%rdi
mov    %rcx,%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>
mov    %rsi,%rax
shr    $0x5,%rax
movabs $0x45e7b272f608771,%rdx
7b 5e 04
mul    %rdx
mov    %rdx,%r8
shr    $0x5,%r8
cmp    $0x36ee7f,%rsi
ja     11b2 <print_time+0xa2>
movabs $0x8888888888888889,%rdx
88 88 88
mov    %rcx,%rax
mul    %rdx
shr    $0x5,%rdx
imul   $0x3c,%rdx,%rax
sub    %rax,%rcx
lea    0xe6d(%rip),%rdi
mov    %r8,%rsi
mov    %rcx,%rdx
xor    %eax,%eax
jmp    1030 <printf@plt>
movabs $0x4a90be587de6e565,%rcx
be 90 4a
mov    %rsi,%rax
mul    %rcx
mov    %rdx,%rsi
shr    $0x14,%rsi
movabs $0x8888888888888889,%rcx
88 88 88
mov    %r8,%rax
mul    %rcx
shr    $0x5,%rdx
imul   $0x3c,%rdx,%rax
sub    %rax,%r8
lea    0xe41(%rip),%rdi
mov    %r8,%rdx
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"%lu milliseconds\0A\00"
@.str.1 = [13 x i8] c"%lu seconds\0A\00"
@.str.2 = [26 x i8] c"%lu minutes, %lu seconds\0A\00"
@.str.3 = [24 x i8] c"%lu hours, %lu minutes\0A\00"
define void @print_time(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = icmp ult i64 %6, 1000
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i64, i64* %2
%10 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %9)
br label %38
11: ; preds = %1
%12 = load i64, i64* %2
%13 = udiv i64 %12, 1000
store i64 %13, i64* %3
%14 = load i64, i64* %3
%15 = icmp ult i64 %14, 60
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i64, i64* %3
%18 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %17)
br label %38
19: ; preds = %11
%20 = load i64, i64* %3
%21 = udiv i64 %20, 60
store i64 %21, i64* %4
%22 = load i64, i64* %3
%23 = urem i64 %22, 60
store i64 %23, i64* %3
%24 = load i64, i64* %4
%25 = icmp ult i64 %24, 60
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = load i64, i64* %4
%28 = load i64, i64* %3
%29 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 %27, i64 %28)
br label %38
30: ; preds = %19
%31 = load i64, i64* %4
%32 = udiv i64 %31, 60
store i64 %32, i64* %5
%33 = load i64, i64* %4
%34 = urem i64 %33, 60
store i64 %34, i64* %4
%35 = load i64, i64* %5
%36 = load i64, i64* %4
%37 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 %35, i64 %36)
br label %38
38: ; preds = %30, %26, %16, %8
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"%lu milliseconds\0A\00"
@.str.1 = [13 x i8] c"%lu seconds\0A\00"
@.str.2 = [26 x i8] c"%lu minutes, %lu seconds\0A\00"
@.str.3 = [24 x i8] c"%lu hours, %lu minutes\0A\00"
define void @print_time(i64 %0) {
%2 = icmp ult i64 %0, 1000
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i64 %0)
br label %20
5: ; preds = %1
%6 = udiv i64 %0, 1000
%7 = icmp ult i64 %0, 60000
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %6)
br label %20
10: ; preds = %5
%11 = udiv i64 %0, 60000
%12 = icmp ult i64 %0, 3600000
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = urem i64 %6, 60
%15 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 %11, i64 %14)
br label %20
16: ; preds = %10
%17 = udiv i64 %0, 3600000
%18 = urem i64 %11, 60
%19 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 %17, i64 %18)
br label %20
20: ; preds = %16, %13, %8, %3
ret void
}