#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*/ print_format(unsigned long);
int /*<<< orphan*/ printf(char *);
void print_time(unsigned long sec) {
  const unsigned int SECONDS_IN_AN_HOUR = 3600;
  const unsigned int SECONDS_IN_A_MINUTE = 60;
  print_format((unsigned long)(sec / SECONDS_IN_AN_HOUR));
  printf(":");
  print_format(
      (unsigned long)((sec % SECONDS_IN_AN_HOUR) / SECONDS_IN_A_MINUTE));
  printf(":");
  print_format(
      (unsigned long)((sec % SECONDS_IN_AN_HOUR) % SECONDS_IN_A_MINUTE));
  printf("\n");
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xe10,-0xc(%rbp)
movl   $0x3c,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdi
call   1040 <print_format@plt>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdi
call   1040 <print_format@plt>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rdi
call   1040 <print_format@plt>
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rdi,%rax
shr    $0x4,%rax
movabs $0x91a2b3c4d5e6f81,%rcx
2b 1a 09
mul    %rcx
mov    %rdx,%rbx
shr    $0x3,%rbx
mov    %rbx,%rdi
call   1040 <print_format@plt>
mov    $0x3a,%edi
call   1030 <putchar@plt>
imul   $0xe10,%ebx,%eax
sub    %eax,%r14d
imul   $0x8889,%r14d,%ebx
shr    $0x15,%ebx
mov    %rbx,%rdi
call   1040 <print_format@plt>
mov    $0x3a,%edi
call   1030 <putchar@plt>
imul   $0x3c,%ebx,%eax
sub    %eax,%r14d
movzwl %r14w,%edi
call   1040 <print_format@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_time(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
store i64 %0, i64* %2
store i32 3600, i32* %3
store i32 60, i32* %4
%5 = load i64, i64* %2
%6 = udiv i64 %5, 3600
%7 = call i32 @print_format(i64 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = load i64, i64* %2
%10 = urem i64 %9, 3600
%11 = udiv i64 %10, 60
%12 = call i32 @print_format(i64 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = load i64, i64* %2
%15 = urem i64 %14, 3600
%16 = urem i64 %15, 60
%17 = call i32 @print_format(i64 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
define void @print_time(i64 %0) {
%2 = udiv i64 %0, 3600
%3 = tail call i32 @print_format(i64 %2)
%4 = tail call i32 @putchar(i32 58)
%5 = urem i64 %0, 3600
%6 = trunc i64 %5 to i16
%7 = udiv i16 %6, 60
%8 = zext i16 %7 to i64
%9 = tail call i32 @print_format(i64 %8)
%10 = tail call i32 @putchar(i32 58)
%11 = urem i16 %6, 60
%12 = zext i16 %11 to i64
%13 = tail call i32 @print_format(i64 %12)
%14 = tail call i32 @putchar(i32 10)
ret void
}