#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 P_evaluate(double, long *, int);
int printf(char *, double);
int /*<<< orphan*/ putchar(char);
int root_test(double x, long *coefficients, int degree) {
  double result;
  register int i;
  if (x == 0.)
    return 0;
  result = P_evaluate(x, coefficients, degree);
  i = printf("f(x = %.4g)", x);
  if (i < 16)
    putchar('\t');
  printf("= %.8g\n", result);
  return (result == 0.);
}


x86 assembly (clang, -O0):
<root_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1168 <root_test+0x38>
jp     1168 <root_test+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <root_test+0xa3>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <P_evaluate@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe76(%rip),%rdi
call   1050 <printf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x10,-0x2c(%rbp)
jge    11a6 <root_test+0x76>
mov    $0x9,%edi
call   1030 <putchar@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<root_test>:
xor    %eax,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    113f <root_test+0xf>
jp     113f <root_test+0xf>
ret
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
call   1040 <P_evaluate@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xea5(%rip),%rdi
movsd  0x10(%rsp),%xmm0
call   1050 <printf@plt>
cmp    $0xf,%eax
jg     1175 <root_test+0x45>
mov    $0x9,%edi
call   1030 <putchar@plt>
lea    0xe90(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1050 <printf@plt>
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
cmpeqsd %xmm0,%xmm1
movq   %xmm1,%rax
and    $0x1,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"f(x = %.4g)\00"
@.str.1 = [8 x i8] c"= %.8g\0A\00"
define i32 @root_test(double %0, i64* %1, i32 %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca i64*
%7 = alloca i32
%8 = alloca double
%9 = alloca i32
store double %0, double* %5
store i64* %1, i64** %6
store i32 %2, i32* %7
%10 = load double, double* %5
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %3
store i32 0, i32* %4
br label %30
13: ; preds = %3
%14 = load double, double* %5
%15 = load i64*, i64** %6
%16 = load i32, i32* %7
%17 = call double @P_evaluate(double %14, i64* %15, i32 %16)
store double %17, double* %8
%18 = load double, double* %5
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %18)
store i32 %19, i32* %9
%20 = load i32, i32* %9
%21 = icmp slt i32 %20, 16
br i1 %21, label %22, label %24
22: ; preds = %13
%23 = call i32 @putchar(i8 signext 9)
br label %24
24: ; preds = %22, %13
%25 = load double, double* %8
%26 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %25)
%27 = load double, double* %8
%28 = fcmp oeq double %27, 0.000000e+00
%29 = zext i1 %28 to i32
store i32 %29, i32* %4
br label %30
30: ; preds = %24, %12
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
@.str = [12 x i8] c"f(x = %.4g)\00"
@.str.1 = [8 x i8] c"= %.8g\0A\00"
define i32 @root_test(double %0, i64* %1, i32 %2) {
%4 = fcmp oeq double %0, 0.000000e+00
br i1 %4, label %15, label %5
5: ; preds = %3
%6 = tail call double @P_evaluate(double %0, i64* %1, i32 %2)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double %0)
%8 = icmp slt i32 %7, 16
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @putchar(i8 signext 9)
br label %11
11: ; preds = %9, %5
%12 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %6)
%13 = fcmp oeq double %6, 0.000000e+00
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %3, %11
%16 = phi i32 [ %14, %11 ], [ 0, %3 ]
ret i32 %16
}