#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, ...);
int segparaHoras(int segundos) {
  int h, m, s;
  if (segundos < 60) {
    s = segundos;
    printf("%ds", s);
  } else if (segundos < 3600) {
    m = segundos / 60;
    s = segundos % 60;
    printf("Tempo: %dm:%ds", m, s);
  } else {
    h = segundos / 3600;
    segundos -= (h * 3600);
    m = segundos / 60;
    s = segundos % 60;
    printf("Tempo: %dh:%dm:%ds", h, m, s);
  }
  return 0;
}


x86 assembly (clang, -O0):
<segparaHoras>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x3c,-0x4(%rbp)
jge    1141 <segparaHoras+0x31>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <segparaHoras+0xc8>
cmpl   $0xe10,-0x4(%rbp)
jge    1183 <segparaHoras+0x73>
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d3 <segparaHoras+0xc3>
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)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <segparaHoras+0xc8>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<segparaHoras>:
push   %rax
mov    %edi,%eax
cmp    $0x3b,%edi
jg     112a <segparaHoras+0x1a>
lea    0xeec(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1199 <segparaHoras+0x89>
cmp    $0xe0f,%eax
ja     1155 <segparaHoras+0x45>
movzwl %ax,%ecx
imul   $0x8889,%ecx,%esi
shr    $0x15,%esi
imul   $0x3c,%esi,%ecx
sub    %ecx,%eax
movzwl %ax,%edx
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1199 <segparaHoras+0x89>
mov    %eax,%ecx
mov    $0x91a2b3c5,%esi
imul   %rcx,%rsi
shr    $0x2b,%rsi
imul   $0xfffff1f0,%esi,%ecx
add    %eax,%ecx
movslq %ecx,%rcx
imul   $0xffffffff88888889,%rcx,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0x5,%edx
add    %eax,%edx
imul   $0x3c,%edx,%eax
sub    %eax,%ecx
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%ds\00"
@.str.1 = [15 x i8] c"Tempo: %dm:%ds\00"
@.str.2 = [19 x i8] c"Tempo: %dh:%dm:%ds\00"
define i32 @segparaHoras(i32 %0) {
%2 = icmp slt i32 %0, 60
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %21
5: ; preds = %1
%6 = icmp ult i32 %0, 3600
br i1 %6, label %7, label %14
7: ; preds = %5
%8 = trunc i32 %0 to i16
%9 = udiv i16 %8, 60
%10 = zext i16 %9 to i32
%11 = urem i16 %8, 60
%12 = zext i16 %11 to i32
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %12)
br label %21
14: ; preds = %5
%15 = udiv i32 %0, 3600
%16 = mul nsw i32 %15, -3600
%17 = add nsw i32 %16, %0
%18 = sdiv i32 %17, 60
%19 = srem i32 %17, 60
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %18, i32 %19)
br label %21
21: ; preds = %7, %14, %3
ret i32 0
}