#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);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, int);
double sin(double);
void rotation_matrix_3(double Rot[3][3], int axis, double angle) {
  switch (axis) {
  case 1:
    Rot[0][0] = 1.0;
    Rot[1][0] = 0.0;
    Rot[2][0] = 0.0;
    Rot[0][1] = 0.0;
    Rot[1][1] = cos(angle);
    Rot[2][1] = -sin(angle);
    Rot[0][2] = 0.0;
    Rot[1][2] = sin(angle);
    Rot[2][2] = cos(angle);
    break;
  case 2:
    Rot[0][0] = cos(angle);
    Rot[1][0] = 0.0;
    Rot[2][0] = sin(angle);
    Rot[0][1] = 0.0;
    Rot[1][1] = 1.0;
    Rot[2][1] = 0.0;
    Rot[0][2] = -sin(angle);
    Rot[1][2] = 0.0;
    Rot[2][2] = cos(angle);
    break;
  case 3:
    Rot[0][0] = cos(angle);
    Rot[1][0] = -sin(angle);
    Rot[2][0] = 0.0;
    Rot[0][1] = sin(angle);
    Rot[1][1] = cos(angle);
    Rot[2][1] = 0.0;
    Rot[0][2] = 0.0;
    Rot[1][2] = 0.0;
    Rot[2][2] = 1.0;
    break;
  default:
    printf("ERROR in rotation_matrix_3: axis = %d, 1<=axis<=3 required.\n",
           axis);
    exit(-1);
  }
  return;
}


