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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
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;
    }
  }
  for (i = 0; i < 1000 - 1; i++) {
    for (j = 1; j < 1000; j++) {
      a[i][j] = sin(0.00001 * a[i + 1][j - 1]);
    }
  }
  ff = fopen("aaas", "w");
  for (i = 0; i < 1000; i++) {
    for (j = 0; j < 1000; j++) {
      fprintf(ff, "%f ", a[i][j]);
    }
    fprintf(ff, "\n");
  }
  fclose(ff);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a1220,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x7a1214(%rbp)
cmpl   $0x3e8,-0x7a1214(%rbp)
jge    11ef <main+0xaf>
movl   $0x0,-0x7a1218(%rbp)
cmpl   $0x3e8,-0x7a1218(%rbp)
jge    11d6 <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    117d <main+0x3d>
jmp    11db <main+0x9b>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    1163 <main+0x23>
movl   $0x0,-0x7a1214(%rbp)
cmpl   $0x3e7,-0x7a1214(%rbp)
jge    12af <main+0x16f>
movl   $0x1,-0x7a1218(%rbp)
cmpl   $0x3e8,-0x7a1218(%rbp)
jge    1296 <main+0x156>
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
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xdac(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
call   1050 <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    1213 <main+0xd3>
jmp    129b <main+0x15b>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    11f9 <main+0xb9>
lea    0xd52(%rip),%rdi
lea    0xd50(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x7a1220(%rbp)
movl   $0x0,-0x7a1214(%rbp)
cmpl   $0x3e8,-0x7a1214(%rbp)
jge    1373 <main+0x233>
movl   $0x0,-0x7a1218(%rbp)
cmpl   $0x3e8,-0x7a1218(%rbp)
jge    134a <main+0x20a>
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    0xce0(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x7a1218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1218(%rbp)
jmp    12ed <main+0x1ad>
mov    -0x7a1220(%rbp),%rdi
lea    0xcbb(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    12d3 <main+0x193>
mov    -0x7a1220(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x7a1220,%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 0xe93(%rip),%xmm0
movdqa 0xe9b(%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    11b0 <main+0x60>
add    $0x1,%rcx
add    $0x1f40,%rax
cmp    $0x3e8,%rcx
jne    1180 <main+0x30>
lea    0x1f48(%rsp),%r15
xor    %r14d,%r14d
movsd  0xe0e(%rip),%xmm1
jmp    1238 <main+0xe8>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1f40,%r15
cmp    $0x3e7,%r14
movsd  0xdea(%rip),%xmm1
je     129f <main+0x14f>
add    $0x1,%r14
mov    $0xfffffffffffffc1a,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  0x1f28(%r15,%rbx,8),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0x10(%r15,%rbx,8)
test   %rbx,%rbx
je     1220 <main+0xd0>
movsd  0x1f30(%r15,%rbx,8),%xmm0
movsd  0xd9f(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0x8(%r15,%rbx,8)
add    $0x2,%rbx
movsd  0xd83(%rip),%xmm1
jmp    1250 <main+0x100>
lea    0xd82(%rip),%rdi
lea    0xd80(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    %rsp,%r13
xor    %r12d,%r12d
lea    0xd6d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movq   0x0(%r13,%rbx,8),%xmm0
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x3e8,%rbx
jne    12e0 <main+0x190>
mov    $0xa,%edi
mov    %r15,%rsi
call   1040 <fputc@plt>
add    $0x1,%r12
add    $0x1f40,%r13
cmp    $0x3e8,%r12
jne    12d0 <main+0x180>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x7a1200,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"aaas\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [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, %52
%33 = phi i64 [ %34, %52 ], [ 0, %29 ]
%34 = add nuw nsw i64 %33, 1
br label %35
35: ; preds = %45, %32
%36 = phi i64 [ 1, %32 ], [ %51, %45 ]
%37 = add nsw i64 %36, -1
%38 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %34, i64 %37
%39 = load double, double* %38
%40 = fmul double %39, 1.000000e-05
%41 = tail call double @sin(double %40)
%42 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %33, i64 %36
store double %41, double* %42
%43 = add nuw nsw i64 %36, 1
%44 = icmp eq i64 %43, 1000
br i1 %44, label %52, label %45
45: ; preds = %35
%46 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %34, i64 %36
%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 %33, i64 %43
store double %49, double* %50
%51 = add nuw nsw i64 %36, 2
br label %35
52: ; preds = %35
%53 = icmp eq i64 %34, 999
br i1 %53, label %54, label %32
54: ; preds = %52
%55 = tail call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %56
56: ; preds = %54, %65
%57 = phi i64 [ 0, %54 ], [ %67, %65 ]
br label %58
58: ; preds = %56, %58
%59 = phi i64 [ 0, %56 ], [ %63, %58 ]
%60 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %3, i64 0, i64 %57, i64 %59
%61 = load double, double* %60
%62 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %61)
%63 = add nuw nsw i64 %59, 1
%64 = icmp eq i64 %63, 1000
br i1 %64, label %65, label %58
65: ; preds = %58
%66 = tail call i32 @fputc(i32 10, i32* %55)
%67 = add nuw nsw i64 %57, 1
%68 = icmp eq i64 %67, 1000
br i1 %68, label %69, label %56
69: ; preds = %65
%70 = tail call i32 @fclose(i32* %55)
ret i32 0
}