#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 */
int O_CREAT;
int O_RDWR;
int O_TRUNC;
double atan2(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ cos(double);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sin(double);
int /*<<< orphan*/ write(int, double *, int);
int create_Result_file() {
  int i, nbVal;
  double tabRatan2[20000], Inc;
  char *F_name;
  int fp;
  F_name = "ratan2";
  nbVal = 20000;
  Inc = (2 * 3.1415926535897932384626433832795029L) / nbVal;
  for (i = 0; i < nbVal; i++) {
    tabRatan2[i] = atan2(sin(Inc * i), cos(Inc * i));
  }
  fp = open(F_name, O_RDWR | O_CREAT | O_TRUNC, 0777);
  if (!fp) {
    printf("error opening file");
    close(fp);
    return -1;
  } else {
    for (i = 0; i < nbVal; i++) {
      write(fp, &tabRatan2[i], sizeof(double));
    }
    close(fp);
    return 0;
  }
}


x86 assembly (clang, -O0):
<create_Result_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27140,%rsp
lea    0xe8e(%rip),%rax
mov    %rax,-0x27120(%rbp)
movl   $0x4e20,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x27128(%rbp)
fildl  -0x27128(%rbp)
fldt   0xe5b(%rip)
fdivp  %st,%st(1)
fstpl  -0x27130(%rbp)
movsd  -0x27130(%rbp),%xmm0
ff
movsd  %xmm0,-0x27118(%rbp)
ff
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    122a <create_Result_file+0xba>
movsd  -0x27118(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1070 <sin@plt>
mov    %eax,-0x27134(%rbp)
movsd  -0x27118(%rbp),%xmm0
ff
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1080 <cos@plt>
mov    -0x27134(%rbp),%edi
mov    %eax,%esi
call   1040 <atan2@plt>
movslq -0x8(%rbp),%rax
movsd  %xmm0,-0x27110(%rbp,%rax,8)
fd ff
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c4 <create_Result_file+0x54>
mov    -0x27120(%rbp),%rdi
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
mov    0x2db7(%rip),%rax
or     (%rax),%esi
mov    0x2da6(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
call   1090 <open@plt>
mov    %eax,-0x27124(%rbp)
cmpl   $0x0,-0x27124(%rbp)
jne    128c <create_Result_file+0x11c>
lea    0xda7(%rip),%rdi
call   1050 <printf@plt>
mov    -0x27124(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12e1 <create_Result_file+0x171>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12cf <create_Result_file+0x15f>
mov    -0x27124(%rbp),%edi
movslq -0x8(%rbp),%rax
lea    -0x27110(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
mov    $0x8,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1293 <create_Result_file+0x123>
mov    -0x27124(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x27140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_Result_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x27110,%rsp
xor    %ebx,%ebx
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xe71(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1070 <sin@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
call   1080 <cos@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <atan2@plt>
movsd  %xmm0,0x10(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x4e20,%rbx
jne    1180 <create_Result_file+0x10>
mov    0x2e0e(%rip),%rax
mov    0x2e27(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e14(%rip),%rax
or     (%rax),%esi
lea    0xe23(%rip),%rdi
mov    $0x1ff,%edx
call   1090 <open@plt>
test   %eax,%eax
je     1223 <create_Result_file+0xb3>
mov    %eax,%ebx
xor    %r14d,%r14d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
lea    (%rsp,%rbp,1),%rsi
add    $0x10,%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   1030 <write@plt>
add    $0x8,%rbp
cmp    $0x27100,%rbp
jne    1200 <create_Result_file+0x90>
jmp    1237 <create_Result_file+0xc7>
lea    0xde5(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%r14d
xor    %ebx,%ebx
mov    %ebx,%edi
call   1060 <close@plt>
mov    %r14d,%eax
add    $0x27110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"ratan2\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [19 x i8] c"error opening file\00"
define i32 @create_Result_file() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20000 x double]
%5 = alloca double
%6 = alloca i8*
%7 = alloca i32
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 20000, i32* %3
%8 = load i32, i32* %3
%9 = sitofp i32 %8 to x86_fp80
%10 = fdiv x86_fp80 0xK4001C90FDAA22168C235, %9
%11 = fptrunc x86_fp80 %10 to double
store double %11, double* %5
store i32 0, i32* %2
br label %12
12: ; preds = %31, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %34
16: ; preds = %12
%17 = load double, double* %5
%18 = load i32, i32* %2
%19 = sitofp i32 %18 to double
%20 = fmul double %17, %19
%21 = call i32 @sin(double %20)
%22 = load double, double* %5
%23 = load i32, i32* %2
%24 = sitofp i32 %23 to double
%25 = fmul double %22, %24
%26 = call i32 @cos(double %25)
%27 = call double @atan2(i32 %21, i32 %26)
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %29
store double %27, double* %30
br label %31
31: ; preds = %16
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %12
34: ; preds = %12
%35 = load i8*, i8** %6
%36 = load i32, i32* @O_RDWR
%37 = load i32, i32* @O_CREAT
%38 = or i32 %36, %37
%39 = load i32, i32* @O_TRUNC
%40 = or i32 %38, %39
%41 = call i32 @open(i8* %35, i32 %40, i32 511)
store i32 %41, i32* %7
%42 = load i32, i32* %7
%43 = icmp ne i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %34
%45 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%46 = load i32, i32* %7
%47 = call i32 @close(i32 %46)
store i32 -1, i32* %1
br label %65
48: ; preds = %34
store i32 0, i32* %2
br label %49
49: ; preds = %59, %48
%50 = load i32, i32* %2
%51 = load i32, i32* %3
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %62
53: ; preds = %49
%54 = load i32, i32* %7
%55 = load i32, i32* %2
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [20000 x double], [20000 x double]* %4, i64 0, i64 %56
%58 = call i32 @write(i32 %54, double* %57, i32 8)
br label %59
59: ; preds = %53
%60 = load i32, i32* %2
%61 = add nsw i32 %60, 1
store i32 %61, i32* %2
br label %49
62: ; preds = %49
%63 = load i32, i32* %7
%64 = call i32 @close(i32 %63)
store i32 0, i32* %1
br label %65
65: ; preds = %62, %44
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@.str = [7 x i8] c"ratan2\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.1 = [19 x i8] c"error opening file\00"
define i32 @create_Result_file() {
%1 = alloca [20000 x double]
%2 = bitcast [20000 x double]* %1 to i8*
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %12, %3 ]
%5 = trunc i64 %4 to i32
%6 = sitofp i32 %5 to double
%7 = fmul double %6, 0x3F3496B7C53C5B02
%8 = tail call i32 @sin(double %7)
%9 = tail call i32 @cos(double %7)
%10 = tail call double @atan2(i32 %8, i32 %9)
%11 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %4
store double %10, double* %11
%12 = add nuw nsw i64 %4, 1
%13 = icmp eq i64 %12, 20000
br i1 %13, label %14, label %3
14: ; preds = %3
%15 = load i32, i32* @O_RDWR
%16 = load i32, i32* @O_CREAT
%17 = or i32 %16, %15
%18 = load i32, i32* @O_TRUNC
%19 = or i32 %17, %18
%20 = tail call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %19, i32 511)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %30
24: ; preds = %14, %24
%25 = phi i64 [ %28, %24 ], [ 0, %14 ]
%26 = getelementptr inbounds [20000 x double], [20000 x double]* %1, i64 0, i64 %25
%27 = call i32 @write(i32 %20, double* %26, i32 8)
%28 = add nuw nsw i64 %25, 1
%29 = icmp eq i64 %28, 20000
br i1 %29, label %30, label %24
30: ; preds = %24, %22
%31 = phi i32 [ 0, %22 ], [ %20, %24 ]
%32 = phi i32 [ -1, %22 ], [ 0, %24 ]
%33 = tail call i32 @close(i32 %31)
ret i32 %32
}