#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 acos(double);
double cos(double);
double sin(double);
double sqrt(double);
void graph_rotate_points(int *points, unsigned int no_of_points,
                         double centre_x, double centre_y, double orientation) {
  unsigned int i;
  double dx, dy, angle, dist, x, y;
  for (i = 0; i < no_of_points; i++) {
    dx = points[i * 2] - centre_x;
    dy = points[i * 2 + 1] - centre_y;
    dist = sqrt(dx * dx + dy * dy);
    if (dist > 0) {
      angle = acos(dy / dist);
      if (dx < 0)
        angle = (2 * 3.1415927) - angle;
      x = centre_x + (dist * sin(angle + orientation));
      y = centre_y + (dist * cos(angle + orientation));
      points[i * 2] = (int)x;
      points[i * 2 + 1] = (int)y;
    }
  }
}


x86 assembly (clang, -O0):
<graph_rotate_points>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    12d1 <graph_rotate_points+0x191>
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
cvtsi2sdl (%rax,%rcx,4),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
cvtsi2sdl (%rax,%rcx,4),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12be <graph_rotate_points+0x17e>
movsd  -0x40(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1219 <graph_rotate_points+0xd9>
movsd  0xdf1(%rip),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x80(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x70(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
cvttsd2si -0x58(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
mov    %edx,(%rax,%rcx,4)
cvttsd2si -0x60(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    %edx,(%rax,%rcx,4)
jmp    12c3 <graph_rotate_points+0x183>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1168 <graph_rotate_points+0x28>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<graph_rotate_points>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
movsd  %xmm2,0x30(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
test   %esi,%esi
je     12a2 <graph_rotate_points+0x162>
mov    %rdi,%r15
mov    %esi,%r14d
add    %r14,%r14
xor    %ebx,%ebx
jmp    118d <graph_rotate_points+0x4d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x2,%rbx
cmp    %rbx,%r14
je     12a2 <graph_rotate_points+0x162>
mov    %ebx,%r12d
xorps  %xmm2,%xmm2
cvtsi2sdl (%r15,%r12,4),%xmm2
subsd  0x10(%rsp),%xmm2
lea    0x1(%rbx),%r13d
xorps  %xmm3,%xmm3
cvtsi2sdl (%r15,%r13,4),%xmm3
subsd  0x18(%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
ucomisd 0xe3a(%rip),%xmm0
movapd %xmm2,0x20(%rsp)
jb     11f0 <graph_rotate_points+0xb0>
sqrtsd %xmm0,%xmm0
ucomisd 0xe26(%rip),%xmm0
jbe    1180 <graph_rotate_points+0x40>
jmp    120f <graph_rotate_points+0xcf>
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm3,0x8(%rsp)
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm3
ucomisd 0xdff(%rip),%xmm0
jbe    1180 <graph_rotate_points+0x40>
divsd  %xmm0,%xmm3
movsd  %xmm0,0x8(%rsp)
movapd %xmm3,%xmm0
call   1030 <acos@plt>
movsd  0xdd6(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd 0x20(%rsp),%xmm3
cmpltsd 0xdcb(%rip),%xmm3
movapd %xmm3,%xmm2
andnpd %xmm0,%xmm2
andpd  %xmm1,%xmm3
orpd   %xmm2,%xmm3
addsd  0x30(%rsp),%xmm3
movapd %xmm3,0x20(%rsp)
movapd %xmm3,%xmm0
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x38(%rsp)
movapd 0x20(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
cvttsd2si 0x38(%rsp),%eax
mov    %eax,(%r15,%r12,4)
cvttsd2si %xmm0,%eax
mov    %eax,(%r15,%r13,4)
jmp    1180 <graph_rotate_points+0x40>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @graph_rotate_points(i32* %0, i32 %1, double %2, double %3, double %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store i32* %0, i32** %6
store i32 %1, i32* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
store i32 0, i32* %11
br label %18
18: ; preds = %92, %5
%19 = load i32, i32* %11
%20 = load i32, i32* %7
%21 = icmp ult i32 %19, %20
br i1 %21, label %22, label %95
22: ; preds = %18
%23 = load i32*, i32** %6
%24 = load i32, i32* %11
%25 = mul i32 %24, 2
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %23, i64 %26
%28 = load i32, i32* %27
%29 = sitofp i32 %28 to double
%30 = load double, double* %8
%31 = fsub double %29, %30
store double %31, double* %12
%32 = load i32*, i32** %6
%33 = load i32, i32* %11
%34 = mul i32 %33, 2
%35 = add i32 %34, 1
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %32, i64 %36
%38 = load i32, i32* %37
%39 = sitofp i32 %38 to double
%40 = load double, double* %9
%41 = fsub double %39, %40
store double %41, double* %13
%42 = load double, double* %12
%43 = load double, double* %12
%44 = load double, double* %13
%45 = load double, double* %13
%46 = fmul double %44, %45
%47 = call double @llvm.fmuladd.f64(double %42, double %43, double %46)
%48 = call double @sqrt(double %47)
store double %48, double* %15
%49 = load double, double* %15
%50 = fcmp ogt double %49, 0.000000e+00
br i1 %50, label %51, label %91
51: ; preds = %22
%52 = load double, double* %13
%53 = load double, double* %15
%54 = fdiv double %52, %53
%55 = call double @acos(double %54)
store double %55, double* %14
%56 = load double, double* %12
%57 = fcmp olt double %56, 0.000000e+00
br i1 %57, label %58, label %61
58: ; preds = %51
%59 = load double, double* %14
%60 = fsub double 0x401921FB5A7ED197, %59
store double %60, double* %14
br label %61
61: ; preds = %58, %51
%62 = load double, double* %8
%63 = load double, double* %15
%64 = load double, double* %14
%65 = load double, double* %10
%66 = fadd double %64, %65
%67 = call double @sin(double %66)
%68 = call double @llvm.fmuladd.f64(double %63, double %67, double %62)
store double %68, double* %16
%69 = load double, double* %9
%70 = load double, double* %15
%71 = load double, double* %14
%72 = load double, double* %10
%73 = fadd double %71, %72
%74 = call double @cos(double %73)
%75 = call double @llvm.fmuladd.f64(double %70, double %74, double %69)
store double %75, double* %17
%76 = load double, double* %16
%77 = fptosi double %76 to i32
%78 = load i32*, i32** %6
%79 = load i32, i32* %11
%80 = mul i32 %79, 2
%81 = zext i32 %80 to i64
%82 = getelementptr inbounds i32, i32* %78, i64 %81
store i32 %77, i32* %82
%83 = load double, double* %17
%84 = fptosi double %83 to i32
%85 = load i32*, i32** %6
%86 = load i32, i32* %11
%87 = mul i32 %86, 2
%88 = add i32 %87, 1
%89 = zext i32 %88 to i64
%90 = getelementptr inbounds i32, i32* %85, i64 %89
store i32 %84, i32* %90
br label %91
91: ; preds = %61, %22
br label %92
92: ; preds = %91
%93 = load i32, i32* %11
%94 = add i32 %93, 1
store i32 %94, i32* %11
br label %18
95: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @graph_rotate_points(i32* nocapture %0, i32 %1, double %2, double %3, double %4) {
%6 = icmp eq i32 %1, 0
br i1 %6, label %44, label %7
7: ; preds = %5
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %41
%10 = phi i64 [ 0, %7 ], [ %42, %41 ]
%11 = trunc i64 %10 to i32
%12 = shl i32 %11, 1
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = load i32, i32* %14
%16 = sitofp i32 %15 to double
%17 = fsub double %16, %2
%18 = or i32 %12, 1
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %0, i64 %19
%21 = load i32, i32* %20
%22 = sitofp i32 %21 to double
%23 = fsub double %22, %3
%24 = fmul double %23, %23
%25 = tail call double @llvm.fmuladd.f64(double %17, double %17, double %24)
%26 = tail call double @sqrt(double %25)
%27 = fcmp ogt double %26, 0.000000e+00
br i1 %27, label %28, label %41
28: ; preds = %9
%29 = fdiv double %23, %26
%30 = tail call double @acos(double %29)
%31 = fcmp olt double %17, 0.000000e+00
%32 = fsub double 0x401921FB5A7ED197, %30
%33 = select i1 %31, double %32, double %30
%34 = fadd double %33, %4
%35 = tail call double @sin(double %34)
%36 = tail call double @llvm.fmuladd.f64(double %26, double %35, double %2)
%37 = tail call double @cos(double %34)
%38 = tail call double @llvm.fmuladd.f64(double %26, double %37, double %3)
%39 = fptosi double %36 to i32
store i32 %39, i32* %14
%40 = fptosi double %38 to i32
store i32 %40, i32* %20
br label %41
41: ; preds = %9, %28
%42 = add nuw nsw i64 %10, 1
%43 = icmp eq i64 %42, %8
br i1 %43, label %44, label %9
44: ; preds = %41, %5
ret void
}