#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 */
int /*<<< orphan*/ apply_rotate(double *, double *, int, int, double *);
void apply_shift_rotate(double *q_in, double *q0, double *R, int n_dim,
                        int transpose, double *q_out) {
  double tmp[n_dim];
  int j;
  for (j = 0; j < n_dim; j++) {
    tmp[j] = q_in[j] - q0[j];
  }
  apply_rotate(&tmp[0], R, n_dim, transpose, q_out);
}


x86 assembly (clang, -O0):
<apply_shift_rotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    119e <apply_shift_rotate+0x8e>
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm0
mov    -0x10(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
subsd  (%rcx,%rdx,8),%xmm0
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    115d <apply_shift_rotate+0x4d>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x28(%rbp),%r8
call   1030 <apply_rotate@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply_shift_rotate>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r10d
mov    %rsp,%r11
lea    0xf(,%r10,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r11
mov    %r11,%rsp
test   %ecx,%ecx
jle    1229 <apply_shift_rotate+0x119>
cmp    $0x4,%ecx
jae    1146 <apply_shift_rotate+0x36>
xor    %eax,%eax
jmp    1210 <apply_shift_rotate+0x100>
mov    %r10d,%eax
and    $0xfffffffc,%eax
lea    -0x4(%rax),%rbx
mov    %rbx,%r14
shr    $0x2,%r14
add    $0x1,%r14
test   %rbx,%rbx
je     1247 <apply_shift_rotate+0x137>
mov    %r14,%r15
and    $0xfffffffffffffffe,%r15
xor    %ebx,%ebx
nopl   (%rax)
movupd (%rdi,%rbx,8),%xmm0
movupd 0x10(%rdi,%rbx,8),%xmm1
movupd (%rsi,%rbx,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rsi,%rbx,8),%xmm2
subpd  %xmm2,%xmm1
movapd %xmm0,(%r11,%rbx,8)
movapd %xmm1,0x10(%r11,%rbx,8)
movupd 0x20(%rdi,%rbx,8),%xmm0
movupd 0x30(%rdi,%rbx,8),%xmm1
movupd 0x20(%rsi,%rbx,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x30(%rsi,%rbx,8),%xmm2
subpd  %xmm2,%xmm1
movapd %xmm0,0x20(%r11,%rbx,8)
movapd %xmm1,0x30(%r11,%rbx,8)
add    $0x8,%rbx
add    $0xfffffffffffffffe,%r15
jne    1170 <apply_shift_rotate+0x60>
test   $0x1,%r14b
je     1204 <apply_shift_rotate+0xf4>
movupd (%rdi,%rbx,8),%xmm0
movupd 0x10(%rdi,%rbx,8),%xmm1
movupd (%rsi,%rbx,8),%xmm2
subpd  %xmm2,%xmm0
movupd 0x10(%rsi,%rbx,8),%xmm2
subpd  %xmm2,%xmm1
movapd %xmm0,(%r11,%rbx,8)
movapd %xmm1,0x10(%r11,%rbx,8)
cmp    %r10,%rax
je     1229 <apply_shift_rotate+0x119>
nopl   0x0(%rax)
movsd  (%rdi,%rax,8),%xmm0
subsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,(%r11,%rax,8)
add    $0x1,%rax
cmp    %rax,%r10
jne    1210 <apply_shift_rotate+0x100>
mov    %r11,%rdi
mov    %rdx,%rsi
mov    %ecx,%edx
mov    %r8d,%ecx
mov    %r9,%r8
call   1030 <apply_rotate@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
test   $0x1,%r14b
jne    11d9 <apply_shift_rotate+0xc9>
jmp    1204 <apply_shift_rotate+0xf4>

LLVM IR (-O0):
define void @apply_shift_rotate(double* %0, double* %1, double* %2, i32 %3, i32 %4, double* %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca double*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
store double* %0, double** %7
store double* %1, double** %8
store double* %2, double** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store double* %5, double** %12
%16 = load i32, i32* %10
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %13
%19 = alloca double, i64 %17
store i64 %17, i64* %14
store i32 0, i32* %15
br label %20
20: ; preds = %39, %6
%21 = load i32, i32* %15
%22 = load i32, i32* %10
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %42
24: ; preds = %20
%25 = load double*, double** %7
%26 = load i32, i32* %15
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = load double*, double** %8
%31 = load i32, i32* %15
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = fsub double %29, %34
%36 = load i32, i32* %15
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %19, i64 %37
store double %35, double* %38
br label %39
39: ; preds = %24
%40 = load i32, i32* %15
%41 = add nsw i32 %40, 1
store i32 %41, i32* %15
br label %20
42: ; preds = %20
%43 = getelementptr inbounds double, double* %19, i64 0
%44 = load double*, double** %9
%45 = load i32, i32* %10
%46 = load i32, i32* %11
%47 = load double*, double** %12
%48 = call i32 @apply_rotate(double* %43, double* %44, i32 %45, i32 %46, double* %47)
%49 = load i8*, i8** %13
ret void
}

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