#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 ops_matvec(int);
double ops_solve(int);
int /*<<< orphan*/ printf(char *, ...);
void print_timing(char *prog, double t[5], int n, double norm, int csvout) {
  if (!csvout) {
    printf("\nreal time information:\n");
    printf("memory alloc\t matrix init\t A*x\t\t solving\t total\n");
    printf("%f\t %f\t %f\t %f\t %f\n", t[0], t[1], t[2], t[3], t[4]);
    printf("\nmflops: %f\n\n", ops_solve(n) / t[3] / 1e6);
    printf("\n");
  } else {
    printf("%s, %i, %.3e, %.3e, %.4e, %.4e, %.3e\n", prog, n,
           ops_solve(n) / t[3], ops_matvec(n) / t[2], t[3], t[2], norm);
  }
}


x86 assembly (clang, -O0):
<print_timing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11e9 <print_timing+0xb9>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm3
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm4
lea    0xeae(%rip),%rdi
mov    $0x5,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1050 <ops_solve@plt>
mov    -0x10(%rbp),%rax
divsd  0x18(%rax),%xmm0
movsd  0xe3c(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe97(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1252 <print_timing+0x122>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <ops_solve@plt>
mov    -0x10(%rbp),%rax
divsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <ops_matvec@plt>
mov    -0x40(%rbp),%rsi
mov    -0x34(%rbp),%edx
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
divsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm3
movsd  -0x20(%rbp),%xmm4
lea    0xe29(%rip),%rdi
mov    $0x5,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_timing>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
test   %ecx,%ecx
je     11ba <print_timing+0x6a>
mov    %rdi,%r14
mov    %ebp,%edi
movsd  %xmm0,0x8(%rsp)
call   1070 <ops_solve@plt>
divsd  0x18(%rbx),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
call   1060 <ops_matvec@plt>
movapd %xmm0,%xmm1
movsd  0x10(%rbx),%xmm3
movsd  0x18(%rbx),%xmm2
divsd  %xmm3,%xmm1
lea    0xe8f(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm4
mov    $0x5,%al
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <printf@plt>
lea    0xe8f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
movsd  (%rbx),%xmm0
movsd  0x8(%rbx),%xmm1
movsd  0x10(%rbx),%xmm2
movsd  0x18(%rbx),%xmm3
movsd  0x20(%rbx),%xmm4
lea    0xe17(%rip),%rdi
mov    $0x5,%al
call   1050 <printf@plt>
mov    %ebp,%edi
call   1070 <ops_solve@plt>
divsd  0x18(%rbx),%xmm0
divsd  0xdf4(%rip),%xmm0
lea    0xe09(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"\0Areal time information:\0A\00"
@.str.1 = [49 x i8] c"memory alloc\09 matrix init\09 A*x\09\09 solving\09 total\0A\00"
@.str.2 = [20 x i8] c"%f\09 %f\09 %f\09 %f\09 %f\0A\00"
@.str.3 = [14 x i8] c"\0Amflops: %f\0A\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [38 x i8] c"%s, %i, %.3e, %.3e, %.4e, %.4e, %.3e\0A\00"
define void @print_timing(i8* %0, double* %1, i32 %2, double %3, i32 %4) {
%6 = alloca i8*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
store i8* %0, i8** %6
store double* %1, double** %7
store i32 %2, i32* %8
store double %3, double* %9
store i32 %4, i32* %10
%11 = load i32, i32* %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %41, label %13
13: ; preds = %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%16 = load double*, double** %7
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
%19 = load double*, double** %7
%20 = getelementptr inbounds double, double* %19, i64 1
%21 = load double, double* %20
%22 = load double*, double** %7
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = load double*, double** %7
%26 = getelementptr inbounds double, double* %25, i64 3
%27 = load double, double* %26
%28 = load double*, double** %7
%29 = getelementptr inbounds double, double* %28, i64 4
%30 = load double, double* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %18, double %21, double %24, double %27, double %30)
%32 = load i32, i32* %8
%33 = call double @ops_solve(i32 %32)
%34 = load double*, double** %7
%35 = getelementptr inbounds double, double* %34, i64 3
%36 = load double, double* %35
%37 = fdiv double %33, %36
%38 = fdiv double %37, 1.000000e+06
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %38)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %64
41: ; preds = %5
%42 = load i8*, i8** %6
%43 = load i32, i32* %8
%44 = load i32, i32* %8
%45 = call double @ops_solve(i32 %44)
%46 = load double*, double** %7
%47 = getelementptr inbounds double, double* %46, i64 3
%48 = load double, double* %47
%49 = fdiv double %45, %48
%50 = load i32, i32* %8
%51 = call double @ops_matvec(i32 %50)
%52 = load double*, double** %7
%53 = getelementptr inbounds double, double* %52, i64 2
%54 = load double, double* %53
%55 = fdiv double %51, %54
%56 = load double*, double** %7
%57 = getelementptr inbounds double, double* %56, i64 3
%58 = load double, double* %57
%59 = load double*, double** %7
%60 = getelementptr inbounds double, double* %59, i64 2
%61 = load double, double* %60
%62 = load double, double* %9
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %42, i32 %43, double %49, double %55, double %58, double %61, double %62)
br label %64
64: ; preds = %41, %13
ret void
}

LLVM IR (-O2):
@.str.2 = [20 x i8] c"%f\09 %f\09 %f\09 %f\09 %f\0A\00"
@.str.3 = [14 x i8] c"\0Amflops: %f\0A\0A\00"
@.str.5 = [38 x i8] c"%s, %i, %.3e, %.3e, %.4e, %.4e, %.3e\0A\00"
@str = [24 x i8] c"\0Areal time information:\00"
@str.6 = [48 x i8] c"memory alloc\09 matrix init\09 A*x\09\09 solving\09 total\00"
define void @print_timing(i8* %0, double* nocapture %1, i32 %2, double %3, i32 %4) {
%6 = icmp eq i32 %4, 0
br i1 %6, label %7, label %26
7: ; preds = %5
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.6, i64 0, i64 0))
%10 = load double, double* %1
%11 = getelementptr inbounds double, double* %1, i64 1
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %1, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %1, i64 3
%16 = load double, double* %15
%17 = getelementptr inbounds double, double* %1, i64 4
%18 = load double, double* %17
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), double %10, double %12, double %14, double %16, double %18)
%20 = tail call double @ops_solve(i32 %2)
%21 = load double, double* %15
%22 = fdiv double %20, %21
%23 = fdiv double %22, 1.000000e+06
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %23)
%25 = tail call i32 @putchar(i32 10)
br label %37
26: ; preds = %5
%27 = tail call double @ops_solve(i32 %2)
%28 = getelementptr inbounds double, double* %1, i64 3
%29 = load double, double* %28
%30 = fdiv double %27, %29
%31 = tail call double @ops_matvec(i32 %2)
%32 = getelementptr inbounds double, double* %1, i64 2
%33 = load double, double* %32
%34 = fdiv double %31, %33
%35 = load double, double* %28
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %0, i32 %2, double %30, double %34, double %35, double %33, double %3)
br label %37
37: ; preds = %26, %7
ret void
}