#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 */
double DBL_DIG;
int /*<<< orphan*/ printf(char *, ...);
double track_percent_error(double);
void print_total_error(void) {
  double total_error = track_percent_error(0.0);
  if (total_error > 1e-10)
    printf("\x1b[31m");
  printf("Total %%Error: %.*e\n\n", DBL_DIG, total_error);
  if (total_error > 1e-10)
    printf("\x1b[0m");
}


x86 assembly (clang, -O0):
<print_total_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
call   1040 <track_percent_error@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xebe(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115a <print_total_error+0x3a>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e87(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x8(%rbp),%xmm1
lea    0xe9d(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  0xe7b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    119d <print_total_error+0x7d>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_total_error>:
push   %rax
xorpd  %xmm0,%xmm0
call   1040 <track_percent_error@plt>
movapd %xmm0,%xmm1
ucomisd 0xeca(%rip),%xmm0
jbe    1178 <print_total_error+0x58>
lea    0xec9(%rip),%rdi
xor    %eax,%eax
movsd  %xmm1,(%rsp)
call   1030 <printf@plt>
mov    0x2e96(%rip),%rax
movsd  (%rax),%xmm0
lea    0xeb1(%rip),%rdi
movsd  (%rsp),%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
pop    %rcx
jmp    1030 <printf@plt>
mov    0x2e69(%rip),%rax
movsd  (%rax),%xmm0
lea    0xe84(%rip),%rdi
mov    $0x2,%al
pop    %rcx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"\1B[31m\00"
@.str.1 = [22 x i8] c"Total %%Error: %.*e\0A\0A\00"
@DBL_DIG = global double 0.000000e+00
@.str.2 = [5 x i8] c"\1B[0m\00"
define void @print_total_error() {
%1 = alloca double
%2 = call double @track_percent_error(double 0.000000e+00)
store double %2, double* %1
%3 = load double, double* %1
%4 = fcmp ogt double %3, 1.000000e-10
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = load double, double* @DBL_DIG
%9 = load double, double* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %8, double %9)
%11 = load double, double* %1
%12 = fcmp ogt double %11, 1.000000e-10
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %7
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"\1B[31m\00"
@.str.1 = [22 x i8] c"Total %%Error: %.*e\0A\0A\00"
@DBL_DIG = global double 0.000000e+00
@.str.2 = [5 x i8] c"\1B[0m\00"
define void @print_total_error() {
%1 = tail call double @track_percent_error(double 0.000000e+00)
%2 = fcmp ogt double %1, 1.000000e-10
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = load double, double* @DBL_DIG
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %5, double %1)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %11
8: ; preds = %0
%9 = load double, double* @DBL_DIG
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double %9, double %1)
br label %11
11: ; preds = %8, %3
ret void
}