#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 */
float cosf(float);
float sinf(float);
float *vec2_rotate(float *result, float *a, float angle) {
  float cs = cosf(angle);
  float sn = sinf(angle);
  float x = a[0];
  float y = a[1];
  result[0] = x * cs - y * sn;
  result[1] = x * sn + y * cs;
  return result;
}


x86 assembly (clang, -O0):
<vec2_rotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
movss  -0x18(%rbp),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  -0x1c(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x20(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  -0x18(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec2_rotate>:
push   %r14
push   %rbx
push   %rax
movss  %xmm0,(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <cosf@plt>
movss  %xmm0,0x4(%rsp)
movss  (%rsp),%xmm0
call   1030 <sinf@plt>
movss  (%rbx),%xmm1
movss  0x4(%rbx),%xmm2
movaps %xmm1,%xmm3
mulss  %xmm0,%xmm1
mulss  %xmm2,%xmm0
movss  0x4(%rsp),%xmm4
mulss  %xmm4,%xmm3
subss  %xmm0,%xmm3
movss  %xmm3,(%r14)
mulss  %xmm2,%xmm4
addss  %xmm4,%xmm1
movss  %xmm1,0x4(%r14)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define float* @vec2_rotate(float* %0, float* %1, float %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float* %0, float** %4
store float* %1, float** %5
store float %2, float* %6
%11 = load float, float* %6
%12 = call float @cosf(float %11)
store float %12, float* %7
%13 = load float, float* %6
%14 = call float @sinf(float %13)
store float %14, float* %8
%15 = load float*, float** %5
%16 = getelementptr inbounds float, float* %15, i64 0
%17 = load float, float* %16
store float %17, float* %9
%18 = load float*, float** %5
%19 = getelementptr inbounds float, float* %18, i64 1
%20 = load float, float* %19
store float %20, float* %10
%21 = load float, float* %9
%22 = load float, float* %7
%23 = load float, float* %10
%24 = load float, float* %8
%25 = fmul float %23, %24
%26 = fneg float %25
%27 = call float @llvm.fmuladd.f32(float %21, float %22, float %26)
%28 = load float*, float** %4
%29 = getelementptr inbounds float, float* %28, i64 0
store float %27, float* %29
%30 = load float, float* %9
%31 = load float, float* %8
%32 = load float, float* %10
%33 = load float, float* %7
%34 = fmul float %32, %33
%35 = call float @llvm.fmuladd.f32(float %30, float %31, float %34)
%36 = load float*, float** %4
%37 = getelementptr inbounds float, float* %36, i64 1
store float %35, float* %37
%38 = load float*, float** %4
ret float* %38
}

LLVM IR (-O2):
define float* @vec2_rotate(float* returned writeonly %0, float* nocapture %1, float %2) {
%4 = tail call float @cosf(float %2)
%5 = tail call float @sinf(float %2)
%6 = load float, float* %1
%7 = getelementptr inbounds float, float* %1, i64 1
%8 = load float, float* %7
%9 = fneg float %8
%10 = fmul float %5, %9
%11 = tail call float @llvm.fmuladd.f32(float %6, float %4, float %10)
store float %11, float* %0
%12 = fmul float %4, %8
%13 = tail call float @llvm.fmuladd.f32(float %6, float %5, float %12)
%14 = getelementptr inbounds float, float* %0, i64 1
store float %13, float* %14
ret float* %0
}