#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 *, int);
void seconds_to_clock(int seconds) {
  int hours = seconds / 3600;
  seconds -= hours * 3600;
  int minutes = seconds / 60;
  seconds -= minutes * 60;
  printf(hours < 10 ? "0%d:" : "%d:", hours);
  printf(minutes < 10 ? "0%d:" : "%d:", minutes);
  printf(seconds < 10 ? "0%d\n" : "%d\n", seconds);
}


x86 assembly (clang, -O0):
<seconds_to_clock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
imul   $0xe10,-0x8(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
imul   $0x3c,-0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%ecx
lea    0xea5(%rip),%rdi
lea    0xe9d(%rip),%rax
cmp    $0xa,%ecx
cmovl  %rax,%rdi
mov    -0x8(%rbp),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
lea    0xe85(%rip),%rdi
lea    0xe7d(%rip),%rax
cmp    $0xa,%ecx
cmovl  %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
lea    0xe6a(%rip),%rdi
lea    0xe62(%rip),%rax
cmp    $0xa,%ecx
cmovl  %rax,%rdi
mov    -0x4(%rbp),%esi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seconds_to_clock>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
movslq %edi,%rax
imul   $0xffffffff91a2b3c5,%rax,%rsi
shr    $0x20,%rsi
add    %eax,%esi
mov    %esi,%ecx
shr    $0x1f,%ecx
sar    $0xb,%esi
add    %ecx,%esi
imul   $0xfffff1f0,%esi,%ecx
add    %eax,%ecx
movslq %ecx,%r15
imul   $0xffffffff88888889,%r15,%rbx
shr    $0x20,%rbx
add    %r15d,%ebx
mov    %ebx,%ecx
shr    $0x1f,%ecx
sar    $0x5,%ebx
add    %ecx,%ebx
imul   $0xffffffc4,%ebx,%r14d
add    %r15d,%r14d
cmp    $0x8ca0,%eax
lea    0xe98(%rip),%r12
lea    0xe92(%rip),%rbp
mov    %rbp,%rdi
cmovl  %r12,%rdi
call   1030 <printf@plt>
cmp    $0x258,%r15d
cmovl  %r12,%rbp
mov    %rbp,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
cmp    $0xa,%r14d
lea    0xe6a(%rip),%rax
lea    0xe64(%rip),%rdi
cmovl  %rax,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"0%d:\00"
@.str.1 = [4 x i8] c"%d:\00"
@.str.2 = [5 x i8] c"0%d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define void @seconds_to_clock(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sdiv i32 %5, 3600
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = mul nsw i32 %7, 3600
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, %8
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = sdiv i32 %11, 60
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = mul nsw i32 %13, 60
%15 = load i32, i32* %2
%16 = sub nsw i32 %15, %14
store i32 %16, i32* %2
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 10
%19 = zext i1 %18 to i64
%20 = select i1 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%21 = load i32, i32* %3
%22 = call i32 @printf(i8* %20, i32 %21)
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 10
%25 = zext i1 %24 to i64
%26 = select i1 %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%27 = load i32, i32* %4
%28 = call i32 @printf(i8* %26, i32 %27)
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 10
%31 = zext i1 %30 to i64
%32 = select i1 %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%33 = load i32, i32* %2
%34 = call i32 @printf(i8* %32, i32 %33)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"0%d:\00"
@.str.1 = [4 x i8] c"%d:\00"
@.str.2 = [5 x i8] c"0%d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define void @seconds_to_clock(i32 %0) {
%2 = sdiv i32 %0, 3600
%3 = mul nsw i32 %2, -3600
%4 = add i32 %3, %0
%5 = sdiv i32 %4, 60
%6 = mul nsw i32 %5, -60
%7 = add i32 %6, %4
%8 = icmp slt i32 %0, 36000
%9 = select i1 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%10 = tail call i32 @printf(i8* %9, i32 %2)
%11 = icmp slt i32 %4, 600
%12 = select i1 %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%13 = tail call i32 @printf(i8* %12, i32 %5)
%14 = icmp slt i32 %7, 10
%15 = select i1 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%16 = tail call i32 @printf(i8* %15, i32 %7)
ret void
}