#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ prints(char *, long double *, unsigned long);
int /*<<< orphan*/ sprintf(char *, char *, long double, long double, char *);
void gnuplot_script(long double *X, long double *degrees, unsigned long size,
                    FILE *outfile) {
  char script[1000] = "";
  char function[1000] = "";
  prints(function, degrees, size);
  sprintf(
      script,
      "reset\nset grid\nset xrange[%.4Lf:%.4Lf]\nf(x) = %splot f(x) with lines",
      X[0], X[size - 1], function);
  fprintf(outfile, script);
}


x86 assembly (clang, -O0):
<gnuplot_script>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x410(%rbp),%rdi
mov    %rdi,-0x808(%rbp)
xor    %esi,%esi
mov    %esi,-0x81c(%rbp)
mov    $0x3e8,%edx
mov    %rdx,-0x818(%rbp)
call   1030 <memset@plt>
mov    -0x81c(%rbp),%esi
mov    -0x818(%rbp),%rdx
lea    -0x800(%rbp),%rdi
mov    %rdi,-0x810(%rbp)
call   1030 <memset@plt>
mov    -0x810(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <prints@plt>
mov    -0x808(%rbp),%rdi
mov    -0x8(%rbp),%rcx
fldt   (%rcx)
mov    -0x18(%rbp),%rax
shl    $0x4,%rax
fldt   -0x10(%rax,%rcx,1)
lea    -0x800(%rbp),%rdx
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
lea    0xe1b(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1040 <fprintf@plt>
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gnuplot_script>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7f8,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r13
lea    0x410(%rsp),%r15
mov    $0x3e8,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
lea    0x20(%rsp),%rbp
mov    $0x3e8,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <prints@plt>
fldt   0x0(%r13)
shl    $0x4,%rbx
fldt   -0x10(%rbx,%r13,1)
fstpt  0x10(%rsp)
fstpt  (%rsp)
lea    0xe4f(%rip),%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
call   1060 <sprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x7f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [69 x i8] c"reset\0Aset grid\0Aset xrange[%.4Lf:%.4Lf]\0Af(x) = %splot f(x) with lines\00"
define void @gnuplot_script(x86_fp80* %0, x86_fp80* %1, i64 %2, i32* %3) {
%5 = alloca x86_fp80*
%6 = alloca x86_fp80*
%7 = alloca i64
%8 = alloca i32*
%9 = alloca [1000 x i8]
%10 = alloca [1000 x i8]
store x86_fp80* %0, x86_fp80** %5
store x86_fp80* %1, x86_fp80** %6
store i64 %2, i64* %7
store i32* %3, i32** %8
%11 = bitcast [1000 x i8]* %9 to i8*
%12 = bitcast [1000 x i8]* %10 to i8*
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%14 = load x86_fp80*, x86_fp80** %6
%15 = load i64, i64* %7
%16 = call i32 @prints(i8* %13, x86_fp80* %14, i64 %15)
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%18 = load x86_fp80*, x86_fp80** %5
%19 = getelementptr inbounds x86_fp80, x86_fp80* %18, i64 0
%20 = load x86_fp80, x86_fp80* %19
%21 = load x86_fp80*, x86_fp80** %5
%22 = load i64, i64* %7
%23 = sub i64 %22, 1
%24 = getelementptr inbounds x86_fp80, x86_fp80* %21, i64 %23
%25 = load x86_fp80, x86_fp80* %24
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %10, i64 0, i64 0
%27 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), x86_fp80 %20, x86_fp80 %25, i8* %26)
%28 = load i32*, i32** %8
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%30 = call i32 @fprintf(i32* %28, i8* %29)
ret void
}

LLVM IR (-O2):
@.str = [69 x i8] c"reset\0Aset grid\0Aset xrange[%.4Lf:%.4Lf]\0Af(x) = %splot f(x) with lines\00"
define void @gnuplot_script(x86_fp80* nocapture %0, x86_fp80* %1, i64 %2, i32* nocapture %3) {
%5 = alloca [1000 x i8]
%6 = alloca [1000 x i8]
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%9 = call i32 @prints(i8* %8, x86_fp80* %1, i64 %2)
%10 = load x86_fp80, x86_fp80* %0
%11 = add i64 %2, -1
%12 = getelementptr inbounds x86_fp80, x86_fp80* %0, i64 %11
%13 = load x86_fp80, x86_fp80* %12
%14 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), x86_fp80 %10, x86_fp80 %13, i8* %8)
%15 = call i32 @fprintf(i32* %3, i8* %7)
ret void
}