#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 fabs(double);
double func(double, double, int);
double what_wave(double angle, int var) {
  double a = 480, b = 780, eps = 1;
  while (fabs(b - a) > eps) {
    a = b - (b - a) * func(b, angle, var) /
                (func(b, angle, var) - func(a, angle, var));
    b = a - (a - b) * func(a, angle, var) /
                (func(a, angle, var) - func(b, angle, var));
  }
  return b;
}


x86 assembly (clang, -O0):
<what_wave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movsd  0xee8(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xed3(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xebe(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movaps 0xec8(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    127c <what_wave+0x16c>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mov    -0xc(%rbp),%edi
call   1030 <func@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mov    -0xc(%rbp),%edi
call   1030 <func@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mov    -0xc(%rbp),%edi
call   1030 <func@plt>
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x50(%rbp),%xmm0
subsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mov    -0xc(%rbp),%edi
call   1030 <func@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mov    -0xc(%rbp),%edi
call   1030 <func@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
mov    -0xc(%rbp),%edi
call   1030 <func@plt>
movsd  -0x40(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x30(%rbp),%xmm0
subsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1147 <what_wave+0x37>
movsd  -0x20(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<what_wave>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
movsd  %xmm0,(%rsp)
movsd  0xedc(%rip),%xmm0
movsd  0xedc(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xed6(%rip),%xmm2
nopw   0x0(%rax,%rax,1)
movapd %xmm2,0x10(%rsp)
movsd  %xmm0,0x28(%rsp)
movsd  (%rsp),%xmm1
mov    %ebx,%edi
call   1030 <func@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %ebx,%edi
call   1030 <func@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %ebx,%edi
call   1030 <func@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm2
divsd  %xmm1,%xmm2
movsd  0x28(%rsp),%xmm1
movapd %xmm1,%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  (%rsp),%xmm1
mov    %ebx,%edi
call   1030 <func@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %ebx,%edi
call   1030 <func@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x28(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %ebx,%edi
call   1030 <func@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm2
divsd  %xmm1,%xmm2
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
subsd  %xmm2,%xmm0
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movapd %xmm2,%xmm1
andpd  0xde4(%rip),%xmm1
ucomisd 0xdd4(%rip),%xmm1
ja     1140 <what_wave+0x30>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @what_wave(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
store double 4.800000e+02, double* %5
store double 7.800000e+02, double* %6
store double 1.000000e+00, double* %7
br label %8
8: ; preds = %15, %2
%9 = load double, double* %6
%10 = load double, double* %5
%11 = fsub double %9, %10
%12 = call double @llvm.fabs.f64(double %11)
%13 = load double, double* %7
%14 = fcmp ogt double %12, %13
br i1 %14, label %15, label %56
15: ; preds = %8
%16 = load double, double* %6
%17 = load double, double* %6
%18 = load double, double* %5
%19 = fsub double %17, %18
%20 = load double, double* %6
%21 = load double, double* %3
%22 = load i32, i32* %4
%23 = call double @func(double %20, double %21, i32 %22)
%24 = fmul double %19, %23
%25 = load double, double* %6
%26 = load double, double* %3
%27 = load i32, i32* %4
%28 = call double @func(double %25, double %26, i32 %27)
%29 = load double, double* %5
%30 = load double, double* %3
%31 = load i32, i32* %4
%32 = call double @func(double %29, double %30, i32 %31)
%33 = fsub double %28, %32
%34 = fdiv double %24, %33
%35 = fsub double %16, %34
store double %35, double* %5
%36 = load double, double* %5
%37 = load double, double* %5
%38 = load double, double* %6
%39 = fsub double %37, %38
%40 = load double, double* %5
%41 = load double, double* %3
%42 = load i32, i32* %4
%43 = call double @func(double %40, double %41, i32 %42)
%44 = fmul double %39, %43
%45 = load double, double* %5
%46 = load double, double* %3
%47 = load i32, i32* %4
%48 = call double @func(double %45, double %46, i32 %47)
%49 = load double, double* %6
%50 = load double, double* %3
%51 = load i32, i32* %4
%52 = call double @func(double %49, double %50, i32 %51)
%53 = fsub double %48, %52
%54 = fdiv double %44, %53
%55 = fsub double %36, %54
store double %55, double* %6
br label %8
56: ; preds = %8
%57 = load double, double* %6
ret double %57
}

LLVM IR (-O2):
define double @what_wave(double %0, i32 %1) {
br label %3
3: ; preds = %2, %3
%4 = phi double [ 3.000000e+02, %2 ], [ %22, %3 ]
%5 = phi double [ 4.800000e+02, %2 ], [ %13, %3 ]
%6 = phi double [ 7.800000e+02, %2 ], [ %21, %3 ]
%7 = tail call double @func(double %6, double %0, i32 %1)
%8 = fmul double %4, %7
%9 = tail call double @func(double %6, double %0, i32 %1)
%10 = tail call double @func(double %5, double %0, i32 %1)
%11 = fsub double %9, %10
%12 = fdiv double %8, %11
%13 = fsub double %6, %12
%14 = fsub double %13, %6
%15 = tail call double @func(double %13, double %0, i32 %1)
%16 = fmul double %15, %14
%17 = tail call double @func(double %13, double %0, i32 %1)
%18 = tail call double @func(double %6, double %0, i32 %1)
%19 = fsub double %17, %18
%20 = fdiv double %16, %19
%21 = fsub double %13, %20
%22 = fsub double %21, %13
%23 = tail call double @llvm.fabs.f64(double %22)
%24 = fcmp ogt double %23, 1.000000e+00
br i1 %24, label %3, label %25
25: ; preds = %3
ret double %21
}