#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
double scale_to_x_origin(int);
int scale_to_y_pixel(int /*<<< orphan*/);
int /*<<< orphan*/ sin(double);
int *getCoordinates() {
  int x = 0;
  int *yCords = (int *)malloc(sizeof(int) * 640);
  memset(yCords, 0, 640);
  for (x = 0; x < 640; ++x) {
    double float_x = scale_to_x_origin(x);
    yCords[x] = scale_to_y_pixel(sin(float_x));
  }
  return yCords;
}


x86 assembly (clang, -O0):
<getCoordinates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa00,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x280,%edx
call   1040 <memset@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x280,-0x4(%rbp)
jge    11ca <getCoordinates+0x7a>
mov    -0x4(%rbp),%edi
call   1030 <scale_to_x_origin@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <sin@plt>
mov    %eax,%edi
call   1070 <scale_to_y_pixel@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1184 <getCoordinates+0x34>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCoordinates>:
push   %r14
push   %rbx
push   %rax
mov    $0xa00,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
xor    %ebx,%ebx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x280,%edx
call   1040 <memset@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <scale_to_x_origin@plt>
call   1050 <sin@plt>
mov    %eax,%edi
call   1070 <scale_to_y_pixel@plt>
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    $0x280,%rbx
jne    1180 <getCoordinates+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32* @getCoordinates() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca double
store i32 0, i32* %1
%4 = call i64 @malloc(i32 2560)
%5 = inttoptr i64 %4 to i32*
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = call i32 @memset(i32* %6, i32 0, i32 640)
store i32 0, i32* %1
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 640
br i1 %10, label %11, label %24
11: ; preds = %8
%12 = load i32, i32* %1
%13 = call double @scale_to_x_origin(i32 %12)
store double %13, double* %3
%14 = load double, double* %3
%15 = call i32 @sin(double %14)
%16 = call i32 @scale_to_y_pixel(i32 %15)
%17 = load i32*, i32** %2
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
store i32 %16, i32* %20
br label %21
21: ; preds = %11
%22 = load i32, i32* %1
%23 = add nsw i32 %22, 1
store i32 %23, i32* %1
br label %8
24: ; preds = %8
%25 = load i32*, i32** %2
ret i32* %25
}

LLVM IR (-O2):
define i32* @getCoordinates() {
%1 = tail call i64 @malloc(i32 2560)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i32 @memset(i32* %2, i32 0, i32 640)
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %11, %4 ]
%6 = trunc i64 %5 to i32
%7 = tail call double @scale_to_x_origin(i32 %6)
%8 = tail call i32 @sin(double %7)
%9 = tail call i32 @scale_to_y_pixel(i32 %8)
%10 = getelementptr inbounds i32, i32* %2, i64 %5
store i32 %9, i32* %10
%11 = add nuw nsw i64 %5, 1
%12 = icmp eq i64 %11, 640
br i1 %12, label %13, label %4
13: ; preds = %4
ret i32* %2
}