#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*/ fatalx(char *);
void vinvert(double *a, double *b, int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (b[i] == 0.0)
      fatalx("(vinvert): zero value\n");
    a[i] = 1.0 / b[i];
  }
}


x86 assembly (clang, -O0):
<vinvert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1192 <vinvert+0x82>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1162 <vinvert+0x52>
jp     1162 <vinvert+0x52>
lea    0xeab(%rip),%rdi
call   1030 <fatalx@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  0xe8e(%rip),%xmm0
divsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <vinvert+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vinvert>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
jle    117f <vinvert+0x6f>
mov    %rsi,%r13
mov    %rdi,%r14
mov    %edx,%r12d
xor    %ebx,%ebx
lea    0xee1(%rip),%r15
jmp    115b <vinvert+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0xeb8(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
je     117f <vinvert+0x6f>
movsd  0x0(%r13,%rbx,8),%xmm0
ucomisd 0xe9e(%rip),%xmm0
jne    1140 <vinvert+0x30>
jp     1140 <vinvert+0x30>
mov    %r15,%rdi
call   1030 <fatalx@plt>
movsd  0x0(%r13,%rbx,8),%xmm0
jmp    1140 <vinvert+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [23 x i8] c"(vinvert): zero value\0A\00"
define void @vinvert(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %32, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %35
12: ; preds = %8
%13 = load double*, double** %5
%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 = fcmp oeq double %17, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = call i32 @fatalx(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %12
%22 = load double*, double** %5
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = fdiv double 1.000000e+00, %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 = %21
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %8
35: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"(vinvert): zero value\0A\00"
define void @vinvert(double* nocapture writeonly %0, double* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %21
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %15
%8 = phi i64 [ 0, %5 ], [ %19, %15 ]
%9 = getelementptr inbounds double, double* %1, i64 %8
%10 = load double, double* %9
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = tail call i32 @fatalx(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%14 = load double, double* %9
br label %15
15: ; preds = %12, %7
%16 = phi double [ %14, %12 ], [ %10, %7 ]
%17 = fdiv double 1.000000e+00, %16
%18 = getelementptr inbounds double, double* %0, 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
}