#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*/ assert(int);
double floor(double);
int printf(char *, ...);
scalar_t__ round(double);
int pr_time(double sec) {
  int has_h, has_m;
  int c, tot;
  tot = printf(" -- ");
  assert(tot > 0);
  has_h = sec >= 3600;
  if (has_h) {
    double h = floor(sec / 3600);
    c = printf("%i:", (int)h);
    assert(c > 0);
    tot += c;
    sec -= h * 3600;
  }
  has_m = has_h || sec >= 60;
  if (has_m) {
    double m = floor(sec / 60);
    if (has_h)
      c = printf("%02i:", (int)m);
    else
      c = printf("%i:", (int)m);
    assert(c > 0);
    tot += c;
    sec -= m * 60;
  }
  if (has_m)
    c = printf("%02i", (int)round(sec));
  else
    c = printf("%is", (int)round(sec));
  assert(c > 0);
  return tot + c;
}


x86 assembly (clang, -O0):
<pr_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  -0x8(%rbp),%xmm0
movsd  0xe84(%rip),%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1216 <pr_time+0xd6>
movsd  -0x8(%rbp),%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <floor@plt>
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x20(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xdf7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x29(%rbp)
jne    123c <pr_time+0xfc>
movsd  -0x8(%rbp),%xmm0
movsd  0xdd6(%rip),%xmm1
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     12f7 <pr_time+0x1b7>
movsd  -0x8(%rbp),%xmm0
movsd  0xdaa(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1060 <floor@plt>
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1291 <pr_time+0x151>
cvttsd2si -0x28(%rbp),%esi
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %eax,-0x14(%rbp)
jmp    12a7 <pr_time+0x167>
cvttsd2si -0x28(%rbp),%esi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd1e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1323 <pr_time+0x1e3>
movsd  -0x8(%rbp),%xmm0
call   1050 <round@plt>
mov    %eax,%esi
lea    0xd0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %eax,-0x14(%rbp)
jmp    1340 <pr_time+0x200>
movsd  -0x8(%rbp),%xmm0
call   1050 <round@plt>
mov    %eax,%esi
lea    0xcee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_time>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,(%rsp)
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %eax,%ebx
xor    %edi,%edi
test   %eax,%eax
setg   %dil
call   1040 <assert@plt>
movsd  (%rsp),%xmm0
ucomisd 0xe89(%rip),%xmm0
jae    118f <pr_time+0x4f>
ucomisd 0xe87(%rip),%xmm0
jae    11ea <pr_time+0xaa>
lea    0xe9a(%rip),%r14
jmp    124b <pr_time+0x10b>
movsd  (%rsp),%xmm0
divsd  0xe64(%rip),%xmm0
call   1060 <floor@plt>
movsd  %xmm0,0x8(%rsp)
cvttsd2si %xmm0,%esi
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %eax,%ebp
xor    %edi,%edi
test   %eax,%eax
setg   %dil
call   1040 <assert@plt>
movsd  (%rsp),%xmm0
add    %ebp,%ebx
movsd  0x8(%rsp),%xmm1
mulsd  0xe23(%rip),%xmm1
subsd  %xmm1,%xmm0
lea    0xe31(%rip),%r14
jmp    11f1 <pr_time+0xb1>
lea    0xe24(%rip),%r14
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
divsd  0xe05(%rip),%xmm0
call   1060 <floor@plt>
movsd  %xmm0,0x8(%rsp)
cvttsd2si %xmm0,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %eax,%ebp
xor    %edi,%edi
test   %eax,%eax
setg   %dil
call   1040 <assert@plt>
movsd  (%rsp),%xmm0
add    %ebp,%ebx
movsd  0x8(%rsp),%xmm1
mulsd  0xdc8(%rip),%xmm1
subsd  %xmm1,%xmm0
lea    0xdd4(%rip),%r14
call   1050 <round@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %eax,%ebp
xor    %edi,%edi
test   %eax,%eax
setg   %dil
call   1040 <assert@plt>
add    %ebp,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c" -- \00"
@.str.1 = [4 x i8] c"%i:\00"
@.str.2 = [6 x i8] c"%02i:\00"
@.str.3 = [5 x i8] c"%02i\00"
@.str.4 = [4 x i8] c"%is\00"
define i32 @pr_time(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store double %0, double* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load double, double* %2
%15 = fcmp oge double %14, 3.600000e+03
%16 = zext i1 %15 to i32
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %37
19: ; preds = %1
%20 = load double, double* %2
%21 = fdiv double %20, 3.600000e+03
%22 = call double @llvm.floor.f64(double %21)
store double %22, double* %7
%23 = load double, double* %7
%24 = fptosi double %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = icmp sgt i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = add nsw i32 %31, %30
store i32 %32, i32* %6
%33 = load double, double* %7
%34 = load double, double* %2
%35 = fneg double %33
%36 = call double @llvm.fmuladd.f64(double %35, double 3.600000e+03, double %34)
store double %36, double* %2
br label %37
37: ; preds = %19, %1
%38 = load i32, i32* %3
%39 = icmp ne i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load double, double* %2
%42 = fcmp oge double %41, 6.000000e+01
br label %43
43: ; preds = %40, %37
%44 = phi i1 [ true, %37 ], [ %42, %40 ]
%45 = zext i1 %44 to i32
store i32 %45, i32* %4
%46 = load i32, i32* %4
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %74
48: ; preds = %43
%49 = load double, double* %2
%50 = fdiv double %49, 6.000000e+01
%51 = call double @llvm.floor.f64(double %50)
store double %51, double* %8
%52 = load i32, i32* %3
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %48
%55 = load double, double* %8
%56 = fptosi double %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %56)
store i32 %57, i32* %5
br label %62
58: ; preds = %48
%59 = load double, double* %8
%60 = fptosi double %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %60)
store i32 %61, i32* %5
br label %62
62: ; preds = %58, %54
%63 = load i32, i32* %5
%64 = icmp sgt i32 %63, 0
%65 = zext i1 %64 to i32
%66 = call i32 @assert(i32 %65)
%67 = load i32, i32* %5
%68 = load i32, i32* %6
%69 = add nsw i32 %68, %67
store i32 %69, i32* %6
%70 = load double, double* %8
%71 = load double, double* %2
%72 = fneg double %70
%73 = call double @llvm.fmuladd.f64(double %72, double 6.000000e+01, double %71)
store double %73, double* %2
br label %74
74: ; preds = %62, %43
%75 = load i32, i32* %4
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %82
77: ; preds = %74
%78 = load double, double* %2
%79 = call i64 @round(double %78)
%80 = trunc i64 %79 to i32
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %80)
store i32 %81, i32* %5
br label %87
82: ; preds = %74
%83 = load double, double* %2
%84 = call i64 @round(double %83)
%85 = trunc i64 %84 to i32
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %85)
store i32 %86, i32* %5
br label %87
87: ; preds = %82, %77
%88 = load i32, i32* %5
%89 = icmp sgt i32 %88, 0
%90 = zext i1 %89 to i32
%91 = call i32 @assert(i32 %90)
%92 = load i32, i32* %6
%93 = load i32, i32* %5
%94 = add nsw i32 %92, %93
ret i32 %94
}

