#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*/ daxpy(double *, double *, long, double);
void bdiv(double *a, double *diag, long stride_a, long stride_diag, long dimi,
          long dimk) {
  long j, k;
  double alpha;
  for (k = 0; k < dimk; k++) {
    for (j = k + 1; j < dimk; j++) {
      alpha = -diag[k + j * stride_diag];
      daxpy(&a[j * stride_a], &a[k * stride_a], dimi, alpha);
    }
  }
}


x86 assembly (clang, -O0):
<bdiv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    11f2 <bdiv+0xe2>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    11dc <bdiv+0xcc>
mov    -0x10(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%rdx
imul   -0x20(%rbp),%rdx
add    %rdx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rax
imul   -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x40(%rbp),%rax
imul   -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x28(%rbp),%rdx
movsd  -0x48(%rbp),%xmm0
call   1030 <daxpy@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1152 <bdiv+0x42>
jmp    11e1 <bdiv+0xd1>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1138 <bdiv+0x28>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bdiv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,0x10(%rsp)
mov    %rdi,0x8(%rsp)
test   %r9,%r9
jle    1208 <bdiv+0xf8>
mov    %r9,%r12
mov    %r8,%rbx
mov    %rcx,%rbp
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%rdx
lea    (%rdx,%rax,8),%rdx
mov    %rdx,0x20(%rsp)
lea    0x0(,%rax,8),%rdi
lea    (%rsi,%rcx,8),%rax
mov    %rax,0x18(%rsp)
lea    0x8(,%rcx,8),%rax
mov    %rax,0x30(%rsp)
shl    $0x3,%rbp
xor    %eax,%eax
movaps 0xe88(%rip),%xmm1
mov    %rdi,0x38(%rsp)
jmp    1199 <bdiv+0x89>
nop
add    %rdi,0x20(%rsp)
mov    0x30(%rsp),%rax
add    %rax,0x18(%rsp)
mov    0x28(%rsp),%rax
cmp    %r12,%rax
je     1208 <bdiv+0xf8>
lea    0x1(%rax),%rdx
mov    %rdx,0x28(%rsp)
cmp    %r12,%rdx
jge    1180 <bdiv+0x70>
imul   0x10(%rsp),%rax
mov    0x8(%rsp),%rdx
lea    (%rdx,%rax,8),%rax
mov    %rax,0x40(%rsp)
mov    0x18(%rsp),%r14
mov    0x20(%rsp),%r13
mov    0x28(%rsp),%r15
nopw   0x0(%rax,%rax,1)
movsd  (%r14),%xmm0
xorps  %xmm1,%xmm0
mov    %r13,%rdi
mov    0x40(%rsp),%rsi
mov    %rbx,%rdx
call   1030 <daxpy@plt>
movaps 0xe11(%rip),%xmm1
mov    0x38(%rsp),%rdi
add    $0x1,%r15
add    %rdi,%r13
add    %rbp,%r14
cmp    %r12,%r15
jl     11d0 <bdiv+0xc0>
jmp    1180 <bdiv+0x70>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @bdiv(double* %0, double* %1, i64 %2, i64 %3, i64 %4, i64 %5) {
%7 = alloca double*
%8 = alloca double*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca double
store double* %0, double** %7
store double* %1, double** %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i64 %4, i64* %11
store i64 %5, i64* %12
store i64 0, i64* %14
br label %16
16: ; preds = %54, %6
%17 = load i64, i64* %14
%18 = load i64, i64* %12
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %57
20: ; preds = %16
%21 = load i64, i64* %14
%22 = add nsw i64 %21, 1
store i64 %22, i64* %13
br label %23
23: ; preds = %50, %20
%24 = load i64, i64* %13
%25 = load i64, i64* %12
%26 = icmp slt i64 %24, %25
br i1 %26, label %27, label %53
27: ; preds = %23
%28 = load double*, double** %8
%29 = load i64, i64* %14
%30 = load i64, i64* %13
%31 = load i64, i64* %10
%32 = mul nsw i64 %30, %31
%33 = add nsw i64 %29, %32
%34 = getelementptr inbounds double, double* %28, i64 %33
%35 = load double, double* %34
%36 = fneg double %35
store double %36, double* %15
%37 = load double*, double** %7
%38 = load i64, i64* %13
%39 = load i64, i64* %9
%40 = mul nsw i64 %38, %39
%41 = getelementptr inbounds double, double* %37, i64 %40
%42 = load double*, double** %7
%43 = load i64, i64* %14
%44 = load i64, i64* %9
%45 = mul nsw i64 %43, %44
%46 = getelementptr inbounds double, double* %42, i64 %45
%47 = load i64, i64* %11
%48 = load double, double* %15
%49 = call i32 @daxpy(double* %41, double* %46, i64 %47, double %48)
br label %50
50: ; preds = %27
%51 = load i64, i64* %13
%52 = add nsw i64 %51, 1
store i64 %52, i64* %13
br label %23
53: ; preds = %23
br label %54
54: ; preds = %53
%55 = load i64, i64* %14
%56 = add nsw i64 %55, 1
store i64 %56, i64* %14
br label %16
57: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @bdiv(double* %0, double* nocapture %1, i64 %2, i64 %3, i64 %4, i64 %5) {
%7 = icmp sgt i64 %5, 0
br i1 %7, label %10, label %29
8: ; preds = %17, %10
%9 = icmp eq i64 %12, %5
br i1 %9, label %29, label %10
10: ; preds = %6, %8
%11 = phi i64 [ %12, %8 ], [ 0, %6 ]
%12 = add nuw nsw i64 %11, 1
%13 = icmp slt i64 %12, %5
br i1 %13, label %14, label %8
14: ; preds = %10
%15 = mul nsw i64 %11, %2
%16 = getelementptr inbounds double, double* %0, i64 %15
br label %17
17: ; preds = %14, %17
%18 = phi i64 [ %12, %14 ], [ %27, %17 ]
%19 = mul nsw i64 %18, %3
%20 = add nsw i64 %19, %11
%21 = getelementptr inbounds double, double* %1, i64 %20
%22 = load double, double* %21
%23 = fneg double %22
%24 = mul nsw i64 %18, %2
%25 = getelementptr inbounds double, double* %0, i64 %24
%26 = tail call i32 @daxpy(double* %25, double* %16, i64 %4, double %23)
%27 = add nuw nsw i64 %18, 1
%28 = icmp slt i64 %27, %5
br i1 %28, label %17, label %8
29: ; preds = %8, %6
ret void
}