#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 M_PI;
scalar_t__ cos(int);
double sin(int);
void initialize_radar(double theta_radar[1000], double matrice_real[1000][1000],
                      double matrice_img[1000][1000]) {
  int i;
  for (i = 0; i < 1000; i++) {
    theta_radar[i] = ((double)(2.0 * M_PI * 0.02) / 0.04) *
                     sin((-90. + i * 180. / 1000) * (double)(M_PI / 180.));
  }
  int j;
  for (i = 0; i < 1000; i++)
    for (j = 0; j < 1000; j++) {
      matrice_real[i][j] = (double)cos(j * theta_radar[i]) / 1000;
      matrice_img[i][j] = (double)-sin(j * theta_radar[i]) / 1000;
    }
}


x86 assembly (clang, -O0):
<initialize_radar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    11ec <initialize_radar+0xcc>
movsd  0xed8(%rip),%xmm0
mov    0x2e91(%rip),%rax
mulsd  (%rax),%xmm0
movsd  0xebd(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea9(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe83(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe6f(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe73(%rip),%xmm0
addsd  %xmm1,%xmm0
mov    0x2e40(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe54(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <initialize_radar+0x1b>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    12d5 <initialize_radar+0x1b5>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3e8,-0x20(%rbp)
jge    12c2 <initialize_radar+0x1a2>
cvtsi2sdl -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
cvtsi2sd %rax,%xmm0
movsd  0xdc4(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd6b(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1207 <initialize_radar+0xe7>
jmp    12c7 <initialize_radar+0x1a7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f3 <initialize_radar+0xd3>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initialize_radar>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
xor    %ebx,%ebx
mov    0x2ea9(%rip),%r13
nop
movsd  0x0(%r13),%xmm0
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm2
mulsd  0xeaa(%rip),%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
divsd  0xea3(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xe9d(%rip),%xmm2
mulsd  %xmm2,%xmm1
divsd  0xe99(%rip),%xmm1
addsd  0xe99(%rip),%xmm1
divsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    $0x3e8,%rbx
jne    1140 <initialize_radar+0x20>
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  (%r12,%r13,8),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0xe18(%rip),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  0x8(%rsp),%xmm0
mulsd  (%r12,%r13,8),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sin@plt>
movsd  0xe05(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    $0x3e8,%rbx
jne    11d0 <initialize_radar+0xb0>
add    $0x1,%r13
add    $0x1f40,%r14
add    $0x1f40,%r15
cmp    $0x3e8,%r13
jne    11c0 <initialize_radar+0xa0>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @initialize_radar(double* %0, [1000 x double]* %1, [1000 x double]* %2) {
%4 = alloca double*
%5 = alloca [1000 x double]*
%6 = alloca [1000 x double]*
%7 = alloca i32
%8 = alloca i32
store double* %0, double** %4
store [1000 x double]* %1, [1000 x double]** %5
store [1000 x double]* %2, [1000 x double]** %6
store i32 0, i32* %7
br label %9
9: ; preds = %32, %3
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 1000
br i1 %11, label %12, label %35
12: ; preds = %9
%13 = load double, double* @M_PI
%14 = fmul double 2.000000e+00, %13
%15 = fmul double %14, 2.000000e-02
%16 = fdiv double %15, 4.000000e-02
%17 = load i32, i32* %7
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 1.800000e+02
%20 = fdiv double %19, 1.000000e+03
%21 = fadd double -9.000000e+01, %20
%22 = load double, double* @M_PI
%23 = fdiv double %22, 1.800000e+02
%24 = fmul double %21, %23
%25 = fptosi double %24 to i32
%26 = call double @sin(i32 %25)
%27 = fmul double %16, %26
%28 = load double*, double** %4
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
store double %27, double* %31
br label %32
32: ; preds = %12
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %9
35: ; preds = %9
store i32 0, i32* %7
br label %36
36: ; preds = %86, %35
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 1000
br i1 %38, label %39, label %89
39: ; preds = %36
store i32 0, i32* %8
br label %40
40: ; preds = %82, %39
%41 = load i32, i32* %8
%42 = icmp slt i32 %41, 1000
br i1 %42, label %43, label %85
43: ; preds = %40
%44 = load i32, i32* %8
%45 = sitofp i32 %44 to double
%46 = load double*, double** %4
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
%50 = load double, double* %49
%51 = fmul double %45, %50
%52 = fptosi double %51 to i32
%53 = call i64 @cos(i32 %52)
%54 = sitofp i64 %53 to double
%55 = fdiv double %54, 1.000000e+03
%56 = load [1000 x double]*, [1000 x double]** %5
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [1000 x double], [1000 x double]* %56, 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 %55, double* %62
%63 = load i32, i32* %8
%64 = sitofp i32 %63 to double
%65 = load double*, double** %4
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = fmul double %64, %69
%71 = fptosi double %70 to i32
%72 = call double @sin(i32 %71)
%73 = fneg double %72
%74 = fdiv double %73, 1.000000e+03
%75 = load [1000 x double]*, [1000 x double]** %6
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [1000 x double], [1000 x double]* %75, i64 %77
%79 = load i32, i32* %8
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [1000 x double], [1000 x double]* %78, i64 0, i64 %80
store double %74, double* %81
br label %82
82: ; preds = %43
%83 = load i32, i32* %8
%84 = add nsw i32 %83, 1
store i32 %84, i32* %8
br label %40
85: ; preds = %40
br label %86
86: ; preds = %85
%87 = load i32, i32* %7
%88 = add nsw i32 %87, 1
store i32 %88, i32* %7
br label %36
89: ; preds = %36
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @initialize_radar(double* nocapture %0, [1000 x double]* nocapture writeonly %1, [1000 x double]* nocapture writeonly %2) {
br label %4
4: ; preds = %3, %4
%5 = phi i64 [ 0, %3 ], [ %21, %4 ]
%6 = load double, double* @M_PI
%7 = fmul double %6, 2.000000e+00
%8 = fmul double %7, 2.000000e-02
%9 = fdiv double %8, 4.000000e-02
%10 = trunc i64 %5 to i32
%11 = sitofp i32 %10 to double
%12 = fmul double %11, 1.800000e+02
%13 = fdiv double %12, 1.000000e+03
%14 = fadd double %13, -9.000000e+01
%15 = fdiv double %6, 1.800000e+02
%16 = fmul double %14, %15
%17 = fptosi double %16 to i32
%18 = tail call double @sin(i32 %17)
%19 = fmul double %18, %9
%20 = getelementptr inbounds double, double* %0, i64 %5
store double %19, double* %20
%21 = add nuw nsw i64 %5, 1
%22 = icmp eq i64 %21, 1000
br i1 %22, label %23, label %4
23: ; preds = %4, %45
%24 = phi i64 [ %46, %45 ], [ 0, %4 ]
%25 = getelementptr inbounds double, double* %0, i64 %24
br label %26
26: ; preds = %23, %26
%27 = phi i64 [ 0, %23 ], [ %43, %26 ]
%28 = trunc i64 %27 to i32
%29 = sitofp i32 %28 to double
%30 = load double, double* %25
%31 = fmul double %30, %29
%32 = fptosi double %31 to i32
%33 = tail call i64 @cos(i32 %32)
%34 = sitofp i64 %33 to double
%35 = fdiv double %34, 1.000000e+03
%36 = getelementptr inbounds [1000 x double], [1000 x double]* %1, i64 %24, i64 %27
store double %35, double* %36
%37 = load double, double* %25
%38 = fmul double %37, %29
%39 = fptosi double %38 to i32
%40 = tail call double @sin(i32 %39)
%41 = fdiv double %40, -1.000000e+03
%42 = getelementptr inbounds [1000 x double], [1000 x double]* %2, i64 %24, i64 %27
store double %41, double* %42
%43 = add nuw nsw i64 %27, 1
%44 = icmp eq i64 %43, 1000
br i1 %44, label %45, label %26
45: ; preds = %26
%46 = add nuw nsw i64 %24, 1
%47 = icmp eq i64 %46, 1000
br i1 %47, label %48, label %23
48: ; preds = %45
ret void
}