x86 assembly (clang, -O0):
<rotation_matrix_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     118a <rotation_matrix_3+0x4a>
jmp    1168 <rotation_matrix_3+0x28>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     1232 <rotation_matrix_3+0xf2>
jmp    1179 <rotation_matrix_3+0x39>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
je     12da <rotation_matrix_3+0x19a>
jmp    1382 <rotation_matrix_3+0x242>
mov    -0x8(%rbp),%rax
movsd  0xe6a(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x30(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
jmp    139b <rotation_matrix_3+0x25b>
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x30(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0xd85(%rip),%xmm0
movsd  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x40(%rax)
jmp    139b <rotation_matrix_3+0x25b>
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x30(%rax)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
mov    -0x8(%rbp),%rax
movsd  0xc88(%rip),%xmm0
movsd  %xmm0,0x40(%rax)
jmp    139b <rotation_matrix_3+0x25b>
mov    -0xc(%rbp),%esi
lea    0xc7c(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotation_matrix_3>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
cmp    $0x3,%esi
movsd  %xmm0,0x8(%rsp)
je     11bd <rotation_matrix_3+0x7d>
cmp    $0x2,%esi
je     1226 <rotation_matrix_3+0xe6>
cmp    $0x1,%esi
jne    1299 <rotation_matrix_3+0x159>
movq   $0x0,0x18(%rbx)
movq   $0x0,0x30(%rbx)
movsd  0xe93(%rip),%xmm1
movups %xmm1,(%rbx)
call   1050 <cos@plt>
movsd  %xmm0,0x20(%rbx)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
xorps  0xe64(%rip),%xmm0
movlps %xmm0,0x38(%rbx)
movq   $0x0,0x10(%rbx)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x28(%rbx)
jmp    1283 <rotation_matrix_3+0x143>
call   1050 <cos@plt>
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
xorps  0xe28(%rip),%xmm0
movlps %xmm0,0x18(%rbx)
movq   $0x0,0x30(%rbx)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x8(%rbx)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x20(%rbx)
movq   $0x0,0x38(%rbx)
movq   $0x0,0x10(%rbx)
movq   $0x0,0x28(%rbx)
movsd  0xdec(%rip),%xmm0
jmp    128e <rotation_matrix_3+0x14e>
call   1050 <cos@plt>
movsd  %xmm0,(%rbx)
movq   $0x0,0x18(%rbx)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x30(%rbx)
movq   $0x0,0x8(%rbx)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x20(%rbx)
movq   $0x0,0x38(%rbx)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
xorps  0xd89(%rip),%xmm0
movlps %xmm0,0x10(%rbx)
movq   $0x0,0x28(%rbx)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x40(%rbx)
add    $0x10,%rsp
pop    %rbx
ret
lea    0xd78(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [61 x i8] c"ERROR in rotation_matrix_3: axis = %d, 1<=axis<=3 required.\0A\00"
define void @rotation_matrix_3([3 x double]* %0, i32 %1, double %2) {
%4 = alloca [3 x double]*
%5 = alloca i32
%6 = alloca double
store [3 x double]* %0, [3 x double]** %4
store i32 %1, i32* %5
store double %2, double* %6
%7 = load i32, i32* %5
switch i32 %7, label %119 [
i32 1, label %8
i32 2, label %45
i32 3, label %82
]
8: ; preds = %3
%9 = load [3 x double]*, [3 x double]** %4
%10 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0
%11 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
store double 1.000000e+00, double* %11
%12 = load [3 x double]*, [3 x double]** %4
%13 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 1
%14 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
store double 0.000000e+00, double* %14
%15 = load [3 x double]*, [3 x double]** %4
%16 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 2
%17 = getelementptr inbounds [3 x double], [3 x double]* %16, i64 0, i64 0
store double 0.000000e+00, double* %17
%18 = load [3 x double]*, [3 x double]** %4
%19 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0
%20 = getelementptr inbounds [3 x double], [3 x double]* %19, i64 0, i64 1
store double 0.000000e+00, double* %20
%21 = load double, double* %6
%22 = call double @cos(double %21)
%23 = load [3 x double]*, [3 x double]** %4
%24 = getelementptr inbounds [3 x double], [3 x double]* %23, i64 1
%25 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 1
store double %22, double* %25
%26 = load double, double* %6
%27 = call double @sin(double %26)
%28 = fneg double %27
%29 = load [3 x double]*, [3 x double]** %4
%30 = getelementptr inbounds [3 x double], [3 x double]* %29, i64 2
%31 = getelementptr inbounds [3 x double], [3 x double]* %30, i64 0, i64 1
store double %28, double* %31
%32 = load [3 x double]*, [3 x double]** %4
%33 = getelementptr inbounds [3 x double], [3 x double]* %32, i64 0
%34 = getelementptr inbounds [3 x double], [3 x double]* %33, i64 0, i64 2
store double 0.000000e+00, double* %34
%35 = load double, double* %6
%36 = call double @sin(double %35)
%37 = load [3 x double]*, [3 x double]** %4
%38 = getelementptr inbounds [3 x double], [3 x double]* %37, i64 1
%39 = getelementptr inbounds [3 x double], [3 x double]* %38, i64 0, i64 2
store double %36, double* %39
%40 = load double, double* %6
%41 = call double @cos(double %40)
%42 = load [3 x double]*, [3 x double]** %4
%43 = getelementptr inbounds [3 x double], [3 x double]* %42, i64 2
%44 = getelementptr inbounds [3 x double], [3 x double]* %43, i64 0, i64 2
store double %41, double* %44
br label %123
45: ; preds = %3
%46 = load double, double* %6
%47 = call double @cos(double %46)
%48 = load [3 x double]*, [3 x double]** %4
%49 = getelementptr inbounds [3 x double], [3 x double]* %48, i64 0
%50 = getelementptr inbounds [3 x double], [3 x double]* %49, i64 0, i64 0
store double %47, double* %50
%51 = load [3 x double]*, [3 x double]** %4
%52 = getelementptr inbounds [3 x double], [3 x double]* %51, i64 1
%53 = getelementptr inbounds [3 x double], [3 x double]* %52, i64 0, i64 0
store double 0.000000e+00, double* %53
%54 = load double, double* %6
%55 = call double @sin(double %54)
%56 = load [3 x double]*, [3 x double]** %4
%57 = getelementptr inbounds [3 x double], [3 x double]* %56, i64 2
%58 = getelementptr inbounds [3 x double], [3 x double]* %57, i64 0, i64 0
store double %55, double* %58
%59 = load [3 x double]*, [3 x double]** %4
%60 = getelementptr inbounds [3 x double], [3 x double]* %59, i64 0
%61 = getelementptr inbounds [3 x double], [3 x double]* %60, i64 0, i64 1
store double 0.000000e+00, double* %61
%62 = load [3 x double]*, [3 x double]** %4
%63 = getelementptr inbounds [3 x double], [3 x double]* %62, i64 1
%64 = getelementptr inbounds [3 x double], [3 x double]* %63, i64 0, i64 1
store double 1.000000e+00, double* %64
%65 = load [3 x double]*, [3 x double]** %4
%66 = getelementptr inbounds [3 x double], [3 x double]* %65, i64 2
%67 = getelementptr inbounds [3 x double], [3 x double]* %66, i64 0, i64 1
store double 0.000000e+00, double* %67
%68 = load double, double* %6
%69 = call double @sin(double %68)
%70 = fneg double %69
%71 = load [3 x double]*, [3 x double]** %4
%72 = getelementptr inbounds [3 x double], [3 x double]* %71, i64 0
%73 = getelementptr inbounds [3 x double], [3 x double]* %72, i64 0, i64 2
store double %70, double* %73
%74 = load [3 x double]*, [3 x double]** %4
%75 = getelementptr inbounds [3 x double], [3 x double]* %74, i64 1
%76 = getelementptr inbounds [3 x double], [3 x double]* %75, i64 0, i64 2
store double 0.000000e+00, double* %76
%77 = load double, double* %6
%78 = call double @cos(double %77)
%79 = load [3 x double]*, [3 x double]** %4
%80 = getelementptr inbounds [3 x double], [3 x double]* %79, i64 2
%81 = getelementptr inbounds [3 x double], [3 x double]* %80, i64 0, i64 2
store double %78, double* %81
br label %123
82: ; preds = %3
%83 = load double, double* %6
%84 = call double @cos(double %83)
%85 = load [3 x double]*, [3 x double]** %4
%86 = getelementptr inbounds [3 x double], [3 x double]* %85, i64 0
%87 = getelementptr inbounds [3 x double], [3 x double]* %86, i64 0, i64 0
store double %84, double* %87
%88 = load double, double* %6
%89 = call double @sin(double %88)
%90 = fneg double %89
%91 = load [3 x double]*, [3 x double]** %4
%92 = getelementptr inbounds [3 x double], [3 x double]* %91, i64 1
%93 = getelementptr inbounds [3 x double], [3 x double]* %92, i64 0, i64 0
store double %90, double* %93
%94 = load [3 x double]*, [3 x double]** %4
%95 = getelementptr inbounds [3 x double], [3 x double]* %94, i64 2
%96 = getelementptr inbounds [3 x double], [3 x double]* %95, i64 0, i64 0
store double 0.000000e+00, double* %96
%97 = load double, double* %6
%98 = call double @sin(double %97)
%99 = load [3 x double]*, [3 x double]** %4
%100 = getelementptr inbounds [3 x double], [3 x double]* %99, i64 0
%101 = getelementptr inbounds [3 x double], [3 x double]* %100, i64 0, i64 1
store double %98, double* %101
%102 = load double, double* %6
%103 = call double @cos(double %102)
%104 = load [3 x double]*, [3 x double]** %4
%105 = getelementptr inbounds [3 x double], [3 x double]* %104, i64 1
%106 = getelementptr inbounds [3 x double], [3 x double]* %105, i64 0, i64 1
store double %103, double* %106
%107 = load [3 x double]*, [3 x double]** %4
%108 = getelementptr inbounds [3 x double], [3 x double]* %107, i64 2
%109 = getelementptr inbounds [3 x double], [3 x double]* %108, i64 0, i64 1
store double 0.000000e+00, double* %109
%110 = load [3 x double]*, [3 x double]** %4
%111 = getelementptr inbounds [3 x double], [3 x double]* %110, i64 0
%112 = getelementptr inbounds [3 x double], [3 x double]* %111, i64 0, i64 2
store double 0.000000e+00, double* %112
%113 = load [3 x double]*, [3 x double]** %4
%114 = getelementptr inbounds [3 x double], [3 x double]* %113, i64 1
%115 = getelementptr inbounds [3 x double], [3 x double]* %114, i64 0, i64 2
store double 0.000000e+00, double* %115
%116 = load [3 x double]*, [3 x double]** %4
%117 = getelementptr inbounds [3 x double], [3 x double]* %116, i64 2
%118 = getelementptr inbounds [3 x double], [3 x double]* %117, i64 0, i64 2
store double 1.000000e+00, double* %118
br label %123
119: ; preds = %3
%120 = load i32, i32* %5
%121 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 %120)
%122 = call i32 @exit(i32 -1)
unreachable
123: ; preds = %82, %45, %8
ret void
}

LLVM IR (-O2):
@.str = [61 x i8] c"ERROR in rotation_matrix_3: axis = %d, 1<=axis<=3 required.\0A\00"
define void @rotation_matrix_3([3 x double]* writeonly %0, i32 %1, double %2) {
switch i32 %1, label %45 [
i32 1, label %4
i32 2, label %17
i32 3, label %31
]
4: ; preds = %3
%5 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
store double 0.000000e+00, double* %5
%6 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
store double 0.000000e+00, double* %6
%7 = bitcast [3 x double]* %0 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 0.000000e+00>, <2 x double>* %7
%8 = tail call double @cos(double %2)
%9 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
store double %8, double* %9
%10 = tail call double @sin(double %2)
%11 = fneg double %10
%12 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
store double %11, double* %12
%13 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
store double 0.000000e+00, double* %13
%14 = tail call double @sin(double %2)
%15 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
store double %14, double* %15
%16 = tail call double @cos(double %2)
br label %48
17: ; preds = %3
%18 = tail call double @cos(double %2)
%19 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
store double %18, double* %19
%20 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
store double 0.000000e+00, double* %20
%21 = tail call double @sin(double %2)
%22 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
store double %21, double* %22
%23 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
store double 0.000000e+00, double* %23
%24 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
store double 1.000000e+00, double* %24
%25 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
store double 0.000000e+00, double* %25
%26 = tail call double @sin(double %2)
%27 = fneg double %26
%28 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
store double %27, double* %28
%29 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
store double 0.000000e+00, double* %29
%30 = tail call double @cos(double %2)
br label %48
31: ; preds = %3
%32 = tail call double @cos(double %2)
%33 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
store double %32, double* %33
%34 = tail call double @sin(double %2)
%35 = fneg double %34
%36 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
store double %35, double* %36
%37 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
store double 0.000000e+00, double* %37
%38 = tail call double @sin(double %2)
%39 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
store double %38, double* %39
%40 = tail call double @cos(double %2)
%41 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
store double %40, double* %41
%42 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
store double 0.000000e+00, double* %42
%43 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
store double 0.000000e+00, double* %43
%44 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
store double 0.000000e+00, double* %44
br label %48
45: ; preds = %3
%46 = tail call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 %1)
%47 = tail call i32 @exit(i32 -1)
unreachable
48: ; preds = %31, %17, %4
%49 = phi double [ 1.000000e+00, %31 ], [ %30, %17 ], [ %16, %4 ]
%50 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
store double %49, double* %50
ret void
}