#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 *, ...);
int /*<<< orphan*/ scanf(char *, double *);
void getCoefficients(double coef[], int length) {
  printf("Give the %d coefficients and constant: \n", length - 1);
  int exponent = length;
  int i;
  for (i = 0; i < length; ++i) {
    if (i == length - 1)
      printf(">> Constant: ");
    else
      printf(">> Coefficient of x^%d = ", --exponent);
    scanf("%lf", &coef[i]);
  }
}


x86 assembly (clang, -O0):
<getCoefficients>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c0 <getCoefficients+0xa0>
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1180 <getCoefficients+0x60>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1197 <getCoefficients+0x77>
mov    -0x10(%rbp),%esi
add    $0xffffffff,%esi
mov    %esi,-0x10(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xea4(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <getCoefficients+0x30>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCoefficients>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
lea    -0x1(%rbx),%ebp
lea    0xec6(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
jle    119d <getCoefficients+0x7d>
mov    %ebp,%ebp
mov    %ebx,%r15d
shl    $0x3,%rbp
shl    $0x3,%r15
lea    0xef6(%rip),%r12
xor    %r13d,%r13d
jmp    1188 <getCoefficients+0x68>
add    $0xffffffff,%ebx
lea    0xecd(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    (%r14,%r13,1),%rsi
mov    %r12,%rdi
call   1040 <scanf@plt>
add    $0x8,%r13
cmp    %r13,%r15
je     119d <getCoefficients+0x7d>
cmp    %r13,%rbp
jne    1160 <getCoefficients+0x40>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1173 <getCoefficients+0x53>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Give the %d coefficients and constant: \0A\00"
@.str.1 = [14 x i8] c">> Constant: \00"
@.str.2 = [26 x i8] c">> Coefficient of x^%d = \00"
@.str.3 = [4 x i8] c"%lf\00"
define void @getCoefficients(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
%7 = load i32, i32* %4
%8 = sub nsw i32 %7, 1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %4
store i32 %10, i32* %5
store i32 0, i32* %6
br label %11
11: ; preds = %32, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %35
15: ; preds = %11
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = sub nsw i32 %17, 1
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %26
22: ; preds = %15
%23 = load i32, i32* %5
%24 = add nsw i32 %23, -1
store i32 %24, i32* %5
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %22, %20
%27 = load double*, double** %3
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %11
35: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"Give the %d coefficients and constant: \0A\00"
@.str.1 = [14 x i8] c">> Constant: \00"
@.str.2 = [26 x i8] c">> Coefficient of x^%d = \00"
@.str.3 = [4 x i8] c"%lf\00"
define void @getCoefficients(double* %0, i32 %1) {
%3 = add nsw i32 %1, -1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %24
6: ; preds = %2
%7 = zext i32 %3 to i64
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %6, %18
%10 = phi i64 [ 0, %6 ], [ %22, %18 ]
%11 = phi i32 [ %1, %6 ], [ %19, %18 ]
%12 = icmp eq i64 %10, %7
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %18
15: ; preds = %9
%16 = add nsw i32 %11, -1
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %15, %13
%19 = phi i32 [ %11, %13 ], [ %16, %15 ]
%20 = getelementptr inbounds double, double* %0, i64 %10
%21 = tail call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %20)
%22 = add nuw nsw i64 %10, 1
%23 = icmp eq i64 %22, %8
br i1 %23, label %24, label %9
24: ; preds = %18, %2
ret void
}