#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ snprintf(char *, int, char *, long const, long const,
                            long const);
char *seconds_to_time_string(const long sec_in) {
  char *time_data_formated = NULL;
  time_data_formated = (char *)calloc(16, sizeof(char));
  if (!time_data_formated)
    return NULL;
  snprintf(time_data_formated, 16, "%2.2ld:%2.2ld:%2.2ld", sec_in / 3600,
           (sec_in % 3600) / 60, sec_in % 60);
  return time_data_formated;
}


x86 assembly (clang, -O0):
<seconds_to_time_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x10,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115f <seconds_to_time_string+0x3f>
movq   $0x0,-0x8(%rbp)
jmp    11bc <seconds_to_time_string+0x9c>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    $0xe10,%esi
cqto
idiv   %rsi
mov    %rdx,%rax
mov    $0x3c,%esi
cqto
idiv   %rsi
mov    %rax,%r8
mov    -0x10(%rbp),%rax
mov    $0x3c,%esi
cqto
idiv   %rsi
mov    %rdx,%r9
mov    $0x10,%esi
lea    0xe51(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seconds_to_time_string>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x10,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     11cb <seconds_to_time_string+0xab>
mov    %rax,%r14
movabs $0x48d159e26af37c05,%rcx
59 d1 48
mov    %rbx,%rax
imul   %rcx
mov    %rdx,%rcx
shr    $0x3f,%rcx
sar    $0xa,%rdx
add    %rdx,%rcx
imul   $0xe10,%ecx,%eax
mov    %ebx,%edx
sub    %eax,%edx
movswl %dx,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %edx,%eax
movzwl %ax,%eax
movswl %ax,%edx
shr    $0xf,%eax
sar    $0x5,%edx
add    %eax,%edx
movswq %dx,%r8
movabs $0x8888888888888889,%rdx
88 88 88
mov    %rbx,%rax
imul   %rdx
add    %rbx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x5,%rdx
add    %rax,%rdx
imul   $0x3c,%rdx,%rax
sub    %rax,%rbx
lea    0xe47(%rip),%rdx
mov    %r14,%rdi
mov    $0x10,%esi
mov    %rbx,%r9
call   1030 <snprintf@plt>
jmp    11ce <seconds_to_time_string+0xae>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"%2.2ld:%2.2ld:%2.2ld\00"
define i8* @seconds_to_time_string(i64 %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i64 %0, i64* %3
store i8* null, i8** %4
%5 = call i64 @calloc(i32 16, i32 1)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i8* null, i8** %2
br label %21
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = load i64, i64* %3
%13 = sdiv i64 %12, 3600
%14 = load i64, i64* %3
%15 = srem i64 %14, 3600
%16 = sdiv i64 %15, 60
%17 = load i64, i64* %3
%18 = srem i64 %17, 60
%19 = call i32 @snprintf(i8* %11, i32 16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %13, i64 %16, i64 %18)
%20 = load i8*, i8** %4
store i8* %20, i8** %2
br label %21
21: ; preds = %10, %9
%22 = load i8*, i8** %2
ret i8* %22
}

LLVM IR (-O2):
@.str = [21 x i8] c"%2.2ld:%2.2ld:%2.2ld\00"
define i8* @seconds_to_time_string(i64 %0) {
%2 = tail call i64 @calloc(i32 16, i32 1)
%3 = inttoptr i64 %2 to i8*
%4 = icmp eq i64 %2, 0
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = sdiv i64 %0, 3600
%7 = srem i64 %0, 3600
%8 = trunc i64 %7 to i16
%9 = sdiv i16 %8, 60
%10 = sext i16 %9 to i64
%11 = srem i64 %0, 60
%12 = tail call i32 @snprintf(i8* %3, i32 16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 %6, i64 %10, i64 %11)
br label %13
13: ; preds = %1, %5
%14 = phi i8* [ %3, %5 ], [ null, %1 ]
ret i8* %14
}