#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 */
typedef scalar_t__ clock_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
float CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, float);
double sin(double);
int main(int argc, char **argv) {
  double a[1000][1000];
  int i, j;
  FILE *ff;
  for (i = 0; i < 1000; i++) {
    for (j = 0; j < 1000; j++) {
      a[i][j] = 10 * i + j;
    }
  }
  clock_t t = clock();
  for (i = 0; i < 1000 - 1; i++) {
    for (j = 0; j < 1000 - 1; j++) {
      a[i][j] = sin(0.00001 * a[i + 1][j + 1]);
    }
  }
  t = clock() - t;
  printf("Time: %f\n", ((float)t) / CLOCKS_PER_SEC);
  ff = fopen("6.out", "w");
  for (i = 0; i < 1000; i++) {
    for (j = 0; j < 1000; j++) {
      fprintf(ff, "%f ", a[i][j]);
    }
    fprintf(ff, "\n");
  }
  fclose(ff);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a1230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x7a1214(%rbp)
cmpl   $0x3e8,-0x7a1214(%rbp)
jge    120f <main+0xaf>
movl   $0x0,-0x7a1218(%rbp)
cmpl   $0x3e8,-0x7a1218(%rbp)
jge    11f6 <main+0x96>
imul   $0xa,-0x7a1214(%rbp),%eax
add    -0x7a1218(%rbp),%eax
cvtsi2sd %eax,%xmm0
movslq -0x7a1214(%rbp),%rcx
lea    -0x7a1210(%rbp),%rax
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x7a1218(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x7a1218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1218(%rbp)
jmp    119d <main+0x3d>
jmp    11fb <main+0x9b>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    1183 <main+0x23>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x7a1228(%rbp)
movl   $0x0,-0x7a1214(%rbp)
cmpl   $0x3e7,-0x7a1214(%rbp)
jge    12dd <main+0x17d>
movl   $0x0,-0x7a1218(%rbp)
cmpl   $0x3e7,-0x7a1218(%rbp)
jge    12c4 <main+0x164>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    -0x7a1210(%rbp),%rax
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
mov    -0x7a1218(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xd7e(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
call   1070 <sin@plt>
movslq -0x7a1214(%rbp),%rcx
lea    -0x7a1210(%rbp),%rax
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x7a1218(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x7a1218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1218(%rbp)
jmp    1241 <main+0xe1>
jmp    12c9 <main+0x169>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    1227 <main+0xc7>
mov    $0x0,%al
call   1030 <clock@plt>
sub    -0x7a1228(%rbp),%rax
mov    %rax,-0x7a1228(%rbp)
cvtsi2ssq -0x7a1228(%rbp),%xmm0
85 ff
mov    0x2ce6(%rip),%rax
divss  (%rax),%xmm0
lea    0xcfb(%rip),%rdi
call   1050 <printf@plt>
lea    0xcf9(%rip),%rdi
lea    0xcf8(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x7a1220(%rbp)
movl   $0x0,-0x7a1214(%rbp)
cmpl   $0x3e8,-0x7a1214(%rbp)
jge    13d6 <main+0x276>
movl   $0x0,-0x7a1218(%rbp)
cmpl   $0x3e8,-0x7a1218(%rbp)
jge    13ad <main+0x24d>
mov    -0x7a1220(%rbp),%rdi
movslq -0x7a1214(%rbp),%rcx
lea    -0x7a1210(%rbp),%rax
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x7a1218(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xc88(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x7a1218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1218(%rbp)
jmp    1350 <main+0x1f0>
mov    -0x7a1220(%rbp),%rdi
lea    0xc55(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    1336 <main+0x1d6>
mov    -0x7a1220(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x7a1230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7a1200,%rsp
mov    %rsp,%rax
xor    %ecx,%ecx
movdqa 0xe73(%rip),%xmm0
movdqa 0xe7b(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%rcx,%rcx,1),%rdx
lea    (%rdx,%rdx,4),%rsi
movq   %rsi,%xmm2
pshufd $0x44,%xmm2,%xmm2
lea    (%rdx,%rdx,4),%rdx
add    $0x2,%rdx
movq   %rdx,%xmm3
pshufd $0x44,%xmm3,%xmm3
mov    $0x2,%edx
movdqa %xmm0,%xmm4
nopl   (%rax)
movdqa %xmm4,%xmm5
paddq  %xmm2,%xmm5
movdqa %xmm3,%xmm6
paddq  %xmm4,%xmm6
pshufd $0xe8,%xmm5,%xmm5
cvtdq2pd %xmm5,%xmm5
pshufd $0xe8,%xmm6,%xmm6
cvtdq2pd %xmm6,%xmm6
movaps %xmm5,-0x10(%rax,%rdx,8)
movaps %xmm6,(%rax,%rdx,8)
paddq  %xmm1,%xmm4
add    $0x4,%rdx
cmp    $0x3ea,%rdx
jne    11d0 <main+0x60>
add    $0x1,%rcx
add    $0x1f40,%rax
cmp    $0x3e8,%rcx
jne    11a0 <main+0x30>
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
lea    0x1f58(%rsp),%r12
movsd  0xde4(%rip),%xmm1
nopl   0x0(%rax)
add    $0x1,%r15
mov    $0xffffffffffffe0c8,%rbx
nopl   0x0(%rax,%rax,1)
movsd  0x1f28(%r12,%rbx,1),%xmm0
mulsd  %xmm1,%xmm0
call   1080 <sin@plt>
movsd  %xmm0,-0x20(%r12,%rbx,1)
movsd  0x1f30(%r12,%rbx,1),%xmm0
mulsd  0xda4(%rip),%xmm0
call   1080 <sin@plt>
movsd  %xmm0,-0x18(%r12,%rbx,1)
movsd  0x1f38(%r12,%rbx,1),%xmm0
mulsd  0xd86(%rip),%xmm0
call   1080 <sin@plt>
movsd  0xd79(%rip),%xmm1
movsd  %xmm0,-0x10(%r12,%rbx,1)
add    $0x18,%rbx
jne    1250 <main+0xe0>
add    $0x1f40,%r12
cmp    $0x3e7,%r15
jne    1240 <main+0xd0>
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mov    0x2d04(%rip),%rax
divss  (%rax),%xmm0
lea    0xd39(%rip),%rdi
call   1050 <printf@plt>
lea    0xd37(%rip),%rdi
lea    0xd36(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
mov    %rsp,%r13
lea    0xd26(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x0(%r13,%rbx,8),%xmm0
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x3e8,%rbx
jne    1330 <main+0x1c0>
mov    $0xa,%edi
mov    %r12,%rsi
call   1060 <fputc@plt>
add    $0x1,%r15
add    $0x1f40,%r13
cmp    $0x3e8,%r15
jne    1320 <main+0x1b0>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x7a1200,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Time: %f\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.1 = [6 x i8] c"6.out\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [4 x i8] c"%f \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x [1000 x double]]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %11
11: ; preds = %34, %2
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 1000
br i1 %13, label %14, label %37
14: ; preds = %11
store i32 0, i32* %8
br label %15
15: ; preds = %30, %14
%16 = load i32, i32* %8
%17 = icmp slt i32 %16, 1000
br i1 %17, label %18, label %33
18: ; preds = %15
%19 = load i32, i32* %7
%20 = mul nsw i32 10, %19
%21 = load i32, i32* %8
%22 = add nsw i32 %20, %21
%23 = sitofp i32 %22 to double
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 %25
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1000 x double], [1000 x double]* %26, i64 0, i64 %28
store double %23, double* %29
br label %30
30: ; preds = %18
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %15
33: ; preds = %15
br label %34
34: ; preds = %33
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %11
37: ; preds = %11
%38 = call i64 (...) @clock()
store i64 %38, i64* %10
store i32 0, i32* %7
br label %39
39: ; preds = %68, %37
%40 = load i32, i32* %7
%41 = icmp slt i32 %40, 999
br i1 %41, label %42, label %71
42: ; preds = %39
store i32 0, i32* %8
br label %43
43: ; preds = %64, %42
%44 = load i32, i32* %8
%45 = icmp slt i32 %44, 999
br i1 %45, label %46, label %67
46: ; preds = %43
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 %49
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [1000 x double], [1000 x double]* %50, i64 0, i64 %53
%55 = load double, double* %54
%56 = fmul double 1.000000e-05, %55
%57 = call double @sin(double %56)
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 %59
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [1000 x double], [1000 x double]* %60, i64 0, i64 %62
store double %57, double* %63
br label %64
64: ; preds = %46
%65 = load i32, i32* %8
%66 = add nsw i32 %65, 1
store i32 %66, i32* %8
br label %43
67: ; preds = %43
br label %68
68: ; preds = %67
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %39
71: ; preds = %39
%72 = call i64 (...) @clock()
%73 = load i64, i64* %10
%74 = sub nsw i64 %72, %73
store i64 %74, i64* %10
%75 = load i64, i64* %10
%76 = sitofp i64 %75 to float
%77 = load float, float* @CLOCKS_PER_SEC
%78 = fdiv float %76, %77
%79 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), float %78)
%80 = call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %80, i32** %9
store i32 0, i32* %7
br label %81
81: ; preds = %104, %71
%82 = load i32, i32* %7
%83 = icmp slt i32 %82, 1000
br i1 %83, label %84, label %107
84: ; preds = %81
store i32 0, i32* %8
br label %85
85: ; preds = %98, %84
%86 = load i32, i32* %8
%87 = icmp slt i32 %86, 1000
br i1 %87, label %88, label %101
88: ; preds = %85
%89 = load i32*, i32** %9
%90 = load i32, i32* %7
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 %91
%93 = load i32, i32* %8
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [1000 x double], [1000 x double]* %92, i64 0, i64 %94
%96 = load double, double* %95
%97 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %96)
br label %98
98: ; preds = %88
%99 = load i32, i32* %8
%100 = add nsw i32 %99, 1
store i32 %100, i32* %8
br label %85
101: ; preds = %85
%102 = load i32*, i32** %9
%103 = call i32 (i32*, i8*, ...) @fprintf(i32* %102, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %104
104: ; preds = %101
%105 = load i32, i32* %7
%106 = add nsw i32 %105, 1
store i32 %106, i32* %7
br label %81
107: ; preds = %81
%108 = load i32*, i32** %9
%109 = call i32 @fclose(i32* %108)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"Time: %f\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.1 = [6 x i8] c"6.out\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [4 x i8] c"%f \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x [1000 x double]]
%4 = bitcast [1000 x [1000 x double]]* %3 to i8*
br label %5
5: ; preds = %2, %29
%6 = phi i64 [ 0, %2 ], [ %30, %29 ]
%7 = mul nuw nsw i64 %6, 10
%8 = insertelement <2 x i64> poison, i64 %7, i64 0
%9 = shufflevector <2 x i64> %8, <2 x i64> poison, <2 x i32> zeroinitializer
%10 = add nuw i64 %7, 2
%11 = insertelement <2 x i64> poison, i64 %10, i64 0
%12 = shufflevector <2 x i64> %11, <2 x i64> poison, <2 x i32> zeroinitializer
br label %13
13: ; preds = %13, %5
%14 = phi i64 [ 0, %5 ], [ %26, %13 ]
%15 = phi <2 x i64> [ <i64 0, i64 1>, %5 ], [ %27, %13 ]
%16 = add nuw nsw <2 x i64> %15, %9
%17 = add <2 x i64> %12, %15
%18 = trunc <2 x i64> %16 to <2 x i32>
%19 = trunc <2 x i64> %17 to <2 x i32>
%20 = sitofp <2 x i32> %18 to <2 x double>
%21 = sitofp <2 x i32> %19 to <2 x double>
%22 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %6, i64 %14
%23 = bitcast double* %22 to <2 x double>*
store <2 x double> %20, <2 x double>* %23
%24 = getelementptr inbounds double, double* %22, i64 2
%25 = bitcast double* %24 to <2 x double>*
store <2 x double> %21, <2 x double>* %25
%26 = add nuw i64 %14, 4
%27 = add <2 x i64> %15, <i64 4, i64 4>
%28 = icmp eq i64 %26, 1000
br i1 %28, label %29, label %13
29: ; preds = %13
%30 = add nuw nsw i64 %6, 1
%31 = icmp eq i64 %30, 1000
br i1 %31, label %32, label %5
32: ; preds = %29
%33 = tail call i64 (...) @clock()
br label %34
34: ; preds = %32, %58
%35 = phi i64 [ 0, %32 ], [ %36, %58 ]
%36 = add nuw nsw i64 %35, 1
br label %37
37: ; preds = %37, %34
%38 = phi i64 [ 0, %34 ], [ %51, %37 ]
%39 = add nuw nsw i64 %38, 1
%40 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %36, i64 %39
%41 = load double, double* %40
%42 = fmul double %41, 1.000000e-05
%43 = tail call double @sin(double %42)
%44 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %35, i64 %38
store double %43, double* %44
%45 = add nuw nsw i64 %38, 2
%46 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %36, i64 %45
%47 = load double, double* %46
%48 = fmul double %47, 1.000000e-05
%49 = tail call double @sin(double %48)
%50 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %35, i64 %39
store double %49, double* %50
%51 = add nuw nsw i64 %38, 3
%52 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %36, i64 %51
%53 = load double, double* %52
%54 = fmul double %53, 1.000000e-05
%55 = tail call double @sin(double %54)
%56 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %35, i64 %45
store double %55, double* %56
%57 = icmp eq i64 %51, 999
br i1 %57, label %58, label %37
58: ; preds = %37
%59 = icmp eq i64 %36, 999
br i1 %59, label %60, label %34
60: ; preds = %58
%61 = tail call i64 (...) @clock()
%62 = sub nsw i64 %61, %33
%63 = sitofp i64 %62 to float
%64 = load float, float* @CLOCKS_PER_SEC
%65 = fdiv float %63, %64
%66 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), float %65)
%67 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %68
68: ; preds = %60, %77
%69 = phi i64 [ 0, %60 ], [ %79, %77 ]
br label %70
70: ; preds = %68, %70
%71 = phi i64 [ 0, %68 ], [ %75, %70 ]
%72 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %69, i64 %71
%73 = load double, double* %72
%74 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %67, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %73)
%75 = add nuw nsw i64 %71, 1
%76 = icmp eq i64 %75, 1000
br i1 %76, label %77, label %70
77: ; preds = %70
%78 = tail call i32 @fputc(i32 10, i32* %67)
%79 = add nuw nsw i64 %69, 1
%80 = icmp eq i64 %79, 1000
br i1 %80, label %81, label %68
81: ; preds = %77
%82 = tail call i32 @fclose(i32* %67)
ret i32 0
}