#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *, ...);
double sin(double);
main() {
  int i, j;
  double a[2][2];
  double theta;
  double x[2];
  double y[2];
  printf("回転（ラジアン）");
  scanf("%lf", &theta);
  a[0][0] = cos(theta);
  a[0][1] = -sin(theta);
  a[1][0] = sin(theta);
  a[1][1] = cos(theta);
  printf("元の座標:");
  scanf("%lf %lf", &x[0], &x[1]);
  for (i = 0; i < 2; i++) {
    y[0] = 0;
    y[1] = 0;
    for (j = 0; j < 2; j++) {
      y[i] += a[i][j] * x[j];
    }
  }
  printf("変換後の座標 (%f, %f)\n", y[0], y[1]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsd  -0x38(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x18(%rbp)
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rsi
lea    -0x50(%rbp),%rdx
add    $0x8,%rdx
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1277 <main+0x137>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    1264 <main+0x124>
movslq -0x8(%rbp),%rcx
lea    -0x30(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0xc(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm2
movslq -0x8(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1212 <main+0xd2>
jmp    1269 <main+0x129>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f1 <main+0xb1>
movsd  -0x60(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
lea    0xda7(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x28(%rsp)
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x18(%rsp),%rdx
lea    0xe70(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  0x30(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
xorpd  %xmm0,%xmm0
addsd  %xmm0,%xmm1
movsd  0x28(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
lea    0xe3d(%rip),%rdi
xorpd  %xmm0,%xmm0
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\E5\9B\9E\E8\BB\A2\EF\BC\88\E3\83\A9\E3\82\B8\E3\82\A2\E3\83\B3\EF\BC\89\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [14 x i8] c"\E5\85\83\E3\81\AE\E5\BA\A7\E6\A8\99:\00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.4 = [29 x i8] c"\E5\A4\89\E6\8F\9B\E5\BE\8C\E3\81\AE\E5\BA\A7\E6\A8\99 (%f, %f)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x [2 x double]]
%5 = alloca double
%6 = alloca [2 x double]
%7 = alloca [2 x double]
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
%10 = load double, double* %5
%11 = call double @cos(double %10)
%12 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %4, i64 0, i64 0
%13 = getelementptr inbounds [2 x double], [2 x double]* %12, i64 0, i64 0
store double %11, double* %13
%14 = load double, double* %5
%15 = call double @sin(double %14)
%16 = fneg double %15
%17 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %4, i64 0, i64 0
%18 = getelementptr inbounds [2 x double], [2 x double]* %17, i64 0, i64 1
store double %16, double* %18
%19 = load double, double* %5
%20 = call double @sin(double %19)
%21 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %4, i64 0, i64 1
%22 = getelementptr inbounds [2 x double], [2 x double]* %21, i64 0, i64 0
store double %20, double* %22
%23 = load double, double* %5
%24 = call double @cos(double %23)
%25 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %4, i64 0, i64 1
%26 = getelementptr inbounds [2 x double], [2 x double]* %25, i64 0, i64 1
store double %24, double* %26
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%28 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 0
%29 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 1
%30 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %28, double* %29)
store i32 0, i32* %2
br label %31
31: ; preds = %61, %0
%32 = load i32, i32* %2
%33 = icmp slt i32 %32, 2
br i1 %33, label %34, label %64
34: ; preds = %31
%35 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
store double 0.000000e+00, double* %35
%36 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 1
store double 0.000000e+00, double* %36
store i32 0, i32* %3
br label %37
37: ; preds = %57, %34
%38 = load i32, i32* %3
%39 = icmp slt i32 %38, 2
br i1 %39, label %40, label %60
40: ; preds = %37
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [2 x [2 x double]], [2 x [2 x double]]* %4, i64 0, i64 %42
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [2 x double], [2 x double]* %43, i64 0, i64 %45
%47 = load double, double* %46
%48 = load i32, i32* %3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [2 x double], [2 x double]* %6, i64 0, i64 %49
%51 = load double, double* %50
%52 = load i32, i32* %2
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 %53
%55 = load double, double* %54
%56 = call double @llvm.fmuladd.f64(double %47, double %51, double %55)
store double %56, double* %54
br label %57
57: ; preds = %40
%58 = load i32, i32* %3
%59 = add nsw i32 %58, 1
store i32 %59, i32* %3
br label %37
60: ; preds = %37
br label %61
61: ; preds = %60
%62 = load i32, i32* %2
%63 = add nsw i32 %62, 1
store i32 %63, i32* %2
br label %31
64: ; preds = %31
%65 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 0
%66 = load double, double* %65
%67 = getelementptr inbounds [2 x double], [2 x double]* %7, i64 0, i64 1
%68 = load double, double* %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), double %66, double %68)
%70 = load i32, i32* %1
ret i32 %70
}

LLVM IR (-O2):
@.str = [25 x i8] c"\E5\9B\9E\E8\BB\A2\EF\BC\88\E3\83\A9\E3\82\B8\E3\82\A2\E3\83\B3\EF\BC\89\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [14 x i8] c"\E5\85\83\E3\81\AE\E5\BA\A7\E6\A8\99:\00"
@.str.3 = [8 x i8] c"%lf %lf\00"
@.str.4 = [29 x i8] c"\E5\A4\89\E6\8F\9B\E5\BE\8C\E3\81\AE\E5\BA\A7\E6\A8\99 (%f, %f)\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca [2 x double]
%3 = bitcast double* %1 to i8*
%4 = bitcast [2 x double]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%7 = load double, double* %1
%8 = call double @cos(double %7)
%9 = load double, double* %1
%10 = call double @sin(double %9)
%11 = load double, double* %1
%12 = call double @sin(double %11)
%13 = load double, double* %1
%14 = call double @cos(double %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 0
%17 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 1
%18 = call i32 (i8*, double*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double* %16, double* %17)
%19 = load double, double* %16
%20 = load double, double* %17
%21 = call double @llvm.fmuladd.f64(double %12, double %19, double 0.000000e+00)
%22 = call double @llvm.fmuladd.f64(double %14, double %20, double %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), double 0.000000e+00, double %22)
ret i32 0
}