#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 *, char, int, int);
char *seconds2hhmm(int seconds) {
  char sign;
  static char buf[80];
  if (seconds < 0) {
    sign = '-';
    seconds = -seconds;
  } else
    sign = '+';
  sprintf(buf, "%c%02d:%02d", sign, seconds / 3600, (seconds % 3600) / 60);
  return buf;
}


x86 assembly (clang, -O0):
<seconds2hhmm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1136 <seconds2hhmm+0x26>
movb   $0x2d,-0x5(%rbp)
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    113a <seconds2hhmm+0x2a>
movb   $0x2b,-0x5(%rbp)
mov    -0x5(%rbp),%al
mov    %al,-0x6(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
mov    $0xe10,%esi
cltd
idiv   %esi
mov    %edx,%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %eax,%r8d
mov    -0x6(%rbp),%al
lea    0x2ed1(%rip),%rdi
lea    0xe8a(%rip),%rsi
movsbl %al,%edx
call   1030 <sprintf@plt>
lea    0x2ebb(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seconds2hhmm>:
push   %rbx
mov    %edi,%eax
neg    %eax
cmovs  %edi,%eax
mov    $0x91a2b3c5,%ecx
imul   %rax,%rcx
shr    $0x2b,%rcx
imul   $0xe10,%ecx,%edx
sub    %edx,%eax
imul   $0x8889,%eax,%r8d
shr    $0x15,%r8d
shr    $0x1f,%edi
lea    (%rdi,%rdi,1),%edx
add    $0x2b,%edx
lea    0x2ef8(%rip),%rbx
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@seconds2hhmm.buf = internal global [80 x i8] zeroinitializer
@.str = [12 x i8] c"%c%02d:%02d\00"
define i8* @seconds2hhmm(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
store i8 45, i8* %3
%7 = load i32, i32* %2
%8 = sub nsw i32 0, %7
store i32 %8, i32* %2
br label %10
9: ; preds = %1
store i8 43, i8* %3
br label %10
10: ; preds = %9, %6
%11 = load i8, i8* %3
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 3600
%14 = load i32, i32* %2
%15 = srem i32 %14, 3600
%16 = sdiv i32 %15, 60
%17 = call i32 @sprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @seconds2hhmm.buf, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext %11, i32 %13, i32 %16)
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @seconds2hhmm.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@seconds2hhmm.buf = internal global [80 x i8] zeroinitializer
@.str = [12 x i8] c"%c%02d:%02d\00"
define i8* @seconds2hhmm(i32 %0) {
%2 = icmp slt i32 %0, 0
%3 = sub nsw i32 0, %0
%4 = select i1 %2, i32 %3, i32 %0
%5 = select i1 %2, i8 45, i8 43
%6 = udiv i32 %4, 3600
%7 = urem i32 %4, 3600
%8 = trunc i32 %7 to i16
%9 = udiv i16 %8, 60
%10 = zext i16 %9 to i32
%11 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @seconds2hhmm.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8 signext %5, i32 %6, i32 %10)
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @seconds2hhmm.buf, i64 0, i64 0)
}