#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 cos(double);
double sin(double);
void rotate2d(double **yvecs, int nmyvtxs, double theta) {
  double temp1;
  double c, s;
  int i;
  s = sin(theta);
  c = cos(theta);
  for (i = 1; i <= nmyvtxs; i++) {
    temp1 = yvecs[1][i];
    yvecs[1][i] = c * temp1 + s * yvecs[2][i];
    yvecs[2][i] = -s * temp1 + c * yvecs[2][i];
  }
}


x86 assembly (clang, -O0):
<rotate2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1212 <rotate2d+0xf2>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x34(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x34(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1159 <rotate2d+0x39>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotate2d>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <sin@plt>
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movapd 0x10(%rsp),%xmm9
test   %ebx,%ebx
jle    12ef <rotate2d+0x1cf>
mov    0x8(%r14),%rax
mov    0x10(%r14),%rcx
movapd 0xe9a(%rip),%xmm1
xorpd  %xmm9,%xmm1
mov    %ebx,%r10d
lea    0x1(%r10),%rdx
mov    $0x1,%edi
cmp    $0x2,%ebx
jb     12b0 <rotate2d+0x190>
lea    0x8(%rax),%rbx
lea    (%rcx,%rdx,8),%rsi
cmp    %rsi,%rbx
jae    119e <rotate2d+0x7e>
lea    (%rax,%rdx,8),%rsi
lea    0x8(%rcx),%rbx
cmp    %rsi,%rbx
jb     12b0 <rotate2d+0x190>
mov    %r10d,%r8d
and    $0xfffffffe,%r8d
movapd %xmm9,%xmm4
unpcklpd %xmm9,%xmm4
movapd %xmm0,%xmm3
unpcklpd %xmm0,%xmm3
movapd %xmm1,%xmm8
unpcklpd %xmm1,%xmm8
lea    -0x2(%r8),%rsi
mov    %rsi,%r9
shr    %r9
add    $0x1,%r9
test   %rsi,%rsi
je     12f7 <rotate2d+0x1d7>
mov    %r9,%rdi
and    $0xfffffffffffffffe,%rdi
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movupd (%rax,%rbx,8),%xmm5
movupd (%rcx,%rbx,8),%xmm6
movapd %xmm4,%xmm7
mulpd  %xmm6,%xmm7
movapd %xmm3,%xmm2
mulpd  %xmm5,%xmm2
addpd  %xmm7,%xmm2
movupd %xmm2,(%rax,%rbx,8)
mulpd  %xmm3,%xmm6
mulpd  %xmm8,%xmm5
addpd  %xmm6,%xmm5
movupd %xmm5,(%rcx,%rbx,8)
movupd 0x10(%rax,%rbx,8),%xmm2
movupd 0x10(%rcx,%rbx,8),%xmm5
movapd %xmm4,%xmm6
mulpd  %xmm5,%xmm6
movapd %xmm3,%xmm7
mulpd  %xmm2,%xmm7
addpd  %xmm6,%xmm7
movupd %xmm7,0x10(%rax,%rbx,8)
mulpd  %xmm3,%xmm5
mulpd  %xmm8,%xmm2
addpd  %xmm5,%xmm2
movupd %xmm2,0x10(%rcx,%rbx,8)
add    $0x4,%rbx
add    $0xfffffffffffffffe,%rdi
jne    11f0 <rotate2d+0xd0>
test   $0x1,%r9b
je     12a1 <rotate2d+0x181>
movupd (%rax,%rbx,8),%xmm2
movupd (%rcx,%rbx,8),%xmm5
mulpd  %xmm5,%xmm4
movapd %xmm3,%xmm6
mulpd  %xmm2,%xmm6
addpd  %xmm4,%xmm6
movupd %xmm6,(%rax,%rbx,8)
mulpd  %xmm5,%xmm3
mulpd  %xmm2,%xmm8
addpd  %xmm3,%xmm8
movupd %xmm8,(%rcx,%rbx,8)
cmp    %r8,%r10
je     12ef <rotate2d+0x1cf>
or     $0x1,%r10
mov    %r10,%rdi
nopl   (%rax)
movsd  (%rax,%rdi,8),%xmm2
movsd  (%rcx,%rdi,8),%xmm3
mulsd  %xmm9,%xmm3
movapd %xmm0,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm3,%xmm4
movsd  %xmm4,(%rax,%rdi,8)
movsd  (%rcx,%rdi,8),%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm1,%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,(%rcx,%rdi,8)
add    $0x1,%rdi
cmp    %rdi,%rdx
jne    12b0 <rotate2d+0x190>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%ebx
test   $0x1,%r9b
jne    126e <rotate2d+0x14e>
jmp    12a1 <rotate2d+0x181>

LLVM IR (-O0):
define void @rotate2d(double** %0, i32 %1, double %2) {
%4 = alloca double**
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
store double** %0, double*** %4
store i32 %1, i32* %5
store double %2, double* %6
%11 = load double, double* %6
%12 = call double @sin(double %11)
store double %12, double* %9
%13 = load double, double* %6
%14 = call double @cos(double %13)
store double %14, double* %8
store i32 1, i32* %10
br label %15
15: ; preds = %64, %3
%16 = load i32, i32* %10
%17 = load i32, i32* %5
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %67
19: ; preds = %15
%20 = load double**, double*** %4
%21 = getelementptr inbounds double*, double** %20, i64 1
%22 = load double*, double** %21
%23 = load i32, i32* %10
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
store double %26, double* %7
%27 = load double, double* %8
%28 = load double, double* %7
%29 = load double, double* %9
%30 = load double**, double*** %4
%31 = getelementptr inbounds double*, double** %30, i64 2
%32 = load double*, double** %31
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = fmul double %29, %36
%38 = call double @llvm.fmuladd.f64(double %27, double %28, double %37)
%39 = load double**, double*** %4
%40 = getelementptr inbounds double*, double** %39, i64 1
%41 = load double*, double** %40
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
store double %38, double* %44
%45 = load double, double* %9
%46 = fneg double %45
%47 = load double, double* %7
%48 = load double, double* %8
%49 = load double**, double*** %4
%50 = getelementptr inbounds double*, double** %49, i64 2
%51 = load double*, double** %50
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = fmul double %48, %55
%57 = call double @llvm.fmuladd.f64(double %46, double %47, double %56)
%58 = load double**, double*** %4
%59 = getelementptr inbounds double*, double** %58, i64 2
%60 = load double*, double** %59
%61 = load i32, i32* %10
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
store double %57, double* %63
br label %64
64: ; preds = %19
%65 = load i32, i32* %10
%66 = add nsw i32 %65, 1
store i32 %66, i32* %10
br label %15
67: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @rotate2d(double** nocapture %0, i32 %1, double %2) {
%4 = tail call double @sin(double %2)
%5 = tail call double @cos(double %2)
%6 = icmp slt i32 %1, 1
br i1 %6, label %108, label %7
7: ; preds = %3
%8 = getelementptr inbounds double*, double** %0, i64 1
%9 = load double*, double** %8
%10 = getelementptr inbounds double*, double** %0, i64 2
%11 = load double*, double** %10
%12 = fneg double %4
%13 = add nuw i32 %1, 1
%14 = zext i32 %13 to i64
%15 = add nsw i64 %14, -1
%16 = icmp ult i64 %15, 2
br i1 %16, label %93, label %17
17: ; preds = %7
%18 = getelementptr double, double* %9, i64 1
%19 = getelementptr double, double* %9, i64 %14
%20 = getelementptr double, double* %11, i64 1
%21 = getelementptr double, double* %11, i64 %14
%22 = icmp ult double* %18, %21
%23 = icmp ult double* %20, %19
%24 = and i1 %22, %23
br i1 %24, label %93, label %25
25: ; preds = %17
%26 = and i64 %15, -2
%27 = or i64 %15, 1
%28 = insertelement <2 x double> poison, double %4, i64 0
%29 = shufflevector <2 x double> %28, <2 x double> poison, <2 x i32> zeroinitializer
%30 = insertelement <2 x double> poison, double %5, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = insertelement <2 x double> poison, double %12, i64 0
%33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
%34 = add nsw i64 %26, -2
%35 = lshr exact i64 %34, 1
%36 = add nuw i64 %35, 1
%37 = and i64 %36, 1
%38 = icmp eq i64 %34, 0
br i1 %38, label %75, label %39
39: ; preds = %25
%40 = and i64 %36, -2
br label %41
41: ; preds = %41, %39
%42 = phi i64 [ 0, %39 ], [ %70, %41 ]
%43 = phi i64 [ 0, %39 ], [ %71, %41 ]
%44 = or i64 %42, 1
%45 = getelementptr inbounds double, double* %9, i64 %44
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = getelementptr inbounds double, double* %11, i64 %44
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = fmul <2 x double> %29, %50
%52 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %47, <2 x double> %51)
%53 = bitcast double* %45 to <2 x double>*
store <2 x double> %52, <2 x double>* %53
%54 = fmul <2 x double> %31, %50
%55 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %47, <2 x double> %54)
%56 = bitcast double* %48 to <2 x double>*
store <2 x double> %55, <2 x double>* %56
%57 = or i64 %42, 3
%58 = getelementptr inbounds double, double* %9, i64 %57
%59 = bitcast double* %58 to <2 x double>*
%60 = load <2 x double>, <2 x double>* %59
%61 = getelementptr inbounds double, double* %11, i64 %57
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = fmul <2 x double> %29, %63
%65 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %60, <2 x double> %64)
%66 = bitcast double* %58 to <2 x double>*
store <2 x double> %65, <2 x double>* %66
%67 = fmul <2 x double> %31, %63
%68 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %60, <2 x double> %67)
%69 = bitcast double* %61 to <2 x double>*
store <2 x double> %68, <2 x double>* %69
%70 = add nuw i64 %42, 4
%71 = add nuw i64 %43, 2
%72 = icmp eq i64 %71, %40
br i1 %72, label %73, label %41
73: ; preds = %41
%74 = or i64 %70, 1
br label %75
75: ; preds = %73, %25
%76 = phi i64 [ 1, %25 ], [ %74, %73 ]
%77 = icmp eq i64 %37, 0
br i1 %77, label %91, label %78
78: ; preds = %75
%79 = getelementptr inbounds double, double* %9, i64 %76
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = getelementptr inbounds double, double* %11, i64 %76
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = fmul <2 x double> %29, %84
%86 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> %81, <2 x double> %85)
%87 = bitcast double* %79 to <2 x double>*
store <2 x double> %86, <2 x double>* %87
%88 = fmul <2 x double> %31, %84
%89 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %33, <2 x double> %81, <2 x double> %88)
%90 = bitcast double* %82 to <2 x double>*
store <2 x double> %89, <2 x double>* %90
br label %91
91: ; preds = %75, %78
%92 = icmp eq i64 %15, %26
br i1 %92, label %108, label %93
93: ; preds = %17, %7, %91
%94 = phi i64 [ 1, %17 ], [ 1, %7 ], [ %27, %91 ]
br label %95
95: ; preds = %93, %95
%96 = phi i64 [ %106, %95 ], [ %94, %93 ]
%97 = getelementptr inbounds double, double* %9, i64 %96
%98 = load double, double* %97
%99 = getelementptr inbounds double, double* %11, i64 %96
%100 = load double, double* %99
%101 = fmul double %4, %100
%102 = tail call double @llvm.fmuladd.f64(double %5, double %98, double %101)
store double %102, double* %97
%103 = load double, double* %99
%104 = fmul double %5, %103
%105 = tail call double @llvm.fmuladd.f64(double %12, double %98, double %104)
store double %105, double* %99
%106 = add nuw nsw i64 %96, 1
%107 = icmp eq i64 %106, %14
br i1 %107, label %108, label %95
108: ; preds = %95, %91, %3
ret void
}