#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*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
void secondsToString(long unsigned int seconds, char *target) {
  long unsigned int hours = seconds / 3600;
  seconds -= hours * 3600;
  long unsigned int minutes = seconds / 60;
  seconds -= minutes * 60;
  strcpy(target, "");
  if (hours > 0)
    sprintf(target, "%02lu:", hours);
  sprintf(target, "%s%02lu:%02lu", target, minutes, seconds);
}


x86 assembly (clang, -O0):
<secondsToString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    $0xe10,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x18(%rbp)
imul   $0xe10,-0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x20(%rbp)
imul   $0x3c,-0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1030 <strcpy@plt>
cmpq   $0x0,-0x18(%rbp)
jbe    11a8 <secondsToString+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%r8
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<secondsToString>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r13
mov    %rdi,%rax
shr    $0x4,%rax
movabs $0x91a2b3c4d5e6f81,%rcx
2b 1a 09
mul    %rcx
mov    %rdx,%r12
mov    %rsi,%r14
shr    $0x3,%r12
imul   $0xfffffffffffff1f0,%r12,%rbx
add    %rdi,%rbx
movabs $0x8888888888888889,%rcx
88 88 88
mov    %rbx,%rax
mul    %rcx
mov    %rdx,%r15
shr    $0x5,%r15
lea    0xe94(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
cmp    $0xe10,%r13
jb     1197 <secondsToString+0x77>
lea    0xe76(%rip),%rsi
mov    %r14,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <sprintf@plt>
imul   $0xffffffffffffffc4,%r15,%r8
add    %rbx,%r8
lea    0xe62(%rip),%rsi
mov    %r14,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"%02lu:\00"
@.str.2 = [14 x i8] c"%s%02lu:%02lu\00"
define void @secondsToString(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %3
store i8* %1, i8** %4
%7 = load i64, i64* %3
%8 = udiv i64 %7, 3600
store i64 %8, i64* %5
%9 = load i64, i64* %5
%10 = mul i64 %9, 3600
%11 = load i64, i64* %3
%12 = sub i64 %11, %10
store i64 %12, i64* %3
%13 = load i64, i64* %3
%14 = udiv i64 %13, 60
store i64 %14, i64* %6
%15 = load i64, i64* %6
%16 = mul i64 %15, 60
%17 = load i64, i64* %3
%18 = sub i64 %17, %16
store i64 %18, i64* %3
%19 = load i8*, i8** %4
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%21 = load i64, i64* %5
%22 = icmp ugt i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %2
%24 = load i8*, i8** %4
%25 = load i64, i64* %5
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %25)
br label %27
27: ; preds = %23, %2
%28 = load i8*, i8** %4
%29 = load i8*, i8** %4
%30 = load i64, i64* %6
%31 = load i64, i64* %3
%32 = call i32 (i8*, i8*, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %29, i64 %30, i64 %31)
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [7 x i8] c"%02lu:\00"
@.str.2 = [14 x i8] c"%s%02lu:%02lu\00"
define void @secondsToString(i64 %0, i8* %1) {
%3 = udiv i64 %0, 3600
%4 = mul i64 %3, -3600
%5 = add i64 %4, %0
%6 = udiv i64 %5, 60
%7 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp ult i64 %0, 3600
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %3)
br label %11
11: ; preds = %9, %2
%12 = mul i64 %6, -60
%13 = add i64 %12, %5
%14 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %1, i64 %6, i64 %13)
ret void
}