#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, ...);
int PutSecs(int Sec, char *Buf) {
  int H, M, S;
  char *Where;
  M = Sec / 60;
  S = Sec % 60;
  H = M / 60;
  M = M % 60;
  Where = Buf;
  if (H)
    Where += sprintf(Where, "%02d:", H);
  Where += sprintf(Where, "%02d:%02d", M, S);
  return Where - Buf;
}


x86 assembly (clang, -O0):
<PutSecs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     118e <PutSecs+0x7e>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PutSecs>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
lea    0xe0f(%rdi),%eax
movslq %edi,%rbx
mov    %rsi,%r15
cmp    $0x1c1f,%eax
jb     115a <PutSecs+0x4a>
imul   $0xffffffff91a2b3c5,%rbx,%rax
shr    $0x20,%rax
lea    (%rbx,%rax,1),%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0xb,%edx
add    %eax,%edx
lea    0xeb6(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
movslq %eax,%r15
add    %r14,%r15
imul   $0xffffffff88888889,%rbx,%rax
shr    $0x20,%rax
add    %ebx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
movslq %eax,%rdx
imul   $0xffffffff88888889,%rdx,%rax
shr    $0x20,%rax
add    %edx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x5,%eax
add    %ecx,%eax
imul   $0x3c,%eax,%eax
imul   $0x3c,%edx,%ecx
sub    %eax,%edx
sub    %ecx,%ebx
lea    0xe6a(%rip),%rsi
mov    %r15,%rdi
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <sprintf@plt>
add    %r15d,%eax
sub    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%02d:\00"
@.str.1 = [10 x i8] c"%02d:%02d\00"
define i32 @PutSecs(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = load i32, i32* %3
%10 = sdiv i32 %9, 60
store i32 %10, i32* %6
%11 = load i32, i32* %3
%12 = srem i32 %11, 60
store i32 %12, i32* %7
%13 = load i32, i32* %6
%14 = sdiv i32 %13, 60
store i32 %14, i32* %5
%15 = load i32, i32* %6
%16 = srem i32 %15, 60
store i32 %16, i32* %6
%17 = load i8*, i8** %4
store i8* %17, i8** %8
%18 = load i32, i32* %5
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %2
%21 = load i8*, i8** %8
%22 = load i32, i32* %5
%23 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i8*, i8** %8
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds i8, i8* %24, i64 %25
store i8* %26, i8** %8
br label %27
27: ; preds = %20, %2
%28 = load i8*, i8** %8
%29 = load i32, i32* %6
%30 = load i32, i32* %7
%31 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %30)
%32 = load i8*, i8** %8
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds i8, i8* %32, i64 %33
store i8* %34, i8** %8
%35 = load i8*, i8** %8
%36 = load i8*, i8** %4
%37 = ptrtoint i8* %35 to i64
%38 = ptrtoint i8* %36 to i64
%39 = sub i64 %37, %38
%40 = trunc i64 %39 to i32
ret i32 %40
}

LLVM IR (-O2):
@.str = [6 x i8] c"%02d:\00"
@.str.1 = [10 x i8] c"%02d:%02d\00"
define i32 @PutSecs(i32 %0, i8* %1) {
%3 = add i32 %0, 3599
%4 = icmp ult i32 %3, 7199
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = sdiv i32 %0, 3600
%7 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %1, i64 %8
br label %10
10: ; preds = %5, %2
%11 = phi i8* [ %9, %5 ], [ %1, %2 ]
%12 = sdiv i32 %0, 60
%13 = srem i32 %12, 60
%14 = srem i32 %0, 60
%15 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %14)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %11, i64 %16
%18 = ptrtoint i8* %17 to i64
%19 = ptrtoint i8* %1 to i64
%20 = sub i64 %18, %19
%21 = trunc i64 %20 to i32
ret i32 %21
}