#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, double);
int /*<<< orphan*/ sprintf(char *, char *, int /*<<< orphan*/);
void transf_print(double *power, double freq_max, double freq_min,
                  double freq_delta) {
  FILE *file;
  static int id;
  char fname[16];
  int i;
  int size = (freq_max - freq_min) / freq_delta + 1;
  sprintf(fname, "t%d.txt", id++);
  file = fopen(fname, "w");
  for (i = 0; i < size; i++) {
    double f = freq_min + i * freq_delta;
    fprintf(file, "%f %f\n", f, power[i]);
  }
  fclose(file);
}


x86 assembly (clang, -O0):
<transf_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
mov    0x2ebd(%rip),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,0x2eb2(%rip)
lea    0xe6f(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x40(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    1211 <transf_print+0xd1>
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x44(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
movsd  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xe14(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11b9 <transf_print+0x79>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transf_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm1,(%rsp)
subsd  %xmm1,%xmm0
movsd  %xmm2,0x8(%rsp)
divsd  %xmm2,%xmm0
addsd  0xe97(%rip),%xmm0
cvttsd2si %xmm0,%ebp
mov    %rdi,%r14
mov    0x2ece(%rip),%edx
lea    0x1(%rdx),%eax
mov    %eax,0x2ec5(%rip)
lea    0xe82(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    %rax,%r12
test   %ebp,%ebp
jle    11ec <transf_print+0xac>
mov    %ebp,%r13d
xor    %ebx,%ebx
lea    0xe5d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  (%r14,%rbx,8),%xmm1
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11c0 <transf_print+0x80>
mov    %r12,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@transf_print.id = internal global i32 0
@.str = [8 x i8] c"t%d.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%f %f\0A\00"
define void @transf_print(double* %0, double %1, double %2, double %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32*
%10 = alloca [16 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
store double* %0, double** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%14 = load double, double* %6
%15 = load double, double* %7
%16 = fsub double %14, %15
%17 = load double, double* %8
%18 = fdiv double %16, %17
%19 = fadd double %18, 1.000000e+00
%20 = fptosi double %19 to i32
store i32 %20, i32* %12
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%22 = load i32, i32* @transf_print.id
%23 = add nsw i32 %22, 1
store i32 %23, i32* @transf_print.id
%24 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %22)
%25 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %9
store i32 0, i32* %11
br label %27
27: ; preds = %45, %4
%28 = load i32, i32* %11
%29 = load i32, i32* %12
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %48
31: ; preds = %27
%32 = load double, double* %7
%33 = load i32, i32* %11
%34 = sitofp i32 %33 to double
%35 = load double, double* %8
%36 = call double @llvm.fmuladd.f64(double %34, double %35, double %32)
store double %36, double* %13
%37 = load i32*, i32** %9
%38 = load double, double* %13
%39 = load double*, double** %5
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
%44 = call i32 @fprintf(i32* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %38, double %43)
br label %45
45: ; preds = %31
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %27
48: ; preds = %27
%49 = load i32*, i32** %9
%50 = call i32 @fclose(i32* %49)
ret void
}

LLVM IR (-O2):
@transf_print.id = internal unnamed_addr global i32 0
@.str = [8 x i8] c"t%d.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%f %f\0A\00"
define void @transf_print(double* nocapture %0, double %1, double %2, double %3) {
%5 = alloca [16 x i8]
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%7 = fsub double %1, %2
%8 = fdiv double %7, %3
%9 = fadd double %8, 1.000000e+00
%10 = fptosi double %9 to i32
%11 = load i32, i32* @transf_print.id
%12 = add nsw i32 %11, 1
store i32 %12, i32* @transf_print.id
%13 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %11)
%14 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp sgt i32 %10, 0
br i1 %15, label %16, label %28
16: ; preds = %4
%17 = zext i32 %10 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %26, %18 ]
%20 = trunc i64 %19 to i32
%21 = sitofp i32 %20 to double
%22 = tail call double @llvm.fmuladd.f64(double %21, double %3, double %2)
%23 = getelementptr inbounds double, double* %0, i64 %19
%24 = load double, double* %23
%25 = tail call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %22, double %24)
%26 = add nuw nsw i64 %19, 1
%27 = icmp eq i64 %26, %17
br i1 %27, label %28, label %18
28: ; preds = %18, %4
%29 = tail call i32 @fclose(i32* %14)
ret void
}