#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 /*<<< orphan*/ isfinite(double);
double pow(double, double);
int /*<<< orphan*/ printf(char *, double, double, double, double, double);
double sin(int);
double tan(int);
double delay(double iat, double fat, int NDELAY) {
  int i;
  double sc = 1.0;
  for (i = 1; i < NDELAY; i++) {
    double tg = tan(i * sc / iat);
    double sen = sin(i * sc / fat);
    double p1 = pow(tg, -3.0) + 0.34;
    double p2 = pow(sen, 5.0);
    sc += 13.4334 / p1 + p2;
    if (!isfinite(sc) || !isfinite(p1) || !isfinite(p2) || !isfinite(tg) ||
        !isfinite(sen))
      printf("sc: %f | p1 %f | p2 %f | tg %f | sen %f\n", sc, p1, p2, tg, sen);
  }
  return (iat * sc);
}


x86 assembly (clang, -O0):
<delay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  0xe93(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12ac <delay+0x15c>
cvtsi2sdl -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <tan@plt>
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe54(%rip),%xmm1
call   1070 <pow@plt>
movsd  0xe3f(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe21(%rip),%xmm1
call   1070 <pow@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xe07(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <isfinite@plt>
cmp    $0x0,%eax
je     1274 <delay+0x124>
movsd  -0x38(%rbp),%xmm0
call   1050 <isfinite@plt>
cmp    $0x0,%eax
je     1274 <delay+0x124>
movsd  -0x40(%rbp),%xmm0
call   1050 <isfinite@plt>
cmp    $0x0,%eax
je     1274 <delay+0x124>
movsd  -0x28(%rbp),%xmm0
call   1050 <isfinite@plt>
cmp    $0x0,%eax
je     1274 <delay+0x124>
movsd  -0x30(%rbp),%xmm0
call   1050 <isfinite@plt>
cmp    $0x0,%eax
jne    1299 <delay+0x149>
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
lea    0xd94(%rip),%rdi
call   1030 <printf@plt>
jmp    129e <delay+0x14e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1179 <delay+0x29>
movsd  -0x8(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delay>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x28(%rsp)
cmp    $0x2,%edi
jl     12cd <delay+0x17d>
mov    %edi,%ebx
add    $0xffffffff,%ebx
movsd  0xe87(%rip),%xmm0
lea    0xea8(%rip),%r14
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
jmp    11cd <delay+0x7d>
nopl   0x0(%rax)
mov    %r14,%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
call   1030 <printf@plt>
movsd  0x40(%rsp),%xmm1
addsd  0xe3c(%rip),%xmm1
add    $0xffffffff,%ebx
je     12db <delay+0x18b>
movsd  0x8(%rsp),%xmm0
movsd  %xmm1,0x40(%rsp)
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
divsd  0x28(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <tan@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
divsd  0x38(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x20(%rsp),%xmm0
movsd  0xde7(%rip),%xmm1
call   1070 <pow@plt>
addsd  0xde2(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0xdd6(%rip),%xmm1
call   1070 <pow@plt>
movapd %xmm0,%xmm1
movsd  0xdcd(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
movsd  %xmm1,0x30(%rsp)
addsd  %xmm1,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <isfinite@plt>
test   %eax,%eax
je     1190 <delay+0x40>
movsd  0x10(%rsp),%xmm0
call   1050 <isfinite@plt>
test   %eax,%eax
je     1190 <delay+0x40>
movsd  0x30(%rsp),%xmm0
call   1050 <isfinite@plt>
test   %eax,%eax
je     1190 <delay+0x40>
movsd  0x20(%rsp),%xmm0
call   1050 <isfinite@plt>
test   %eax,%eax
je     1190 <delay+0x40>
movsd  0x18(%rsp),%xmm0
call   1050 <isfinite@plt>
test   %eax,%eax
jne    11b6 <delay+0x66>
jmp    1190 <delay+0x40>
movsd  0xd2b(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0x28(%rsp),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [41 x i8] c"sc: %f | p1 %f | p2 %f | tg %f | sen %f\0A\00"
define double @delay(double %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %4
store double %1, double* %5
store i32 %2, i32* %6
store double 1.000000e+00, double* %8
store i32 1, i32* %7
br label %13
13: ; preds = %72, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %75
17: ; preds = %13
%18 = load i32, i32* %7
%19 = sitofp i32 %18 to double
%20 = load double, double* %8
%21 = fmul double %19, %20
%22 = load double, double* %4
%23 = fdiv double %21, %22
%24 = fptosi double %23 to i32
%25 = call double @tan(i32 %24)
store double %25, double* %9
%26 = load i32, i32* %7
%27 = sitofp i32 %26 to double
%28 = load double, double* %8
%29 = fmul double %27, %28
%30 = load double, double* %5
%31 = fdiv double %29, %30
%32 = fptosi double %31 to i32
%33 = call double @sin(i32 %32)
store double %33, double* %10
%34 = load double, double* %9
%35 = call double @pow(double %34, double -3.000000e+00)
%36 = fadd double %35, 3.400000e-01
store double %36, double* %11
%37 = load double, double* %10
%38 = call double @pow(double %37, double 5.000000e+00)
store double %38, double* %12
%39 = load double, double* %11
%40 = fdiv double 1.343340e+01, %39
%41 = load double, double* %12
%42 = fadd double %40, %41
%43 = load double, double* %8
%44 = fadd double %43, %42
store double %44, double* %8
%45 = load double, double* %8
%46 = call i32 @isfinite(double %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %64
48: ; preds = %17
%49 = load double, double* %11
%50 = call i32 @isfinite(double %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %64
52: ; preds = %48
%53 = load double, double* %12
%54 = call i32 @isfinite(double %53)
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %64
56: ; preds = %52
%57 = load double, double* %9
%58 = call i32 @isfinite(double %57)
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load double, double* %10
%62 = call i32 @isfinite(double %61)
%63 = icmp ne i32 %62, 0
br i1 %63, label %71, label %64
64: ; preds = %60, %56, %52, %48, %17
%65 = load double, double* %8
%66 = load double, double* %11
%67 = load double, double* %12
%68 = load double, double* %9
%69 = load double, double* %10
%70 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), double %65, double %66, double %67, double %68, double %69)
br label %71
71: ; preds = %64, %60
br label %72
72: ; preds = %71
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %7
br label %13
75: ; preds = %13
%76 = load double, double* %4
%77 = load double, double* %8
%78 = fmul double %76, %77
ret double %78
}

LLVM IR (-O2):
@.str = [41 x i8] c"sc: %f | p1 %f | p2 %f | tg %f | sen %f\0A\00"
define double @delay(double %0, double %1, i32 %2) {
%4 = icmp sgt i32 %2, 1
br i1 %4, label %5, label %41
5: ; preds = %3, %38
%6 = phi i32 [ %39, %38 ], [ 1, %3 ]
%7 = phi double [ %21, %38 ], [ 1.000000e+00, %3 ]
%8 = sitofp i32 %6 to double
%9 = fmul double %7, %8
%10 = fdiv double %9, %0
%11 = fptosi double %10 to i32
%12 = tail call double @tan(i32 %11)
%13 = fdiv double %9, %1
%14 = fptosi double %13 to i32
%15 = tail call double @sin(i32 %14)
%16 = tail call double @pow(double %12, double -3.000000e+00)
%17 = fadd double %16, 3.400000e-01
%18 = tail call double @pow(double %15, double 5.000000e+00)
%19 = fdiv double 1.343340e+01, %17
%20 = fadd double %18, %19
%21 = fadd double %7, %20
%22 = tail call i32 @isfinite(double %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %36, label %24
24: ; preds = %5
%25 = tail call i32 @isfinite(double %17)
%26 = icmp eq i32 %25, 0
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = tail call i32 @isfinite(double %18)
%29 = icmp eq i32 %28, 0
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = tail call i32 @isfinite(double %12)
%32 = icmp eq i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = tail call i32 @isfinite(double %15)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33, %30, %27, %24, %5
%37 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), double %21, double %17, double %18, double %12, double %15)
br label %38
38: ; preds = %36, %33
%39 = add nuw nsw i32 %6, 1
%40 = icmp eq i32 %39, %2
br i1 %40, label %41, label %5
41: ; preds = %38, %3
%42 = phi double [ 1.000000e+00, %3 ], [ %21, %38 ]
%43 = fmul double %42, %0
ret double %43
}