#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; ++i) {
    for (j = 0; j < 1000 - 2; ++j) {
      a[i][j] = sin(0.00001 * a[i][j + 2]);
    }
  }
  t = clock() - t;
  printf("Time: %f\n", ((float)t) / CLOCKS_PER_SEC);
  ff = fopen("4.out", "w");
  for (i = 0; i < 1000; ++i) {
    for (j = 0; j < 1000; ++j) {
      fprintf(ff, "%f\n", 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   $0x3e8,-0x7a1214(%rbp)
jge    12d8 <main+0x178>
movl   $0x0,-0x7a1218(%rbp)
cmpl   $0x3e6,-0x7a1218(%rbp)
jge    12bf <main+0x15f>
movslq -0x7a1214(%rbp),%rcx
lea    -0x7a1210(%rbp),%rax
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
mov    -0x7a1218(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  0xd83(%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    12c4 <main+0x164>
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    0x2ceb(%rip),%rax
divss  (%rax),%xmm0
lea    0xd00(%rip),%rdi
call   1050 <printf@plt>
lea    0xcfe(%rip),%rdi
lea    0xcfd(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x7a1220(%rbp)
movl   $0x0,-0x7a1214(%rbp)
cmpl   $0x3e8,-0x7a1214(%rbp)
jge    13d1 <main+0x271>
movl   $0x0,-0x7a1218(%rbp)
cmpl   $0x3e8,-0x7a1218(%rbp)
jge    13a8 <main+0x248>
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    0xc81(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x7a1218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1218(%rbp)
jmp    134b <main+0x1eb>
mov    -0x7a1220(%rbp),%rdi
lea    0xc5a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    1331 <main+0x1d1>
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
mov    %rsp,%r12
movsd  0xde9(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
mov    $0x3,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  -0x8(%r12,%rbx,8),%xmm0
mulsd  %xmm1,%xmm0
call   1080 <sin@plt>
movsd  %xmm0,-0x18(%r12,%rbx,8)
movsd  (%r12,%rbx,8),%xmm0
mulsd  0xdab(%rip),%xmm0
call   1080 <sin@plt>
movsd  0xd9e(%rip),%xmm1
movsd  %xmm0,-0x10(%r12,%rbx,8)
add    $0x2,%rbx
cmp    $0x3e9,%rbx
jne    1250 <main+0xe0>
add    $0x1,%r15
add    $0x1f40,%r12
cmp    $0x3e8,%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    0x2d22(%rip),%rax
divss  (%rax),%xmm0
lea    0xd57(%rip),%rdi
call   1050 <printf@plt>
lea    0xd55(%rip),%rdi
lea    0xd54(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
mov    %rsp,%r13
lea    0xd38(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
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    1310 <main+0x1a0>
mov    $0xa,%edi
mov    %r12,%rsi
call   1060 <fputc@plt>
add    $0x1,%r15
add    $0x1f40,%r13
cmp    $0x3e8,%r15
jne    1300 <main+0x190>
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"4.out\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [4 x i8] c"%f\0A\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 = %67, %37
%40 = load i32, i32* %7
%41 = icmp slt i32 %40, 1000
br i1 %41, label %42, label %70
42: ; preds = %39
store i32 0, i32* %8
br label %43
43: ; preds = %63, %42
%44 = load i32, i32* %8
%45 = icmp slt i32 %44, 998
br i1 %45, label %46, label %66
46: ; preds = %43
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 %48
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 2
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1000 x double], [1000 x double]* %49, i64 0, i64 %52
%54 = load double, double* %53
%55 = fmul double 1.000000e-05, %54
%56 = call double @sin(double %55)
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 %58
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [1000 x double], [1000 x double]* %59, i64 0, i64 %61
store double %56, double* %62
br label %63
63: ; preds = %46
%64 = load i32, i32* %8
%65 = add nsw i32 %64, 1
store i32 %65, i32* %8
br label %43
66: ; preds = %43
br label %67
67: ; preds = %66
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %39
70: ; preds = %39
%71 = call i64 (...) @clock()
%72 = load i64, i64* %10
%73 = sub nsw i64 %71, %72
store i64 %73, i64* %10
%74 = load i64, i64* %10
%75 = sitofp i64 %74 to float
%76 = load float, float* @CLOCKS_PER_SEC
%77 = fdiv float %75, %76
%78 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), float %77)
%79 = 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* %79, i32** %9
store i32 0, i32* %7
br label %80
80: ; preds = %103, %70
%81 = load i32, i32* %7
%82 = icmp slt i32 %81, 1000
br i1 %82, label %83, label %106
83: ; preds = %80
store i32 0, i32* %8
br label %84
84: ; preds = %97, %83
%85 = load i32, i32* %8
%86 = icmp slt i32 %85, 1000
br i1 %86, label %87, label %100
87: ; preds = %84
%88 = load i32*, i32** %9
%89 = load i32, i32* %7
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 %90
%92 = load i32, i32* %8
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [1000 x double], [1000 x double]* %91, i64 0, i64 %93
%95 = load double, double* %94
%96 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %95)
br label %97
97: ; preds = %87
%98 = load i32, i32* %8
%99 = add nsw i32 %98, 1
store i32 %99, i32* %8
br label %84
100: ; preds = %84
%101 = load i32*, i32** %9
%102 = call i32 (i32*, i8*, ...) @fprintf(i32* %101, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %103
103: ; preds = %100
%104 = load i32, i32* %7
%105 = add nsw i32 %104, 1
store i32 %105, i32* %7
br label %80
106: ; preds = %80
%107 = load i32*, i32** %9
%108 = call i32 @fclose(i32* %107)
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"4.out\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [4 x i8] c"%f\0A\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, %53
%35 = phi i64 [ 0, %32 ], [ %54, %53 ]
br label %36
36: ; preds = %36, %34
%37 = phi i64 [ 0, %34 ], [ %51, %36 ]
%38 = add nuw nsw i64 %37, 2
%39 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %35, i64 %38
%40 = load double, double* %39
%41 = fmul double %40, 1.000000e-05
%42 = tail call double @sin(double %41)
%43 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %35, i64 %37
store double %42, double* %43
%44 = or i64 %37, 1
%45 = add nuw nsw i64 %37, 3
%46 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %35, 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 %44
store double %49, double* %50
%51 = add nuw nsw i64 %37, 2
%52 = icmp eq i64 %51, 998
br i1 %52, label %53, label %36
53: ; preds = %36
%54 = add nuw nsw i64 %35, 1
%55 = icmp eq i64 %54, 1000
br i1 %55, label %56, label %34
56: ; preds = %53
%57 = tail call i64 (...) @clock()
%58 = sub nsw i64 %57, %33
%59 = sitofp i64 %58 to float
%60 = load float, float* @CLOCKS_PER_SEC
%61 = fdiv float %59, %60
%62 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), float %61)
%63 = 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 %64
64: ; preds = %56, %73
%65 = phi i64 [ 0, %56 ], [ %75, %73 ]
br label %66
66: ; preds = %64, %66
%67 = phi i64 [ 0, %64 ], [ %71, %66 ]
%68 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %65, i64 %67
%69 = load double, double* %68
%70 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %69)
%71 = add nuw nsw i64 %67, 1
%72 = icmp eq i64 %71, 1000
br i1 %72, label %73, label %66
73: ; preds = %66
%74 = tail call i32 @fputc(i32 10, i32* %63)
%75 = add nuw nsw i64 %65, 1
%76 = icmp eq i64 %75, 1000
br i1 %76, label %77, label %64
77: ; preds = %73
%78 = tail call i32 @fclose(i32* %63)
ret i32 0
}