#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*/ acos(double);
double fabs(int /*<<< orphan*/);
int maximum(int, int);
double pow(int, int);
int /*<<< orphan*/ printf(char *, double, double, double);
double sqrt(double);
double calculTheta(double coeffX, int exposantX, double coeffY, int exposantY) {
  double theta = 0, coeffTemp = 0;
  int exposantTempA = 0, exposantTempB = 0;
  exposantTempA = maximum(exposantX, exposantY);
  if (exposantX == exposantTempA) {
    exposantTempB = 2 * exposantY - 2 * exposantTempA;
    coeffTemp = pow(coeffX, 2) + pow(coeffY, 2) * pow(10, exposantTempB);
  } else {
    exposantTempB = 2 * exposantX - 2 * exposantTempA;
    coeffTemp = pow(coeffX, 2) * pow(10, -2 * exposantTempA) + pow(coeffY, 2);
  }
  coeffTemp = sqrt(coeffTemp);
  printf("Calcul du theta : %lf, %lf, %lf\n", coeffX, coeffTemp,
         (coeffX / coeffTemp) * pow(10, exposantX - exposantTempA));
  theta = fabs(acos((coeffX / coeffTemp) * pow(10, exposantX - exposantTempA)));
  if (coeffY < 0)
    theta = -theta;
  return theta;
}


