#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; i++) {
    for (j = 0; j < 1000; j++) {
      a[i][j] = sin(0.00001 * a[i][j]);
    }
  }
  ff = fopen("result.simple.txt", "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    $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   $0x3e8,-0x7a1214(%rbp)
jge    12a5 <main+0x165>
movl   $0x0,-0x7a1218(%rbp)
cmpl   $0x3e8,-0x7a1218(%rbp)
jge    128c <main+0x14c>
movslq -0x7a1214(%rbp),%rcx
lea    -0x7a1210(%rbp),%rax
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x7a1218(%rbp),%rcx
movsd  0xdb6(%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    1291 <main+0x151>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    11f9 <main+0xb9>
lea    0xd5c(%rip),%rdi
lea    0xd67(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x7a1220(%rbp)
movl   $0x0,-0x7a1214(%rbp)
cmpl   $0x3e8,-0x7a1214(%rbp)
jge    1369 <main+0x229>
movl   $0x0,-0x7a1218(%rbp)
cmpl   $0x3e8,-0x7a1218(%rbp)
jge    1340 <main+0x200>
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    0xcf7(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x7a1218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1218(%rbp)
jmp    12e3 <main+0x1a3>
mov    -0x7a1220(%rbp),%rdi
lea    0xcd2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x7a1214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a1214(%rbp)
jmp    12c9 <main+0x189>
mov    -0x7a1220(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%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>
mov    %rsp,%r15
xor    %r14d,%r14d
movsd  0xe13(%rip),%xmm1
nopl   (%rax)
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  -0x8(%r15,%rbx,8),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0x8(%r15,%rbx,8)
movsd  (%r15,%rbx,8),%xmm0
mulsd  0xddb(%rip),%xmm0
call   1060 <sin@plt>
movsd  0xdce(%rip),%xmm1
movsd  %xmm0,(%r15,%rbx,8)
add    $0x2,%rbx
cmp    $0x3e9,%rbx
jne    1220 <main+0xd0>
add    $0x1,%r14
add    $0x1f40,%r15
cmp    $0x3e8,%r14
jne    1210 <main+0xc0>
lea    0xda8(%rip),%rdi
lea    0xdb3(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    %rsp,%r13
xor    %r12d,%r12d
lea    0xda0(%rip),%r14
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    12b0 <main+0x160>
mov    $0xa,%edi
mov    %r15,%rsi
call   1040 <fputc@plt>
add    $0x1,%r12
add    $0x1f40,%r13
cmp    $0x3e8,%r12
jne    12a0 <main+0x150>
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 = [18 x i8] c"result.simple.txt\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 = %64, %36
%38 = load i32, i32* %7
%39 = icmp slt i32 %38, 1000
br i1 %39, label %40, label %67
40: ; preds = %37
store i32 0, i32* %8
br label %41
41: ; preds = %60, %40
%42 = load i32, i32* %8
%43 = icmp slt i32 %42, 1000
br i1 %43, label %44, label %63
44: ; preds = %41
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 %46
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [1000 x double], [1000 x double]* %47, i64 0, i64 %49
%51 = load double, double* %50
%52 = fmul double 1.000000e-05, %51
%53 = call double @sin(double %52)
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 %55
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [1000 x double], [1000 x double]* %56, i64 0, i64 %58
store double %53, double* %59
br label %60
60: ; preds = %44
%61 = load i32, i32* %8
%62 = add nsw i32 %61, 1
store i32 %62, i32* %8
br label %41
63: ; preds = %41
br label %64
64: ; preds = %63
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
br label %37
67: ; preds = %37
%68 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %68, i32** %9
store i32 0, i32* %7
br label %69
69: ; preds = %92, %67
%70 = load i32, i32* %7
%71 = icmp slt i32 %70, 1000
br i1 %71, label %72, label %95
72: ; preds = %69
store i32 0, i32* %8
br label %73
73: ; preds = %86, %72
%74 = load i32, i32* %8
%75 = icmp slt i32 %74, 1000
br i1 %75, label %76, label %89
76: ; preds = %73
%77 = load i32*, i32** %9
%78 = load i32, i32* %7
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* %6, i64 0, i64 %79
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [1000 x double], [1000 x double]* %80, i64 0, i64 %82
%84 = load double, double* %83
%85 = call i32 (i32*, i8*, ...) @fprintf(i32* %77, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %84)
br label %86
86: ; preds = %76
%87 = load i32, i32* %8
%88 = add nsw i32 %87, 1
store i32 %88, i32* %8
br label %73
89: ; preds = %73
%90 = load i32*, i32** %9
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %92
92: ; preds = %89
%93 = load i32, i32* %7
%94 = add nsw i32 %93, 1
store i32 %94, i32* %7
br label %69
95: ; preds = %69
%96 = load i32*, i32** %9
%97 = call i32 @fclose(i32* %96)
ret i32 0
}

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