#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 *bessjtable(double, int *, int);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ printf(char *, ...);
double strtod(char *, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int N, i, offset;
  double *bessj, x;
  x = strtod(argv[1], NULL);
  printf("x = %f\n", x);
  printf("-------------------------------\n");
  bessj = bessjtable(x, &N, -15);
  offset = (N - 1) / 2;
  for (i = 0; i < N; i++)
    printf("J_%-4d =  % 11.8f\n", i - offset, bessj[i]);
  free(bessj);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtod@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe88(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    -0x14(%rbp),%rdi
mov    $0xfffffff1,%esi
call   1060 <bessjtable@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f7 <main+0xb7>
mov    -0x18(%rbp),%esi
sub    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe47(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11bc <main+0x7c>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%rdi
xor    %esi,%esi
call   1050 <strtod@plt>
movsd  %xmm0,0x10(%rsp)
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
lea    0xc(%rsp),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0xfffffff1,%esi
call   1070 <bessjtable@plt>
mov    %rax,%r15
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11f2 <main+0xa2>
mov    %eax,%ecx
add    $0xffffffff,%ecx
shr    $0x1f,%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
sar    %eax
neg    %eax
mov    %eax,%r12d
xor    %ebx,%ebx
lea    0xe45(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r12,%rbx,1),%esi
movsd  (%r15,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11d0 <main+0x80>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"x = %f\0A\00"
@.str.1 = [33 x i8] c"-------------------------------\0A\00"
@.str.2 = [19 x i8] c"J_%-4d = % 11.8f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call double @strtod(i8* %13, i32* null)
store double %14, double* %10
%15 = load double, double* %10
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%18 = load double, double* %10
%19 = call double* @bessjtable(double %18, i32* %6, i32 -15)
store double* %19, double** %9
%20 = load i32, i32* %6
%21 = sub nsw i32 %20, 1
%22 = sdiv i32 %21, 2
store i32 %22, i32* %8
store i32 0, i32* %7
br label %23
23: ; preds = %37, %2
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %40
27: ; preds = %23
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = sub nsw i32 %28, %29
%31 = load double*, double** %9
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %30, double %35)
br label %37
37: ; preds = %27
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %23
40: ; preds = %23
%41 = load double*, double** %9
%42 = call i32 @free(double* %41)
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [8 x i8] c"x = %f\0A\00"
@.str.2 = [19 x i8] c"J_%-4d = % 11.8f\0A\00"
@str = [32 x i8] c"-------------------------------\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call double @strtod(i8* nocapture %6, i32* null)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %7)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%10 = call double* @bessjtable(double %7, i32* %3, i32 -15)
%11 = load i32, i32* %3
%12 = add nsw i32 %11, -1
%13 = sdiv i32 %12, -2
%14 = icmp sgt i32 %11, 0
br i1 %14, label %15, label %26
15: ; preds = %2, %15
%16 = phi i64 [ %22, %15 ], [ 0, %2 ]
%17 = trunc i64 %16 to i32
%18 = add i32 %13, %17
%19 = getelementptr inbounds double, double* %10, i64 %16
%20 = load double, double* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %18, double %20)
%22 = add nuw nsw i64 %16, 1
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %15, label %26
26: ; preds = %15, %2
%27 = call i32 @free(double* %10)
ret i32 0
}