#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 M_PI;
double cos(double);
scalar_t__ rint(double);
double sin(double);
void RotateCoordinates(short *x, short *y, short center_x, short center_y,
                       short angle) {
  double r_angle;
  short x_coord, y_coord;
  r_angle = (angle / 64) * (M_PI / 180.0);
  x_coord = (short)(x[0] - center_x);
  y_coord = (short)(y[0] - center_y);
  x[0] = (short)(center_x + (short)(rint(cos(r_angle) * ((double)x_coord) +
                                         sin(r_angle) * (double)y_coord)));
  y[0] = (short)(center_y + (short)(rint(-sin(r_angle) * ((double)x_coord) +
                                         cos(r_angle) * (double)y_coord)));
}


x86 assembly (clang, -O0):
<RotateCoordinates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %r8w,%ax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %dx,-0x12(%rbp)
mov    %cx,-0x14(%rbp)
mov    %ax,-0x16(%rbp)
movswl -0x16(%rbp),%eax
mov    %eax,%ecx
add    $0x3f,%ecx
test   %eax,%eax
cmovs  %ecx,%eax
sar    $0x6,%eax
cvtsi2sd %eax,%xmm0
mov    0x2e7c(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe88(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movzwl (%rax),%eax
movzwl -0x12(%rbp),%ecx
sub    %ecx,%eax
mov    %ax,-0x22(%rbp)
mov    -0x10(%rbp),%rax
movzwl (%rax),%eax
movzwl -0x14(%rbp),%ecx
sub    %ecx,%eax
mov    %ax,-0x24(%rbp)
movzwl -0x12(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
movswl -0x22(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movswl -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <rint@plt>
mov    %rax,%rcx
mov    -0x3c(%rbp),%eax
add    %ecx,%eax
mov    %ax,%cx
mov    -0x8(%rbp),%rax
mov    %cx,(%rax)
movswl -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps 0xdec(%rip),%xmm1
pxor   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movswl -0x22(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movswl -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <rint@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%eax
movswl %cx,%ecx
add    %ecx,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %cx,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RotateCoordinates>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r15d
mov    %edx,%r13d
mov    %rsi,%r14
mov    %rdi,%r12
lea    0x3f(%r8),%eax
test   %r8w,%r8w
cmovns %r8d,%eax
cwtl
sar    $0x6,%eax
cvtsi2sd %eax,%xmm1
mov    0x2e83(%rip),%rax
movsd  (%rax),%xmm0
divsd  0xe8f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movzwl (%rdi),%ebx
sub    %edx,%ebx
movzwl (%rsi),%ebp
sub    %ecx,%ebp
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movswl %bx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movswl %bp,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x20(%rsp)
mulsd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
addsd  %xmm1,%xmm0
call   1040 <rint@plt>
add    %r13d,%eax
mov    %ax,(%r12)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
subsd  %xmm1,%xmm0
call   1040 <rint@plt>
add    %r15d,%eax
mov    %ax,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @RotateCoordinates(i16* %0, i16* %1, i16 signext %2, i16 signext %3, i16 signext %4) {
%6 = alloca i16*
%7 = alloca i16*
%8 = alloca i16
%9 = alloca i16
%10 = alloca i16
%11 = alloca double
%12 = alloca i16
%13 = alloca i16
store i16* %0, i16** %6
store i16* %1, i16** %7
store i16 %2, i16* %8
store i16 %3, i16* %9
store i16 %4, i16* %10
%14 = load i16, i16* %10
%15 = sext i16 %14 to i32
%16 = sdiv i32 %15, 64
%17 = sitofp i32 %16 to double
%18 = load double, double* @M_PI
%19 = fdiv double %18, 1.800000e+02
%20 = fmul double %17, %19
store double %20, double* %11
%21 = load i16*, i16** %6
%22 = getelementptr inbounds i16, i16* %21, i64 0
%23 = load i16, i16* %22
%24 = sext i16 %23 to i32
%25 = load i16, i16* %8
%26 = sext i16 %25 to i32
%27 = sub nsw i32 %24, %26
%28 = trunc i32 %27 to i16
store i16 %28, i16* %12
%29 = load i16*, i16** %7
%30 = getelementptr inbounds i16, i16* %29, i64 0
%31 = load i16, i16* %30
%32 = sext i16 %31 to i32
%33 = load i16, i16* %9
%34 = sext i16 %33 to i32
%35 = sub nsw i32 %32, %34
%36 = trunc i32 %35 to i16
store i16 %36, i16* %13
%37 = load i16, i16* %8
%38 = sext i16 %37 to i32
%39 = load double, double* %11
%40 = call double @cos(double %39)
%41 = load i16, i16* %12
%42 = sitofp i16 %41 to double
%43 = load double, double* %11
%44 = call double @sin(double %43)
%45 = load i16, i16* %13
%46 = sitofp i16 %45 to double
%47 = fmul double %44, %46
%48 = call double @llvm.fmuladd.f64(double %40, double %42, double %47)
%49 = call i64 @rint(double %48)
%50 = trunc i64 %49 to i16
%51 = sext i16 %50 to i32
%52 = add nsw i32 %38, %51
%53 = trunc i32 %52 to i16
%54 = load i16*, i16** %6
%55 = getelementptr inbounds i16, i16* %54, i64 0
store i16 %53, i16* %55
%56 = load i16, i16* %9
%57 = sext i16 %56 to i32
%58 = load double, double* %11
%59 = call double @sin(double %58)
%60 = fneg double %59
%61 = load i16, i16* %12
%62 = sitofp i16 %61 to double
%63 = load double, double* %11
%64 = call double @cos(double %63)
%65 = load i16, i16* %13
%66 = sitofp i16 %65 to double
%67 = fmul double %64, %66
%68 = call double @llvm.fmuladd.f64(double %60, double %62, double %67)
%69 = call i64 @rint(double %68)
%70 = trunc i64 %69 to i16
%71 = sext i16 %70 to i32
%72 = add nsw i32 %57, %71
%73 = trunc i32 %72 to i16
%74 = load i16*, i16** %7
%75 = getelementptr inbounds i16, i16* %74, i64 0
store i16 %73, i16* %75
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @RotateCoordinates(i16* nocapture %0, i16* nocapture %1, i16 signext %2, i16 signext %3, i16 signext %4) {
%6 = sdiv i16 %4, 64
%7 = sitofp i16 %6 to double
%8 = load double, double* @M_PI
%9 = fdiv double %8, 1.800000e+02
%10 = fmul double %9, %7
%11 = load i16, i16* %0
%12 = sub i16 %11, %2
%13 = load i16, i16* %1
%14 = sub i16 %13, %3
%15 = tail call double @cos(double %10)
%16 = sitofp i16 %12 to double
%17 = tail call double @sin(double %10)
%18 = sitofp i16 %14 to double
%19 = fmul double %17, %18
%20 = tail call double @llvm.fmuladd.f64(double %15, double %16, double %19)
%21 = tail call i64 @rint(double %20)
%22 = trunc i64 %21 to i16
%23 = add i16 %22, %2
store i16 %23, i16* %0
%24 = tail call double @sin(double %10)
%25 = fneg double %24
%26 = tail call double @cos(double %10)
%27 = fmul double %26, %18
%28 = tail call double @llvm.fmuladd.f64(double %25, double %16, double %27)
%29 = tail call i64 @rint(double %28)
%30 = trunc i64 %29 to i16
%31 = add i16 %30, %3
store i16 %31, i16* %1
ret void
}