#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
double difftime(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double, int, int, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void printpercent(time_t start, double perc) {
  time_t end;
  double runtime;
  int hours, minutes, seconds;
  time(&end);
  runtime = difftime(end, start);
  hours = runtime / (60 * 60);
  minutes = (runtime - hours * 60 * 60) / 60;
  seconds = runtime - hours * 60 * 60 - minutes * 60;
  printf("%6.2f%% done in %2d hours, %2d minutes, %2d seconds.\n", perc, hours,
         minutes, seconds);
  return;
}


x86 assembly (clang, -O0):
<printpercent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <time@plt>
mov    -0x14(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <difftime@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xea2(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
imul   $0x3c,-0x24(%rbp),%eax
imul   $0x3c,%eax,%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe73(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
imul   $0x3c,-0x24(%rbp),%eax
imul   $0x3c,%eax,%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
imul   $0x3c,-0x28(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xe3c(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printpercent>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %edi,%ebx
lea    0x4(%rsp),%rdi
call   1050 <time@plt>
mov    0x4(%rsp),%edi
mov    %ebx,%esi
call   1040 <difftime@plt>
movapd %xmm0,%xmm1
divsd  0xea2(%rip),%xmm1
cvttsd2si %xmm1,%esi
imul   $0xe10,%esi,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
divsd  0xe89(%rip),%xmm1
cvttsd2si %xmm1,%edx
imul   $0x3c,%edx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
lea    0xe74(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [54 x i8] c"%6.2f%% done in %2d hours, %2d minutes, %2d seconds.\0A\00"
define void @printpercent(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store double %1, double* %4
%10 = call i32 @time(i32* %5)
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = call double @difftime(i32 %11, i32 %12)
store double %13, double* %6
%14 = load double, double* %6
%15 = fdiv double %14, 3.600000e+03
%16 = fptosi double %15 to i32
store i32 %16, i32* %7
%17 = load double, double* %6
%18 = load i32, i32* %7
%19 = mul nsw i32 %18, 60
%20 = mul nsw i32 %19, 60
%21 = sitofp i32 %20 to double
%22 = fsub double %17, %21
%23 = fdiv double %22, 6.000000e+01
%24 = fptosi double %23 to i32
store i32 %24, i32* %8
%25 = load double, double* %6
%26 = load i32, i32* %7
%27 = mul nsw i32 %26, 60
%28 = mul nsw i32 %27, 60
%29 = sitofp i32 %28 to double
%30 = fsub double %25, %29
%31 = load i32, i32* %8
%32 = mul nsw i32 %31, 60
%33 = sitofp i32 %32 to double
%34 = fsub double %30, %33
%35 = fptosi double %34 to i32
store i32 %35, i32* %9
%36 = load double, double* %4
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = load i32, i32* %9
%40 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), double %36, i32 %37, i32 %38, i32 %39)
ret void
}

LLVM IR (-O2):
@.str = [54 x i8] c"%6.2f%% done in %2d hours, %2d minutes, %2d seconds.\0A\00"
define void @printpercent(i32 %0, double %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @time(i32* %3)
%6 = load i32, i32* %3
%7 = call double @difftime(i32 %6, i32 %0)
%8 = fdiv double %7, 3.600000e+03
%9 = fptosi double %8 to i32
%10 = mul i32 %9, 3600
%11 = sitofp i32 %10 to double
%12 = fsub double %7, %11
%13 = fdiv double %12, 6.000000e+01
%14 = fptosi double %13 to i32
%15 = mul nsw i32 %14, 60
%16 = sitofp i32 %15 to double
%17 = fsub double %12, %16
%18 = fptosi double %17 to i32
%19 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), double %1, i32 %9, i32 %14, i32 %18)
ret void
}