LLVM IR (-O2):
@.str = [5 x i8] c" -- \00"
@.str.1 = [4 x i8] c"%i:\00"
@.str.2 = [6 x i8] c"%02i:\00"
@.str.3 = [5 x i8] c"%02i\00"
@.str.4 = [4 x i8] c"%is\00"
define i32 @pr_time(double %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp sgt i32 %2, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = fcmp ult double %0, 3.600000e+03
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = fcmp ult double %0, 6.000000e+01
br i1 %8, label %34, label %20
9: ; preds = %1
%10 = fdiv double %0, 3.600000e+03
%11 = tail call double @llvm.floor.f64(double %10)
%12 = fptosi double %11 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = icmp sgt i32 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = add nsw i32 %13, %2
%18 = fneg double %11
%19 = tail call double @llvm.fmuladd.f64(double %18, double 3.600000e+03, double %0)
br label %20
20: ; preds = %7, %9
%21 = phi double [ %19, %9 ], [ %0, %7 ]
%22 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %7 ]
%23 = phi i32 [ %17, %9 ], [ %2, %7 ]
%24 = fdiv double %21, 6.000000e+01
%25 = tail call double @llvm.floor.f64(double %24)
%26 = fptosi double %25 to i32
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %22, i32 %26)
%28 = icmp sgt i32 %27, 0
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = add nsw i32 %27, %23
%32 = fneg double %25
%33 = tail call double @llvm.fmuladd.f64(double %32, double 6.000000e+01, double %21)
br label %34
34: ; preds = %7, %20
%35 = phi double [ %33, %20 ], [ %0, %7 ]
%36 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %20 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %7 ]
%37 = phi i32 [ %31, %20 ], [ %2, %7 ]
%38 = tail call i64 @round(double %35)
%39 = trunc i64 %38 to i32
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %36, i32 %39)
%41 = icmp sgt i32 %40, 0
%42 = zext i1 %41 to i32
%43 = tail call i32 @assert(i32 %42)
%44 = add nsw i32 %40, %37
ret i32 %44
}