#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*/ F(double *, double *);
double fmax(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ getMaxAbsEigenValue(double *);
void laxFriedrichRiemannSolver(double UL[], double UR[], double *flux) {
  double FL[3];
  double FR[3];
  F(UL, FL);
  F(UR, FR);
  double maxWaveSpeed = fmax(getMaxAbsEigenValue(UL), getMaxAbsEigenValue(UR));
  int var;
  for (var = 0; var < 3; var++) {
    flux[var] =
        0.5 * (FL[var] + FR[var]) - 0.5 * maxWaveSpeed * (UR[var] - UL[var]);
  }
}


x86 assembly (clang, -O0):
<laxFriedrichRiemannSolver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <F@plt>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <F@plt>
mov    -0x8(%rbp),%rdi
call   1050 <getMaxAbsEigenValue@plt>
mov    %eax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <getMaxAbsEigenValue@plt>
mov    -0x60(%rbp),%edi
mov    %eax,%esi
call   1040 <fmax@plt>
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
cmpl   $0x3,-0x5c(%rbp)
jge    1214 <laxFriedrichRiemannSolver+0xe4>
movslq -0x5c(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm0
movslq -0x5c(%rbp),%rax
addsd  -0x50(%rbp,%rax,8),%xmm0
movsd  0xe51(%rip),%xmm1
mulsd  -0x58(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x5c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe0f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1189 <laxFriedrichRiemannSolver+0x59>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<laxFriedrichRiemannSolver>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0x20(%rsp),%rsi
call   1030 <F@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <F@plt>
mov    %r15,%rdi
call   1050 <getMaxAbsEigenValue@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <getMaxAbsEigenValue@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <fmax@plt>
mulsd  0xe85(%rip),%xmm0
movsd  0x20(%rsp),%xmm1
addsd  (%rsp),%xmm1
movsd  (%rbx),%xmm2
subsd  (%r15),%xmm2
mulsd  %xmm0,%xmm2
movsd  0xe6d(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%r14)
movsd  0x28(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
movsd  0x8(%rbx),%xmm2
subsd  0x8(%r15),%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x30(%rsp),%xmm1
addsd  0x10(%rsp),%xmm1
movsd  0x10(%rbx),%xmm2
subsd  0x10(%r15),%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @laxFriedrichRiemannSolver(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = alloca double
%10 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%11 = load double*, double** %4
%12 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%13 = call i32 @F(double* %11, double* %12)
%14 = load double*, double** %5
%15 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%16 = call i32 @F(double* %14, double* %15)
%17 = load double*, double** %4
%18 = call i32 @getMaxAbsEigenValue(double* %17)
%19 = load double*, double** %5
%20 = call i32 @getMaxAbsEigenValue(double* %19)
%21 = call double @fmax(i32 %18, i32 %20)
store double %21, double* %9
store i32 0, i32* %10
br label %22
22: ; preds = %55, %3
%23 = load i32, i32* %10
%24 = icmp slt i32 %23, 3
br i1 %24, label %25, label %58
25: ; preds = %22
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 %27
%29 = load double, double* %28
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %31
%33 = load double, double* %32
%34 = fadd double %29, %33
%35 = load double, double* %9
%36 = fmul double 5.000000e-01, %35
%37 = load double*, double** %5
%38 = load i32, i32* %10
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = load double*, double** %4
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = fsub double %41, %46
%48 = fmul double %36, %47
%49 = fneg double %48
%50 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %34, double %49)
%51 = load double*, double** %6
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
store double %50, double* %54
br label %55
55: ; preds = %25
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
br label %22
58: ; preds = %22
ret void
}

LLVM IR (-O2):
define void @laxFriedrichRiemannSolver(double* %0, double* %1, double* nocapture writeonly %2) {
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = bitcast [3 x double]* %4 to i8*
%7 = bitcast [3 x double]* %5 to i8*
%8 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%9 = call i32 @F(double* %0, double* %8)
%10 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%11 = call i32 @F(double* %1, double* %10)
%12 = call i32 @getMaxAbsEigenValue(double* %0)
%13 = call i32 @getMaxAbsEigenValue(double* %1)
%14 = call double @fmax(i32 %12, i32 %13)
%15 = fmul double %14, -5.000000e-01
%16 = load double, double* %8
%17 = load double, double* %10
%18 = fadd double %16, %17
%19 = load double, double* %1
%20 = load double, double* %0
%21 = fsub double %19, %20
%22 = fmul double %15, %21
%23 = call double @llvm.fmuladd.f64(double %18, double 5.000000e-01, double %22)
store double %23, double* %2
%24 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%25 = load double, double* %24
%26 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%27 = load double, double* %26
%28 = fadd double %25, %27
%29 = getelementptr inbounds double, double* %1, i64 1
%30 = load double, double* %29
%31 = getelementptr inbounds double, double* %0, i64 1
%32 = load double, double* %31
%33 = fsub double %30, %32
%34 = fmul double %15, %33
%35 = call double @llvm.fmuladd.f64(double %28, double 5.000000e-01, double %34)
%36 = getelementptr inbounds double, double* %2, i64 1
store double %35, double* %36
%37 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%38 = load double, double* %37
%39 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%40 = load double, double* %39
%41 = fadd double %38, %40
%42 = getelementptr inbounds double, double* %1, i64 2
%43 = load double, double* %42
%44 = getelementptr inbounds double, double* %0, i64 2
%45 = load double, double* %44
%46 = fsub double %43, %45
%47 = fmul double %15, %46
%48 = call double @llvm.fmuladd.f64(double %41, double 5.000000e-01, double %47)
%49 = getelementptr inbounds double, double* %2, i64 2
store double %48, double* %49
ret void
}