x86 assembly (clang, -O0):
<calculTheta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <maximum@plt>
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x34(%rbp),%eax
jne    1218 <calculTheta+0xb8>
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    -0x34(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
cvttsd2si -0x8(%rbp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
cvttsd2si -0x18(%rbp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x38(%rbp),%esi
mov    $0xa,%edi
call   1070 <pow@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    127c <calculTheta+0x11c>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    -0x34(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
cvttsd2si -0x8(%rbp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  %xmm0,-0x50(%rbp)
imul   $0xfffffffe,-0x34(%rbp),%esi
mov    $0xa,%edi
call   1070 <pow@plt>
movsd  %xmm0,-0x58(%rbp)
cvttsd2si -0x18(%rbp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  -0x58(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0xc(%rbp),%esi
sub    -0x34(%rbp),%esi
mov    $0xa,%edi
call   1070 <pow@plt>
movsd  -0x78(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm3,%xmm2
lea    0xd25(%rip),%rdi
call   1040 <printf@plt>
movsd  -0x8(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0xc(%rbp),%esi
sub    -0x34(%rbp),%esi
mov    $0xa,%edi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <acos@plt>
mov    %eax,%edi
call   1060 <fabs@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    134b <calculTheta+0x1eb>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculTheta>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %esi,%ebp
movaps %xmm1,0x20(%rsp)
mov    %edi,%ebx
movsd  %xmm0,0x18(%rsp)
call   1030 <maximum@plt>
mov    %eax,%r14d
cmp    %ebx,%eax
jne    11d1 <calculTheta+0x71>
sub    %ebx,%ebp
add    %ebp,%ebp
cvttsd2si 0x18(%rsp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  %xmm0,0x8(%rsp)
cvttsd2si 0x20(%rsp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0xa,%edi
mov    %ebp,%esi
call   1070 <pow@plt>
movapd %xmm0,%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
jmp    121d <calculTheta+0xbd>
cvttsd2si 0x18(%rsp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  %xmm0,0x8(%rsp)
lea    (%r14,%r14,1),%esi
neg    %esi
mov    $0xa,%edi
call   1070 <pow@plt>
movsd  %xmm0,0x10(%rsp)
cvttsd2si 0x20(%rsp),%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     1230 <calculTheta+0xd0>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    1239 <calculTheta+0xd9>
movapd %xmm1,%xmm0
call   1080 <sqrt@plt>
movsd  0x18(%rsp),%xmm1
movsd  %xmm0,0x10(%rsp)
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
sub    %r14d,%ebx
mov    $0xa,%edi
mov    %ebx,%esi
call   1070 <pow@plt>
movapd %xmm0,%xmm2
mulsd  0x8(%rsp),%xmm2
lea    0xda9(%rip),%rdi
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1040 <printf@plt>
mov    $0xa,%edi
mov    %ebx,%esi
call   1070 <pow@plt>
mulsd  0x8(%rsp),%xmm0
call   1050 <acos@plt>
mov    %eax,%edi
call   1060 <fabs@plt>
movapd 0xd5a(%rip),%xmm1
xorpd  %xmm0,%xmm1
movapd 0x20(%rsp),%xmm3
cmpltsd 0xd57(%rip),%xmm3
movapd %xmm3,%xmm2
andnpd %xmm0,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
movapd %xmm3,%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Calcul du theta : %lf, %lf, %lf\0A\00"
define double @calculTheta(double %0, i32 %1, double %2, i32 %3) {
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
store double %0, double* %5
store i32 %1, i32* %6
store double %2, double* %7
store i32 %3, i32* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store i32 0, i32* %11
store i32 0, i32* %12
%13 = load i32, i32* %6
%14 = load i32, i32* %8
%15 = call i32 @maximum(i32 %13, i32 %14)
store i32 %15, i32* %11
%16 = load i32, i32* %6
%17 = load i32, i32* %11
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %4
%20 = load i32, i32* %8
%21 = mul nsw i32 2, %20
%22 = load i32, i32* %11
%23 = mul nsw i32 2, %22
%24 = sub nsw i32 %21, %23
store i32 %24, i32* %12
%25 = load double, double* %5
%26 = fptosi double %25 to i32
%27 = call double @pow(i32 %26, i32 2)
%28 = load double, double* %7
%29 = fptosi double %28 to i32
%30 = call double @pow(i32 %29, i32 2)
%31 = load i32, i32* %12
%32 = call double @pow(i32 10, i32 %31)
%33 = call double @llvm.fmuladd.f64(double %30, double %32, double %27)
store double %33, double* %10
br label %50
34: ; preds = %4
%35 = load i32, i32* %6
%36 = mul nsw i32 2, %35
%37 = load i32, i32* %11
%38 = mul nsw i32 2, %37
%39 = sub nsw i32 %36, %38
store i32 %39, i32* %12
%40 = load double, double* %5
%41 = fptosi double %40 to i32
%42 = call double @pow(i32 %41, i32 2)
%43 = load i32, i32* %11
%44 = mul nsw i32 -2, %43
%45 = call double @pow(i32 10, i32 %44)
%46 = load double, double* %7
%47 = fptosi double %46 to i32
%48 = call double @pow(i32 %47, i32 2)
%49 = call double @llvm.fmuladd.f64(double %42, double %45, double %48)
store double %49, double* %10
br label %50
50: ; preds = %34, %19
%51 = load double, double* %10
%52 = call double @sqrt(double %51)
store double %52, double* %10
%53 = load double, double* %5
%54 = load double, double* %10
%55 = load double, double* %5
%56 = load double, double* %10
%57 = fdiv double %55, %56
%58 = load i32, i32* %6
%59 = load i32, i32* %11
%60 = sub nsw i32 %58, %59
%61 = call double @pow(i32 10, i32 %60)
%62 = fmul double %57, %61
%63 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %53, double %54, double %62)
%64 = load double, double* %5
%65 = load double, double* %10
%66 = fdiv double %64, %65
%67 = load i32, i32* %6
%68 = load i32, i32* %11
%69 = sub nsw i32 %67, %68
%70 = call double @pow(i32 10, i32 %69)
%71 = fmul double %66, %70
%72 = call i32 @acos(double %71)
%73 = call double @fabs(i32 %72)
store double %73, double* %9
%74 = load double, double* %7
%75 = fcmp olt double %74, 0.000000e+00
br i1 %75, label %76, label %79
76: ; preds = %50
%77 = load double, double* %9
%78 = fneg double %77
store double %78, double* %9
br label %79
79: ; preds = %76, %50
%80 = load double, double* %9
ret double %80
}

LLVM IR (-O2):
@.str = [33 x i8] c"Calcul du theta : %lf, %lf, %lf\0A\00"
define double @calculTheta(double %0, i32 %1, double %2, i32 %3) {
%5 = tail call i32 @maximum(i32 %1, i32 %3)
%6 = icmp eq i32 %5, %1
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = sub nsw i32 %3, %1
%9 = shl nsw i32 %8, 1
%10 = fptosi double %0 to i32
%11 = tail call double @pow(i32 %10, i32 2)
%12 = fptosi double %2 to i32
%13 = tail call double @pow(i32 %12, i32 2)
%14 = tail call double @pow(i32 10, i32 %9)
%15 = tail call double @llvm.fmuladd.f64(double %13, double %14, double %11)
br label %24
16: ; preds = %4
%17 = fptosi double %0 to i32
%18 = tail call double @pow(i32 %17, i32 2)
%19 = mul nsw i32 %5, -2
%20 = tail call double @pow(i32 10, i32 %19)
%21 = fptosi double %2 to i32
%22 = tail call double @pow(i32 %21, i32 2)
%23 = tail call double @llvm.fmuladd.f64(double %18, double %20, double %22)
br label %24
24: ; preds = %16, %7
%25 = phi double [ %15, %7 ], [ %23, %16 ]
%26 = tail call double @sqrt(double %25)
%27 = fdiv double %0, %26
%28 = sub nsw i32 %1, %5
%29 = tail call double @pow(i32 10, i32 %28)
%30 = fmul double %27, %29
%31 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %0, double %26, double %30)
%32 = tail call double @pow(i32 10, i32 %28)
%33 = fmul double %27, %32
%34 = tail call i32 @acos(double %33)
%35 = tail call double @fabs(i32 %34)
%36 = fcmp olt double %2, 0.000000e+00
%37 = fneg double %35
%38 = select i1 %36, double %37, double %35
ret double %38
}