#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*/ printf(char *, double, ...);
void printPolynomial(double C[], int degree) {
  int hasPreviousTerms = 0;
  if (degree == 0) {
    printf("%f", C[0]);
    hasPreviousTerms = 1;
  } else {
    if (C[0] != 0) {
      printf("%f", C[0]);
      hasPreviousTerms = 1;
    }
  }
  int term;
  for (term = 1; term <= degree; term++) {
    if (C[term] != 0) {
      if (hasPreviousTerms) {
        printf(" + %f * x^%d", C[term], term);
      } else {
        printf("%f * x^%d", C[term], term);
        hasPreviousTerms = 1;
      }
    }
  }
}


x86 assembly (clang, -O0):
<printPolynomial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1152 <printPolynomial+0x42>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xec1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    1194 <printPolynomial+0x84>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1172 <printPolynomial+0x62>
jp     1172 <printPolynomial+0x62>
jmp    118f <printPolynomial+0x7f>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
lea    0xe7f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    1194 <printPolynomial+0x84>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1236 <printPolynomial+0x126>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11cc <printPolynomial+0xbc>
jp     11cc <printPolynomial+0xbc>
jmp    1223 <printPolynomial+0x113>
cmpl   $0x0,-0x10(%rbp)
je     11f9 <printPolynomial+0xe9>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x14(%rbp),%esi
lea    0xe16(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    121e <printPolynomial+0x10e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x14(%rbp),%esi
lea    0xdf6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    1223 <printPolynomial+0x113>
jmp    1228 <printPolynomial+0x118>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119b <printPolynomial+0x8b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printPolynomial>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
movsd  (%rdi),%xmm0
test   %esi,%esi
je     114d <printPolynomial+0x3d>
mov    %esi,%r15d
mov    %rdi,%r14
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1133 <printPolynomial+0x23>
jnp    1164 <printPolynomial+0x54>
lea    0xece(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%eax
test   %r15d,%r15d
jg     116b <printPolynomial+0x5b>
jmp    11c4 <printPolynomial+0xb4>
lea    0xeb4(%rip),%rdi
mov    $0x1,%al
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <printf@plt>
xor    %eax,%eax
test   %r15d,%r15d
jle    11c4 <printPolynomial+0xb4>
add    $0x1,%r15d
mov    $0x1,%ebx
lea    0xe93(%rip),%r12
lea    0xe89(%rip),%r13
jmp    1199 <printPolynomial+0x89>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r15
je     11c4 <printPolynomial+0xb4>
movsd  (%r14,%rbx,8),%xmm0
ucomisd 0xe59(%rip),%xmm0
jne    11ab <printPolynomial+0x9b>
jnp    1190 <printPolynomial+0x80>
test   %eax,%eax
mov    %r13,%rdi
cmove  %r12,%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x1,%eax
jmp    1190 <printPolynomial+0x80>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
@.str.1 = [13 x i8] c" + %f * x^%d\00"
@.str.2 = [10 x i8] c"%f * x^%d\00"
define void @printPolynomial(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load double*, double** %3
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
%13 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %12)
store i32 1, i32* %5
br label %25
14: ; preds = %2
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = fcmp une double %17, 0.000000e+00
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load double*, double** %3
%21 = getelementptr inbounds double, double* %20, i64 0
%22 = load double, double* %21
%23 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %22)
store i32 1, i32* %5
br label %24
24: ; preds = %19, %14
br label %25
25: ; preds = %24, %9
store i32 1, i32* %6
br label %26
26: ; preds = %58, %25
%27 = load i32, i32* %6
%28 = load i32, i32* %4
%29 = icmp sle i32 %27, %28
br i1 %29, label %30, label %61
30: ; preds = %26
%31 = load double*, double** %3
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = fcmp une double %35, 0.000000e+00
br i1 %36, label %37, label %57
37: ; preds = %30
%38 = load i32, i32* %5
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %37
%41 = load double*, double** %3
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
%45 = load double, double* %44
%46 = load i32, i32* %6
%47 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %45, i32 %46)
br label %56
48: ; preds = %37
%49 = load double*, double** %3
%50 = load i32, i32* %6
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = load i32, i32* %6
%55 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %53, i32 %54)
store i32 1, i32* %5
br label %56
56: ; preds = %48, %40
br label %57
57: ; preds = %56, %30
br label %58
58: ; preds = %57
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %26
61: ; preds = %26
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
@.str.1 = [13 x i8] c" + %f * x^%d\00"
@.str.2 = [10 x i8] c"%f * x^%d\00"
define void @printPolynomial(double* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
%4 = load double, double* %0
br i1 %3, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %4)
br label %32
7: ; preds = %2
%8 = fcmp une double %4, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %4)
br label %11
11: ; preds = %7, %9
%12 = phi i32 [ 1, %9 ], [ 0, %7 ]
%13 = icmp slt i32 %1, 1
br i1 %13, label %32, label %14
14: ; preds = %11
%15 = add nuw i32 %1, 1
%16 = zext i32 %15 to i64
br label %17
17: ; preds = %14, %28
%18 = phi i64 [ 1, %14 ], [ %30, %28 ]
%19 = phi i32 [ %12, %14 ], [ %29, %28 ]
%20 = getelementptr inbounds double, double* %0, i64 %18
%21 = load double, double* %20
%22 = fcmp une double %21, 0.000000e+00
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = icmp eq i32 %19, 0
%25 = trunc i64 %18 to i32
%26 = select i1 %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0)
%27 = tail call i32 (i8*, double, ...) @printf(i8* %26, double %21, i32 %25)
br label %28
28: ; preds = %23, %17
%29 = phi i32 [ %19, %17 ], [ 1, %23 ]
%30 = add nuw nsw i64 %18, 1
%31 = icmp eq i64 %30, %16
br i1 %31, label %32, label %17
32: ; preds = %28, %5, %11
ret void
}