#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 abs(double);
double pole(double, double);
int /*<<< orphan*/ printf(char *, ...);
double calka(double a, double b, double delta) {
  double c = (a + b) / 2.0;
  double S = pole(a, b);
  printf("%f,%f S1\n", a, c);
  double S1 = pole(a, c);
  printf("\n");
  printf("%f,%f S2\n", c, b);
  double S2 = pole(c, b);
  printf("\n");
  if (abs((S1 + S2) - S) < delta)
    return S;
  return calka(a, c, delta / 2) + calka(c, b, delta / 2);
}


x86 assembly (clang, -O0):
<calka>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe97(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <pole@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe71(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1050 <pole@plt>
movsd  %xmm0,-0x38(%rbp)
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe41(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <pole@plt>
movsd  %xmm0,-0x40(%rbp)
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x38(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1030 <abs@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    122f <calka+0xef>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1285 <calka+0x145>
movsd  -0x10(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  0xdba(%rip),%xmm3
divsd  %xmm3,%xmm2
call   1060 <calka@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  0xd95(%rip),%xmm3
divsd  %xmm3,%xmm2
call   1060 <calka@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calka>:
sub    $0x38,%rsp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
mulsd  0xe8a(%rip),%xmm2
movsd  %xmm2,(%rsp)
call   1060 <pole@plt>
movsd  %xmm0,0x20(%rsp)
lea    0xe7b(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1060 <pole@plt>
movsd  %xmm0,0x30(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe4c(%rip),%rdi
movsd  (%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1060 <pole@plt>
movsd  %xmm0,0x28(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
movsd  0x28(%rsp),%xmm0
addsd  0x30(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
call   1040 <abs@plt>
movsd  0x10(%rsp),%xmm2
ucomisd %xmm0,%xmm2
movsd  0x20(%rsp),%xmm0
ja     1261 <calka+0x111>
mulsd  0xdd7(%rip),%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1070 <calka@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1070 <calka@plt>
addsd  0x8(%rsp),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%f,%f S1\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [10 x i8] c"%f,%f S2\0A\00"
define double @calka(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%12 = load double, double* %5
%13 = load double, double* %6
%14 = fadd double %12, %13
%15 = fdiv double %14, 2.000000e+00
store double %15, double* %8
%16 = load double, double* %5
%17 = load double, double* %6
%18 = call double @pole(double %16, double %17)
store double %18, double* %9
%19 = load double, double* %5
%20 = load double, double* %8
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %19, double %20)
%22 = load double, double* %5
%23 = load double, double* %8
%24 = call double @pole(double %22, double %23)
store double %24, double* %10
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = load double, double* %8
%27 = load double, double* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %26, double %27)
%29 = load double, double* %8
%30 = load double, double* %6
%31 = call double @pole(double %29, double %30)
store double %31, double* %11
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%33 = load double, double* %10
%34 = load double, double* %11
%35 = fadd double %33, %34
%36 = load double, double* %9
%37 = fsub double %35, %36
%38 = call double @abs(double %37)
%39 = load double, double* %7
%40 = fcmp olt double %38, %39
br i1 %40, label %41, label %43
41: ; preds = %3
%42 = load double, double* %9
store double %42, double* %4
br label %55
43: ; preds = %3
%44 = load double, double* %5
%45 = load double, double* %8
%46 = load double, double* %7
%47 = fdiv double %46, 2.000000e+00
%48 = call double @calka(double %44, double %45, double %47)
%49 = load double, double* %8
%50 = load double, double* %6
%51 = load double, double* %7
%52 = fdiv double %51, 2.000000e+00
%53 = call double @calka(double %49, double %50, double %52)
%54 = fadd double %48, %53
store double %54, double* %4
br label %55
55: ; preds = %43, %41
%56 = load double, double* %4
ret double %56
}

LLVM IR (-O2):
@.str = [10 x i8] c"%f,%f S1\0A\00"
@.str.2 = [10 x i8] c"%f,%f S2\0A\00"
define double @calka(double %0, double %1, double %2) {
%4 = fadd double %0, %1
%5 = fmul double %4, 5.000000e-01
%6 = tail call double @pole(double %0, double %1)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %0, double %5)
%8 = tail call double @pole(double %0, double %5)
%9 = tail call i32 @putchar(i32 10)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %5, double %1)
%11 = tail call double @pole(double %5, double %1)
%12 = tail call i32 @putchar(i32 10)
%13 = fadd double %8, %11
%14 = fsub double %13, %6
%15 = tail call double @abs(double %14)
%16 = fcmp olt double %15, %2
br i1 %16, label %17, label %19
17: ; preds = %3, %19
%18 = phi double [ %23, %19 ], [ %6, %3 ]
ret double %18
19: ; preds = %3
%20 = fmul double %2, 5.000000e-01
%21 = tail call double @calka(double %0, double %5, double %20)
%22 = tail call double @calka(double %5, double %1, double %20)
%23 = fadd double %21, %22
br label %17
}