#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(int);
double pow(double, double);
int /*<<< orphan*/ printf(char *, ...);
void imagine_root(int CoeffA, int CoeffB, double discrim) {
  double root;
  double root_b;
  root = (pow(abs(discrim), 0.5)) / (2.0 * abs(CoeffA));
  root_b = (-1.0 * CoeffB) / (2.0 * CoeffA);
  printf("Roots are %.3lf + %.3lfi ", root_b, root);
  printf("and %.3lf - %.3lfi", root_b, root);
  printf("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n\n");
  return;
}


x86 assembly (clang, -O0):
<imagine_root>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%edi
call   1030 <abs@plt>
movsd  0xebb(%rip),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <abs@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe77(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x4(%rbp),%xmm2
movsd  0xe5e(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe58(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe5a(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imagine_root>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
cvttsd2si %xmm0,%edi
call   1040 <abs@plt>
movsd  0xea5(%rip),%xmm1
call   1060 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1040 <abs@plt>
addsd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
xorpd  0xe80(%rip),%xmm0
cvtsi2sd %ebp,%xmm2
addsd  %xmm2,%xmm2
divsd  %xmm2,%xmm0
movapd %xmm0,0x10(%rsp)
lea    0xe77(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xe83(%rip),%rdi
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Roots are %.3lf + %.3lfi \00"
@.str.1 = [19 x i8] c"and %.3lf - %.3lfi\00"
@.str.2 = [49 x i8] c"\0A-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\0A\0A\00"
define void @imagine_root(i32 %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store double %2, double* %6
%9 = load double, double* %6
%10 = fptosi double %9 to i32
%11 = call double @abs(i32 %10)
%12 = call double @pow(double %11, double 5.000000e-01)
%13 = load i32, i32* %4
%14 = call double @abs(i32 %13)
%15 = fmul double 2.000000e+00, %14
%16 = fdiv double %12, %15
store double %16, double* %7
%17 = load i32, i32* %5
%18 = sitofp i32 %17 to double
%19 = fmul double -1.000000e+00, %18
%20 = load i32, i32* %4
%21 = sitofp i32 %20 to double
%22 = fmul double 2.000000e+00, %21
%23 = fdiv double %19, %22
store double %23, double* %8
%24 = load double, double* %8
%25 = load double, double* %7
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double %24, double %25)
%27 = load double, double* %8
%28 = load double, double* %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %27, double %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Roots are %.3lf + %.3lfi \00"
@.str.1 = [19 x i8] c"and %.3lf - %.3lfi\00"
@str = [48 x i8] c"\0A-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\0A\00"
define void @imagine_root(i32 %0, i32 %1, double %2) {
%4 = fptosi double %2 to i32
%5 = tail call double @abs(i32 %4)
%6 = tail call double @pow(double %5, double 5.000000e-01)
%7 = tail call double @abs(i32 %0)
%8 = fmul double %7, 2.000000e+00
%9 = fdiv double %6, %8
%10 = sitofp i32 %1 to double
%11 = fneg double %10
%12 = sitofp i32 %0 to double
%13 = fmul double %12, 2.000000e+00
%14 = fdiv double %11, %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double %14, double %9)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %14, double %9)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
ret void
}