#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 EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int sin(int);
int /*<<< orphan*/ svg_draw_to_file_xy(int /*<<< orphan*/ *, char *, double *,
                                       double *, int, char *, char *, int,
                                       int /*<<< orphan*/);
int main(int argc, char **argv) {
  int size = 410, i;
  double *data = (double *)malloc(sizeof(double) * size);
  double *x = (double *)malloc(sizeof(double) * size);
  FILE *f;
  for (i = 0; i < size; ++i) {
    data[i] = 50 + 50 * sin(i * 0.03);
    x[i] = i;
  }
  f = fopen("sin.svg", "w");
  svg_draw_to_file_xy(f, "#ff0000", data, x, size, "x", "sin(x)", 2, 0);
  fclose(f);
  free(data);
  free(x);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x19a,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1207 <main+0xa7>
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xe3d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
imul   $0x32,%eax,%eax
add    $0x32,%eax
cvtsi2sd %eax,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11aa <main+0x4a>
lea    0xdfa(%rip),%rdi
lea    0xdfb(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xddd(%rip),%rsi
lea    0xdde(%rip),%r9
lea    0xdd9(%rip),%rax
xor    %r10d,%r10d
mov    %rax,(%rsp)
movl   $0x2,0x8(%rsp)
movl   $0x0,0x10(%rsp)
call   1070 <svg_draw_to_file_xy@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0xcd0,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    $0xcd0,%edi
call   1060 <malloc@plt>
mov    %rax,%r12
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe5b(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
imul   $0x32,%eax,%eax
add    $0x32,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
lea    0x1(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r12,%rbx,8)
movapd %xmm1,%xmm0
mulsd  0xe13(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sin@plt>
imul   $0x32,%eax,%eax
add    $0x32,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%r14,%rbx,8)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%r12,%rbx,8)
add    $0x2,%rbx
cmp    $0x19a,%rbx
jne    1190 <main+0x30>
lea    0xdd9(%rip),%rdi
lea    0xdda(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
sub    $0x8,%rsp
lea    0xdd3(%rip),%rax
lea    0xdc2(%rip),%rsi
lea    0xdc3(%rip),%r9
mov    %r15,%rdi
mov    %r14,%rdx
mov    %r12,%rcx
mov    $0x19a,%r8d
push   $0x0
push   $0x2
push   %rax
call   1070 <svg_draw_to_file_xy@plt>
add    $0x20,%rsp
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"sin.svg\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [8 x i8] c"#ff0000\00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [7 x i8] c"sin(x)\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 410, i32* %6
%11 = load i32, i32* %6
%12 = sext i32 %11 to i64
%13 = mul i64 8, %12
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to double*
store double* %16, double** %8
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = mul i64 8, %18
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to double*
store double* %22, double** %9
store i32 0, i32* %7
br label %23
23: ; preds = %46, %2
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %49
27: ; preds = %23
%28 = load i32, i32* %7
%29 = sitofp i32 %28 to double
%30 = fmul double %29, 3.000000e-02
%31 = fptosi double %30 to i32
%32 = call i32 @sin(i32 %31)
%33 = mul nsw i32 50, %32
%34 = add nsw i32 50, %33
%35 = sitofp i32 %34 to double
%36 = load double*, double** %8
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
store double %35, double* %39
%40 = load i32, i32* %7
%41 = sitofp i32 %40 to double
%42 = load double*, double** %9
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
store double %41, double* %45
br label %46
46: ; preds = %27
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %23
49: ; preds = %23
%50 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %50, i32** %10
%51 = load i32*, i32** %10
%52 = load double*, double** %8
%53 = load double*, double** %9
%54 = load i32, i32* %6
%55 = call i32 @svg_draw_to_file_xy(i32* %51, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double* %52, double* %53, i32 %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 2, i32 0)
%56 = load i32*, i32** %10
%57 = call i32 @fclose(i32* %56)
%58 = load double*, double** %8
%59 = call i32 @free(double* %58)
%60 = load double*, double** %9
%61 = call i32 @free(double* %60)
%62 = load i32, i32* @EXIT_SUCCESS
ret i32 %62
}

LLVM IR (-O2):
@.str = [8 x i8] c"sin.svg\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [8 x i8] c"#ff0000\00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [7 x i8] c"sin(x)\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 3280)
%4 = inttoptr i64 %3 to double*
%5 = tail call i64 @malloc(i32 3280)
%6 = inttoptr i64 %5 to double*
br label %7
7: ; preds = %7, %2
%8 = phi i64 [ 0, %2 ], [ %30, %7 ]
%9 = trunc i64 %8 to i32
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 3.000000e-02
%12 = fptosi double %11 to i32
%13 = tail call i32 @sin(i32 %12)
%14 = mul nsw i32 %13, 50
%15 = add nsw i32 %14, 50
%16 = sitofp i32 %15 to double
%17 = getelementptr inbounds double, double* %4, i64 %8
store double %16, double* %17
%18 = getelementptr inbounds double, double* %6, i64 %8
store double %10, double* %18
%19 = or i64 %8, 1
%20 = trunc i64 %19 to i32
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 3.000000e-02
%23 = fptosi double %22 to i32
%24 = tail call i32 @sin(i32 %23)
%25 = mul nsw i32 %24, 50
%26 = add nsw i32 %25, 50
%27 = sitofp i32 %26 to double
%28 = getelementptr inbounds double, double* %4, i64 %19
store double %27, double* %28
%29 = getelementptr inbounds double, double* %6, i64 %19
store double %21, double* %29
%30 = add nuw nsw i64 %8, 2
%31 = icmp eq i64 %30, 410
br i1 %31, label %32, label %7
32: ; preds = %7
%33 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%34 = tail call i32 @svg_draw_to_file_xy(i32* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double* %4, double* %6, i32 410, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 2, i32 0)
%35 = tail call i32 @fclose(i32* %33)
%36 = tail call i32 @free(double* %4)
%37 = tail call i32 @free(double* %6)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}