#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*/ assert(int);
double multi_apply(double (*f)(double), int n, double s) {
  assert(n >= 1);
  if (n == 1)
    return f(s);
  return f(multi_apply(f, n - 1, s));
}


x86 assembly (clang, -O0):
<multi_apply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x1,-0x14(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x1,-0x14(%rbp)
jne    1164 <multi_apply+0x44>
mov    -0x10(%rbp),%rax
movsd  -0x20(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x8(%rbp)
jmp    118b <multi_apply+0x6b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
movsd  -0x20(%rbp),%xmm0
call   1040 <multi_apply@plt>
mov    -0x28(%rbp),%rax
call   *%rax
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multi_apply>:
push   %r14
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
mov    %esi,%ebx
mov    %rdi,%r14
xor    %edi,%edi
test   %esi,%esi
setg   %dil
call   1030 <assert@plt>
cmp    $0x1,%ebx
jne    1147 <multi_apply+0x27>
movsd  (%rsp),%xmm0
jmp    1159 <multi_apply+0x39>
add    $0xffffffff,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
movsd  (%rsp),%xmm0
call   1040 <multi_apply@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    *%rax

LLVM IR (-O0):
define double @multi_apply(double (double)* %0, i32 %1, double %2) {
%4 = alloca double
%5 = alloca double (double)*
%6 = alloca i32
%7 = alloca double
store double (double)* %0, double (double)** %5
store i32 %1, i32* %6
store double %2, double* %7
%8 = load i32, i32* %6
%9 = icmp sge i32 %8, 1
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load double (double)*, double (double)** %5
%16 = load double, double* %7
%17 = call double %15(double %16)
store double %17, double* %4
br label %26
18: ; preds = %3
%19 = load double (double)*, double (double)** %5
%20 = load double (double)*, double (double)** %5
%21 = load i32, i32* %6
%22 = sub nsw i32 %21, 1
%23 = load double, double* %7
%24 = call double @multi_apply(double (double)* %20, i32 %22, double %23)
%25 = call double %19(double %24)
store double %25, double* %4
br label %26
26: ; preds = %18, %14
%27 = load double, double* %4
ret double %27
}

LLVM IR (-O2):
define double @multi_apply(double (double)* nocapture %0, i32 %1, double %2) {
%4 = icmp sgt i32 %1, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp eq i32 %1, 1
br i1 %7, label %8, label %11
8: ; preds = %3, %11
%9 = phi double [ %13, %11 ], [ %2, %3 ]
%10 = tail call double %0(double %9)
ret double %10
11: ; preds = %3
%12 = add nsw i32 %1, -1
%13 = tail call double @multi_apply(double (double)* %0, i32 %12, double %2)
br label %8
}