#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int seg = 0, min = 0, hr = 0;
  int n;
  printf("\n Digite um numero em segundos: ");
  scanf("%d", &n);
  if (n <= 60) {
    seg = n;
  }
  if (n > 60 && n <= 3600) {
    seg = n % 60;
    min = n / 60;
    if (min == 60) {
      min = 0;
      hr = 1;
    }
  } else {
    seg = n % 60;
    min = n / 60;
    while (min >= 60) {
      ++hr;
      min -= 60;
    }
  }
  printf("\n => %.2d : %.2d : %.2d ", hr, min, seg);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3c,-0x14(%rbp)
jg     1172 <main+0x52>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x3c,-0x14(%rbp)
jle    11c2 <main+0xa2>
cmpl   $0xe10,-0x14(%rbp)
jg     11c2 <main+0xa2>
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x3c,-0xc(%rbp)
jne    11bd <main+0x9d>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
jmp    1204 <main+0xe4>
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x3c,-0xc(%rbp)
jl     11ff <main+0xdf>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x3c,%eax
mov    %eax,-0xc(%rbp)
jmp    11de <main+0xbe>
jmp    1204 <main+0xe4>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
lea    -0x3d(%rcx),%edx
movslq %ecx,%rax
cmp    $0xdd3,%edx
ja     1179 <main+0x59>
movzwl %cx,%edx
imul   $0x8889,%edx,%esi
shr    $0x15,%esi
lea    -0xe10(%rcx),%edi
xor    %edx,%edx
xor    %ebx,%ebx
cmp    $0x3c,%edi
setb   %bl
cmovae %esi,%edx
jmp    11c1 <main+0xa1>
imul   $0xffffffff88888889,%rax,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x5,%edx
add    %esi,%edx
cmp    $0xe10,%eax
jl     11c1 <main+0xa1>
cmp    $0x77,%edx
mov    $0x77,%esi
cmovl  %edx,%esi
neg    %esi
add    %edx,%esi
add    $0x3b,%esi
mov    $0x88888889,%ebx
imul   %rsi,%rbx
shr    $0x25,%rbx
imul   $0xffffffc4,%ebx,%esi
add    $0x1,%ebx
add    %esi,%edx
add    $0xffffffc4,%edx
imul   $0xffffffff88888889,%rax,%rax
shr    $0x20,%rax
add    %ecx,%eax
mov    %eax,%esi
shr    $0x1f,%esi
sar    $0x5,%eax
add    %esi,%eax
imul   $0x3c,%eax,%eax
sub    %eax,%ecx
lea    0xe40(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0A Digite um numero em segundos: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"\0A => %.2d : %.2d : %.2d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%8 = load i32, i32* %5
%9 = icmp sle i32 %8, 60
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = load i32, i32* %5
store i32 %11, i32* %2
br label %12
12: ; preds = %10, %0
%13 = load i32, i32* %5
%14 = icmp sgt i32 %13, 60
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = load i32, i32* %5
%17 = icmp sle i32 %16, 3600
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = load i32, i32* %5
%20 = srem i32 %19, 60
store i32 %20, i32* %2
%21 = load i32, i32* %5
%22 = sdiv i32 %21, 60
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 60
br i1 %24, label %25, label %26
25: ; preds = %18
store i32 0, i32* %3
store i32 1, i32* %4
br label %26
26: ; preds = %25, %18
br label %41
27: ; preds = %15, %12
%28 = load i32, i32* %5
%29 = srem i32 %28, 60
store i32 %29, i32* %2
%30 = load i32, i32* %5
%31 = sdiv i32 %30, 60
store i32 %31, i32* %3
br label %32
32: ; preds = %35, %27
%33 = load i32, i32* %3
%34 = icmp sge i32 %33, 60
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
%38 = load i32, i32* %3
%39 = sub nsw i32 %38, 60
store i32 %39, i32* %3
br label %32
40: ; preds = %32
br label %41
41: ; preds = %40, %26
%42 = load i32, i32* %4
%43 = load i32, i32* %3
%44 = load i32, i32* %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %42, i32 %43, i32 %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"\0A Digite um numero em segundos: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [25 x i8] c"\0A => %.2d : %.2d : %.2d \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = add i32 %5, -61
%7 = icmp ult i32 %6, 3540
br i1 %7, label %8, label %16
8: ; preds = %0
%9 = trunc i32 %5 to i16
%10 = udiv i16 %9, 60
%11 = zext i16 %10 to i32
%12 = add nsw i32 %5, -3600
%13 = icmp ult i32 %12, 60
%14 = select i1 %13, i32 0, i32 %11
%15 = zext i1 %13 to i32
br label %28
16: ; preds = %0
%17 = sdiv i32 %5, 60
%18 = icmp sgt i32 %5, 3599
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = add nsw i32 %17, 59
%21 = call i32 @llvm.smin.i32(i32 %17, i32 119)
%22 = sub nsw i32 %20, %21
%23 = udiv i32 %22, 60
%24 = add nuw nsw i32 %23, 1
%25 = mul i32 %23, -60
%26 = add nsw i32 %17, -60
%27 = add i32 %25, %26
br label %28
28: ; preds = %19, %16, %8
%29 = phi i32 [ %14, %8 ], [ %17, %16 ], [ %27, %19 ]
%30 = phi i32 [ %15, %8 ], [ 0, %16 ], [ %24, %19 ]
%31 = srem i32 %5, 60
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %30, i32 %29, i32 %31)
ret i32 0
}