#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 fun1(float);
float fun(int n) {
  float sum = 1, i;
  int tmp = 1;
  for (i = 2; i <= n; i++, tmp = -tmp)
    sum = sum + tmp * fun1(i) / i;
  return sum;
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movss  0xee1(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm1
cvtsi2ssl -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     11a7 <fun+0x97>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fun1@plt>
movss  -0x18(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   %ecx,%eax
cvtsi2ss %eax,%xmm1
divss  -0xc(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xe74(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
xor    %eax,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    113c <fun+0x2c>
movss  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jge    1124 <fun+0x14>
movss  0xede(%rip),%xmm1
jmp    1197 <fun+0x87>
cvtsi2ss %edi,%xmm0
movss  %xmm0,0x4(%rsp)
movss  0xeca(%rip),%xmm1
movss  0xec6(%rip),%xmm2
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  %xmm2,0x8(%rsp)
movss  %xmm1,0xc(%rsp)
movaps %xmm2,%xmm0
call   1030 <fun1@plt>
movss  0x8(%rsp),%xmm2
movss  0xc(%rsp),%xmm1
imul   %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
divss  %xmm2,%xmm0
addss  %xmm0,%xmm1
addss  0xe76(%rip),%xmm2
neg    %ebx
movss  0x4(%rsp),%xmm0
ucomiss %xmm2,%xmm0
jae    1150 <fun+0x40>
movaps %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @fun(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store i32 %0, i32* %2
store float 1.000000e+00, float* %3
store i32 1, i32* %5
store float 2.000000e+00, float* %4
br label %6
6: ; preds = %21, %1
%7 = load float, float* %4
%8 = load i32, i32* %2
%9 = sitofp i32 %8 to float
%10 = fcmp ole float %7, %9
br i1 %10, label %11, label %26
11: ; preds = %6
%12 = load float, float* %3
%13 = load i32, i32* %5
%14 = load float, float* %4
%15 = call i32 @fun1(float %14)
%16 = mul nsw i32 %13, %15
%17 = sitofp i32 %16 to float
%18 = load float, float* %4
%19 = fdiv float %17, %18
%20 = fadd float %12, %19
store float %20, float* %3
br label %21
21: ; preds = %11
%22 = load float, float* %4
%23 = fadd float %22, 1.000000e+00
store float %23, float* %4
%24 = load i32, i32* %5
%25 = sub nsw i32 0, %24
store i32 %25, i32* %5
br label %6
26: ; preds = %6
%27 = load float, float* %3
ret float %27
}

LLVM IR (-O2):
define float @fun(i32 %0) {
%2 = sitofp i32 %0 to float
%3 = icmp slt i32 %0, 2
br i1 %3, label %16, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %14, %4 ], [ 1, %1 ]
%6 = phi float [ %13, %4 ], [ 2.000000e+00, %1 ]
%7 = phi float [ %12, %4 ], [ 1.000000e+00, %1 ]
%8 = tail call i32 @fun1(float %6)
%9 = mul nsw i32 %8, %5
%10 = sitofp i32 %9 to float
%11 = fdiv float %10, %6
%12 = fadd float %7, %11
%13 = fadd float %6, 1.000000e+00
%14 = sub nsw i32 0, %5
%15 = fcmp ugt float %13, %2
br i1 %15, label %16, label %4
16: ; preds = %4, %1
%17 = phi float [ 1.000000e+00, %1 ], [ %12, %4 ]
ret float %17
}