#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 *calloc(int, int);
double cosh(int);
int sqrt(double);
double *calc_theta_exact(double delta_x, double beta, int N) {
  int i;
  double *theta_exact = calloc(N, sizeof(double));
  double count;
  for (i = 0, count = 0.0; i < N; i++, count += delta_x)
    theta_exact[i] = cosh(sqrt(beta) * (1 - count)) / cosh(sqrt(beta));
  return theta_exact;
}


x86 assembly (clang, -O0):
<calc_theta_exact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e5 <calc_theta_exact+0xb5>
movsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe79(%rip),%xmm1
subsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <cosh@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1030 <cosh@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1165 <calc_theta_exact+0x35>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_theta_exact>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
test   %ebp,%ebp
jle    11dd <calc_theta_exact+0xad>
mov    %ebp,%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm0
call   1050 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe76(%rip),%xmm1
subsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <cosh@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1030 <cosh@plt>
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
add    $0x1,%rbx
movsd  (%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
cmp    %rbx,%rbp
jne    1170 <calc_theta_exact+0x40>
mov    %r14,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double* @calc_theta_exact(double %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca double
store double %0, double* %4
store double %1, double* %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = call double* @calloc(i32 %10, i32 8)
store double* %11, double** %8
store i32 0, i32* %7
store double 0.000000e+00, double* %9
br label %12
12: ; preds = %33, %3
%13 = load i32, i32* %7
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %39
16: ; preds = %12
%17 = load double, double* %5
%18 = call i32 @sqrt(double %17)
%19 = sitofp i32 %18 to double
%20 = load double, double* %9
%21 = fsub double 1.000000e+00, %20
%22 = fmul double %19, %21
%23 = fptosi double %22 to i32
%24 = call double @cosh(i32 %23)
%25 = load double, double* %5
%26 = call i32 @sqrt(double %25)
%27 = call double @cosh(i32 %26)
%28 = fdiv double %24, %27
%29 = load double*, double** %8
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
store double %28, double* %32
br label %33
33: ; preds = %16
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
%36 = load double, double* %4
%37 = load double, double* %9
%38 = fadd double %37, %36
store double %38, double* %9
br label %12
39: ; preds = %12
%40 = load double*, double** %8
ret double* %40
}

LLVM IR (-O2):
define noalias double* @calc_theta_exact(double %0, double %1, i32 %2) {
%4 = tail call double* @calloc(i32 %2, i32 8)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %24
6: ; preds = %3
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %21, %8 ]
%10 = phi double [ 0.000000e+00, %6 ], [ %22, %8 ]
%11 = tail call i32 @sqrt(double %1)
%12 = sitofp i32 %11 to double
%13 = fsub double 1.000000e+00, %10
%14 = fmul double %13, %12
%15 = fptosi double %14 to i32
%16 = tail call double @cosh(i32 %15)
%17 = tail call i32 @sqrt(double %1)
%18 = tail call double @cosh(i32 %17)
%19 = fdiv double %16, %18
%20 = getelementptr inbounds double, double* %4, i64 %9
store double %19, double* %20
%21 = add nuw nsw i64 %9, 1
%22 = fadd double %10, %0
%23 = icmp eq i64 %21, %7
br i1 %23, label %24, label %8
24: ; preds = %8, %3
ret double* %4
}