#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 fabs(double);
int /*<<< orphan*/ printf(char *);
void doubles_reciprocal(double *farr, int size, double *res_farr) {
  int i;
  for (i = 0; i < size; i++) {
    if (fabs(farr[i]) < 1e-20)
      printf("doubles_reciprocal about to hit a near-zero\n");
    res_farr[i] = 1.0 / farr[i];
  }
}


x86 assembly (clang, -O0):
<doubles_reciprocal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11aa <doubles_reciprocal+0x8a>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe9c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    117a <doubles_reciprocal+0x5a>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  0xe7e(%rip),%xmm0
divsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <doubles_reciprocal+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_reciprocal>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %esi,%esi
jle    1188 <doubles_reciprocal+0x68>
mov    %rdx,%r14
mov    %rdi,%r13
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0xec9(%rip),%r15
jmp    116e <doubles_reciprocal+0x4e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0xea8(%rip),%xmm0
divsd  0x0(%r13,%rbx,8),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
je     1188 <doubles_reciprocal+0x68>
movsd  0x0(%r13,%rbx,8),%xmm0
call   1040 <fabs@plt>
test   %eax,%eax
jg     1150 <doubles_reciprocal+0x30>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    1150 <doubles_reciprocal+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"doubles_reciprocal about to hit a near-zero\0A\00"
define void @doubles_reciprocal(double* %0, i32 %1, double* %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store double* %2, double** %6
store i32 0, i32* %7
br label %8
8: ; preds = %34, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %37
12: ; preds = %8
%13 = load double*, double** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = call i32 @fabs(double %17)
%19 = sitofp i32 %18 to double
%20 = fcmp olt double %19, 0x3BC79CA10C924223
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %21, %12
%24 = load double*, double** %4
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = fdiv double 1.000000e+00, %28
%30 = load double*, double** %6
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
store double %29, double* %33
br label %34
34: ; preds = %23
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %8
37: ; preds = %8
ret void
}

LLVM IR (-O2):
@str = [44 x i8] c"doubles_reciprocal about to hit a near-zero\00"
define void @doubles_reciprocal(double* nocapture %0, i32 %1, double* nocapture writeonly %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %21
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %15
%8 = phi i64 [ 0, %5 ], [ %19, %15 ]
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = load double, double* %9
%11 = tail call i32 @fabs(double %10)
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %13, %7
%16 = load double, double* %9
%17 = fdiv double 1.000000e+00, %16
%18 = getelementptr inbounds double, double* %2, i64 %8
store double %17, double* %18
%19 = add nuw nsw i64 %8, 1
%20 = icmp eq i64 %19, %6
br i1 %20, label %21, label %7
21: ; preds = %15, %3
ret void
}