#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 L(double, double, double, double);
double h(double, double, double);
double psih01(double);
double psih2(double);
double psim200(double);
double rah(double, double, double);
double rohair(double, double, double);
double ustar2(double, double, double);
double metiter(double a[10], double b[10], double t0, double rah0, double z0m,
               double ustar0, double dem, double u200, int iteration) {
  int i;
  double dT, airden, h0, L0, psim_200, psih_2, psih_01, u_star, r_ah;
  r_ah = rah0;
  for (i = 0; i < iteration; i++) {
    dT = a[i] * t0 + b[i];
    airden = rohair(dem, t0, dT);
    h0 = h(airden, dT, r_ah);
    L0 = L(airden, ustar0, t0, h0);
    psim_200 = psim200(L0);
    psih_2 = psih2(L0);
    psih_01 = psih01(L0);
    u_star = ustar2(u200, z0m, psim_200);
    r_ah = rah(psih_2, psih_01, u_star);
  }
  return (h0);
}


x86 assembly (clang, -O0):
<metiter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
movsd  %xmm5,-0x40(%rbp)
mov    %edx,-0x44(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    12c9 <metiter+0x149>
mov    -0x8(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x18(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
call   1060 <rohair@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x90(%rbp),%xmm2
ff
call   1040 <h@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm3
call   1050 <L@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1070 <psim200@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1030 <psih2@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm0
call   10a0 <psih01@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
call   1080 <ustar2@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
movsd  -0x88(%rbp),%xmm2
ff
call   1090 <rah@plt>
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11c8 <metiter+0x48>
movsd  -0x60(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<metiter>:
test   %edx,%edx
jle    12b7 <metiter+0x137>
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
movapd %xmm1,%xmm6
movapd %xmm0,%xmm1
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xor    %ebx,%ebx
movsd  %xmm5,0x38(%rsp)
movsd  %xmm3,0x30(%rsp)
movsd  %xmm2,0x28(%rsp)
movsd  %xmm4,0x40(%rsp)
movsd  %xmm0,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm6,0x10(%rsp)
movsd  (%r15,%rbx,8),%xmm2
mulsd  %xmm1,%xmm2
addsd  (%r14,%rbx,8),%xmm2
movsd  %xmm2,0x8(%rsp)
movaps %xmm4,%xmm0
movsd  0x18(%rsp),%xmm1
call   1060 <rohair@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1040 <h@plt>
movaps %xmm0,%xmm3
movsd  (%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  %xmm3,0x20(%rsp)
call   1050 <L@plt>
movsd  %xmm0,(%rsp)
call   1070 <psim200@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1030 <psih2@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   10a0 <psih01@plt>
movsd  %xmm0,(%rsp)
movsd  0x38(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1080 <ustar2@plt>
movaps %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1090 <rah@plt>
movsd  0x18(%rsp),%xmm1
movsd  0x40(%rsp),%xmm4
movapd %xmm0,%xmm6
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11d0 <metiter+0x50>
movsd  0x20(%rsp),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
ret

LLVM IR (-O0):
define double @metiter(double* %0, double* %1, double %2, double %3, double %4, double %5, double %6, double %7, i32 %8) {
%10 = alloca double*
%11 = alloca double*
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
store double* %0, double** %10
store double* %1, double** %11
store double %2, double* %12
store double %3, double* %13
store double %4, double* %14
store double %5, double* %15
store double %6, double* %16
store double %7, double* %17
store i32 %8, i32* %18
%29 = load double, double* %13
store double %29, double* %28
store i32 0, i32* %19
br label %30
30: ; preds = %74, %9
%31 = load i32, i32* %19
%32 = load i32, i32* %18
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %77
34: ; preds = %30
%35 = load double*, double** %10
%36 = load i32, i32* %19
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = load double, double* %12
%41 = load double*, double** %11
%42 = load i32, i32* %19
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
%45 = load double, double* %44
%46 = call double @llvm.fmuladd.f64(double %39, double %40, double %45)
store double %46, double* %20
%47 = load double, double* %16
%48 = load double, double* %12
%49 = load double, double* %20
%50 = call double @rohair(double %47, double %48, double %49)
store double %50, double* %21
%51 = load double, double* %21
%52 = load double, double* %20
%53 = load double, double* %28
%54 = call double @h(double %51, double %52, double %53)
store double %54, double* %22
%55 = load double, double* %21
%56 = load double, double* %15
%57 = load double, double* %12
%58 = load double, double* %22
%59 = call double @L(double %55, double %56, double %57, double %58)
store double %59, double* %23
%60 = load double, double* %23
%61 = call double @psim200(double %60)
store double %61, double* %24
%62 = load double, double* %23
%63 = call double @psih2(double %62)
store double %63, double* %25
%64 = load double, double* %23
%65 = call double @psih01(double %64)
store double %65, double* %26
%66 = load double, double* %17
%67 = load double, double* %14
%68 = load double, double* %24
%69 = call double @ustar2(double %66, double %67, double %68)
store double %69, double* %27
%70 = load double, double* %25
%71 = load double, double* %26
%72 = load double, double* %27
%73 = call double @rah(double %70, double %71, double %72)
store double %73, double* %28
br label %74
74: ; preds = %34
%75 = load i32, i32* %19
%76 = add nsw i32 %75, 1
store i32 %76, i32* %19
br label %30
77: ; preds = %30
%78 = load double, double* %22
ret double %78
}

LLVM IR (-O2):
define double @metiter(double* nocapture %0, double* nocapture %1, double %2, double %3, double %4, double %5, double %6, double %7, i32 %8) {
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %31
11: ; preds = %9
%12 = zext i32 %8 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %29, %13 ]
%15 = phi double [ %3, %11 ], [ %28, %13 ]
%16 = getelementptr inbounds double, double* %0, i64 %14
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %1, i64 %14
%19 = load double, double* %18
%20 = tail call double @llvm.fmuladd.f64(double %17, double %2, double %19)
%21 = tail call double @rohair(double %6, double %2, double %20)
%22 = tail call double @h(double %21, double %20, double %15)
%23 = tail call double @L(double %21, double %5, double %2, double %22)
%24 = tail call double @psim200(double %23)
%25 = tail call double @psih2(double %23)
%26 = tail call double @psih01(double %23)
%27 = tail call double @ustar2(double %7, double %4, double %24)
%28 = tail call double @rah(double %25, double %26, double %27)
%29 = add nuw nsw i64 %14, 1
%30 = icmp eq i64 %29, %12
br i1 %30, label %31, label %13
31: ; preds = %13, %9
%32 = phi double [ undef, %9 ], [ %22, %13 ]
ret double %32
}