#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 M_PI;
int cos(int);
double *malloc(int);
double *nodes_txebitxev(int n, double a, double b) {
  double *x = malloc(sizeof(double) * n);
  int i = 0;
  for (i = 0; i < n; i++) {
    x[i] = a + (b - a) / 2 * (cos((2 * i + 1) * M_PI / (2 * n)) + 1);
  }
  return x;
}


x86 assembly (clang, -O0):
<nodes_txebitxev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11de <nodes_txebitxev+0xbe>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe82(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    0x2e51(%rip),%rcx
imul   (%rcx),%eax
mov    -0x4(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <cos@plt>
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
add    $0x1,%eax
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1156 <nodes_txebitxev+0x36>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nodes_txebitxev>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %edi,%r15d
lea    0x0(,%r15,8),%edi
call   1030 <malloc@plt>
mov    %rax,%r14
test   %r15d,%r15d
jle    11b7 <nodes_txebitxev+0x97>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mulsd  0xe9d(%rip),%xmm0
movsd  %xmm0,(%rsp)
mov    %r15d,%r12d
add    %r15d,%r15d
add    %r12,%r12
xor    %ebx,%ebx
mov    0x2e6e(%rip),%r13
nopw   0x0(%rax,%rax,1)
lea    0x1(%rbx),%eax
imul   0x0(%r13),%eax
cltd
idiv   %r15d
mov    %eax,%edi
call   1040 <cos@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,4)
add    $0x2,%rbx
cmp    %rbx,%r12
jne    1180 <nodes_txebitxev+0x60>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double* @nodes_txebitxev(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca i32
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = mul i64 8, %10
%12 = trunc i64 %11 to i32
%13 = call double* @malloc(i32 %12)
store double* %13, double** %7
store i32 0, i32* %8
store i32 0, i32* %8
br label %14
14: ; preds = %40, %3
%15 = load i32, i32* %8
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %43
18: ; preds = %14
%19 = load double, double* %5
%20 = load double, double* %6
%21 = load double, double* %5
%22 = fsub double %20, %21
%23 = fdiv double %22, 2.000000e+00
%24 = load i32, i32* %8
%25 = mul nsw i32 2, %24
%26 = add nsw i32 %25, 1
%27 = load i32, i32* @M_PI
%28 = mul nsw i32 %26, %27
%29 = load i32, i32* %4
%30 = mul nsw i32 2, %29
%31 = sdiv i32 %28, %30
%32 = call i32 @cos(i32 %31)
%33 = add nsw i32 %32, 1
%34 = sitofp i32 %33 to double
%35 = call double @llvm.fmuladd.f64(double %23, double %34, double %19)
%36 = load double*, double** %7
%37 = load i32, i32* %8
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
store double %35, double* %39
br label %40
40: ; preds = %18
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %14
43: ; preds = %14
%44 = load double*, double** %7
ret double* %44
}

LLVM IR (-O2):
@M_PI = global i32 0
define noalias double* @nodes_txebitxev(i32 %0, double %1, double %2) {
%4 = shl i32 %0, 3
%5 = tail call double* @malloc(i32 %4)
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %27
7: ; preds = %3
%8 = fsub double %2, %1
%9 = fmul double %8, 5.000000e-01
%10 = shl nuw nsw i32 %0, 1
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %25, %12 ]
%14 = load i32, i32* @M_PI
%15 = trunc i64 %13 to i32
%16 = shl i32 %15, 1
%17 = or i32 %16, 1
%18 = mul nsw i32 %14, %17
%19 = sdiv i32 %18, %10
%20 = tail call i32 @cos(i32 %19)
%21 = add nsw i32 %20, 1
%22 = sitofp i32 %21 to double
%23 = tail call double @llvm.fmuladd.f64(double %9, double %22, double %1)
%24 = getelementptr inbounds double, double* %5, i64 %13
store double %23, double* %24
%25 = add nuw nsw i64 %13, 1
%26 = icmp eq i64 %25, %11
br i1 %26, label %27, label %12
27: ; preds = %12, %3
ret double* %5
}