#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 *, ...);
void printX(double *mtr, int len, char asInt) {
  int x = len - 1;
  for (int i = 0; i < len; i++) {
    if (asInt == '1')
      printf("%d*x^%d", (int)mtr[i], x--);
    else
      printf("%lf*x^%d", mtr[i], x--);
    if (i < len - 1)
      printf(" + ");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d0 <printX+0xc0>
movsbl -0xd(%rbp),%eax
cmp    $0x31,%eax
jne    1178 <printX+0x68>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%esi
mov    -0x14(%rbp),%edx
mov    %edx,%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <printX+0x8e>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x14(%rbp),%esi
mov    %esi,%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
lea    0xe71(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11bd <printX+0xad>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c2 <printX+0xb2>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1134 <printX+0x24>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printX>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11b5 <printX+0x95>
mov    %edx,%r14d
mov    %rdi,%rbx
lea    -0x1(%rsi),%ebp
mov    %ebp,%r15d
mov    %esi,%r12d
neg    %r12
xor    %r13d,%r13d
jmp    115f <printX+0x3f>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
add    $0xffffffff,%ebp
mov    %r12,%rax
add    %r13,%rax
je     11b5 <printX+0x95>
movsd  (%rbx,%r13,8),%xmm0
cmp    $0x31,%r14b
jne    1190 <printX+0x70>
cvttsd2si %xmm0,%esi
lea    0xe8a(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r15,%r13
jae    1150 <printX+0x30>
jmp    11a5 <printX+0x85>
cs nopw 0x0(%rax,%rax,1)
lea    0xe71(%rip),%rdi
mov    %ebp,%esi
mov    $0x1,%al
call   1040 <printf@plt>
cmp    %r15,%r13
jae    1150 <printX+0x30>
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1150 <printX+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%d*x^%d\00"
@.str.1 = [9 x i8] c"%lf*x^%d\00"
@.str.2 = [4 x i8] c" + \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @printX(double* %0, i32 %1, i8 signext %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%9 = load i32, i32* %5
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %7
store i32 0, i32* %8
br label %11
11: ; preds = %46, %3
%12 = load i32, i32* %8
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %49
15: ; preds = %11
%16 = load i8, i8* %6
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 49
br i1 %18, label %19, label %29
19: ; preds = %15
%20 = load double*, double** %4
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = fptosi double %24 to i32
%26 = load i32, i32* %7
%27 = add nsw i32 %26, -1
store i32 %27, i32* %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %26)
br label %38
29: ; preds = %15
%30 = load double*, double** %4
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = load i32, i32* %7
%36 = add nsw i32 %35, -1
store i32 %36, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %34, i32 %35)
br label %38
38: ; preds = %29, %19
%39 = load i32, i32* %8
%40 = load i32, i32* %5
%41 = sub nsw i32 %40, 1
%42 = icmp slt i32 %39, %41
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %43, %38
br label %46
46: ; preds = %45
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %11
49: ; preds = %11
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d*x^%d\00"
@.str.1 = [9 x i8] c"%lf*x^%d\00"
@.str.2 = [4 x i8] c" + \00"
define void @printX(double* nocapture %0, i32 %1, i8 signext %2) {
%4 = add nsw i32 %1, -1
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = icmp eq i8 %2, 49
%8 = zext i32 %4 to i64
%9 = zext i32 %1 to i64
br label %12
10: ; preds = %27, %3
%11 = tail call i32 @putchar(i32 10)
ret void
12: ; preds = %6, %27
%13 = phi i64 [ 0, %6 ], [ %28, %27 ]
%14 = phi i32 [ %4, %6 ], [ %23, %27 ]
%15 = getelementptr inbounds double, double* %0, i64 %13
%16 = load double, double* %15
br i1 %7, label %17, label %20
17: ; preds = %12
%18 = fptosi double %16 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %14)
br label %22
20: ; preds = %12
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %16, i32 %14)
br label %22
22: ; preds = %20, %17
%23 = add nsw i32 %14, -1
%24 = icmp ult i64 %13, %8
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %22, %25
%28 = add nuw nsw i64 %13, 1
%29 = icmp eq i64 %28, %9
br i1 %29, label %10, label %12
}