#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 *malloc(int);
int /*<<< orphan*/ printInfo(double *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ readEquation(double *, int);
int /*<<< orphan*/ readEquationCmd(double *, char **, int);
int /*<<< orphan*/ scanf(char *, int *);
int makeEquation(double *equation, char **in, int degree) {
  if (degree > 1) {
    equation = malloc((degree + 1) * sizeof(double));
    readEquationCmd(equation, in, degree);
  } else {
    printf("%s", "Degree? ");
    scanf("%d", &degree);
    if (degree < 1)
      return 0;
    equation = malloc((degree + 1) * sizeof(double));
    readEquation(equation, degree);
    putchar('\n');
  }
  printInfo(equation, degree);
  return degree;
}


x86 assembly (clang, -O0):
<makeEquation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jle    11b9 <makeEquation+0x49>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1060 <readEquationCmd@plt>
jmp    121f <makeEquation+0xaf>
lea    0xe40(%rip),%rdi
lea    0xe3c(%rip),%rsi
call   1050 <printf@plt>
lea    0xe39(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1080 <scanf@plt>
cmpl   $0x1,-0x1c(%rbp)
jge    11f2 <makeEquation+0x82>
movl   $0x0,-0x4(%rbp)
jmp    1231 <makeEquation+0xc1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <readEquation@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1090 <printInfo@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeEquation>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,0xc(%rsp)
cmp    $0x2,%edx
jl     11a5 <makeEquation+0x35>
mov    %edx,%ebx
mov    %rsi,%r15
lea    0x8(,%rbx,8),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1060 <readEquationCmd@plt>
jmp    11f8 <makeEquation+0x88>
lea    0xe54(%rip),%rdi
lea    0xe50(%rip),%rsi
call   1050 <printf@plt>
lea    0xe4d(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    1208 <makeEquation+0x98>
lea    0x8(,%rbx,8),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %ebx,%esi
call   1040 <readEquation@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1090 <printInfo@plt>
mov    0xc(%rsp),%eax
jmp    120a <makeEquation+0x9a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [9 x i8] c"Degree? \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @makeEquation(double* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i8**
%7 = alloca i32
store double* %0, double** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %21
10: ; preds = %3
%11 = load i32, i32* %7
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 8
%15 = trunc i64 %14 to i32
%16 = call double* @malloc(i32 %15)
store double* %16, double** %5
%17 = load double*, double** %5
%18 = load i8**, i8*** %6
%19 = load i32, i32* %7
%20 = call i32 @readEquationCmd(double* %17, i8** %18, i32 %19)
br label %38
21: ; preds = %3
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 1
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 0, i32* %4
br label %43
27: ; preds = %21
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = mul i64 %30, 8
%32 = trunc i64 %31 to i32
%33 = call double* @malloc(i32 %32)
store double* %33, double** %5
%34 = load double*, double** %5
%35 = load i32, i32* %7
%36 = call i32 @readEquation(double* %34, i32 %35)
%37 = call i32 @putchar(i8 signext 10)
br label %38
38: ; preds = %27, %10
%39 = load double*, double** %5
%40 = load i32, i32* %7
%41 = call i32 @printInfo(double* %39, i32 %40)
%42 = load i32, i32* %7
store i32 %42, i32* %4
br label %43
43: ; preds = %38, %26
%44 = load i32, i32* %4
ret i32 %44
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [9 x i8] c"Degree? \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @makeEquation(double* nocapture readnone %0, i8** %1, i32 %2) {
%4 = alloca i32
store i32 %2, i32* %4
%5 = icmp sgt i32 %2, 1
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = shl i32 %2, 3
%8 = add i32 %7, 8
%9 = tail call double* @malloc(i32 %8)
%10 = tail call i32 @readEquationCmd(double* %9, i8** %1, i32 %2)
br label %23
11: ; preds = %3
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 1
br i1 %15, label %28, label %16
16: ; preds = %11
%17 = shl i32 %14, 3
%18 = add i32 %17, 8
%19 = call double* @malloc(i32 %18)
%20 = call i32 @readEquation(double* %19, i32 %14)
%21 = call i32 @putchar(i8 signext 10)
%22 = load i32, i32* %4
br label %23
23: ; preds = %16, %6
%24 = phi i32 [ %2, %6 ], [ %22, %16 ]
%25 = phi double* [ %9, %6 ], [ %19, %16 ]
%26 = call i32 @printInfo(double* %25, i32 %24)
%27 = load i32, i32* %4
br label %28
28: ; preds = %11, %23
%29 = phi i32 [ %27, %23 ], [ 0, %11 ]
ret i32 %29
}