#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*/ noprintf(char *, int);
int rfprof_len(double **);
double rfprof_sumweight(double **rfdata) {
  double w = 0.0;
  int i, N, NN;
  N = rfprof_len(rfdata);
  noprintf("rfprof_sumweight: rfdata length = %d\n", N);
  NN = (*(int *)rfdata[1]);
  for (i = 1; i <= N; i++)
    w += rfdata[i][NN];
  return w;
}


x86 assembly (clang, -O0):
<rfprof_sumweight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <rfprof_len@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xeb6(%rip),%rdi
call   1030 <noprintf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     119c <rfprof_sumweight+0x7c>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1163 <rfprof_sumweight+0x43>
movsd  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rfprof_sumweight>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <rfprof_len@plt>
mov    %eax,%r14d
lea    0xeca(%rip),%rdi
mov    %eax,%esi
call   1030 <noprintf@plt>
test   %r14d,%r14d
jle    117c <rfprof_sumweight+0x5c>
mov    0x8(%rbx),%rcx
movslq (%rcx),%rax
add    $0x1,%r14d
xorpd  %xmm0,%xmm0
addsd  (%rcx,%rax,8),%xmm0
cmp    $0x2,%r14d
je     11f2 <rfprof_sumweight+0xd2>
lea    -0x2(%r14),%rdx
add    $0xfffffffffffffffd,%r14
mov    %edx,%r8d
and    $0x3,%r8d
cmp    $0x3,%r14
jae    1182 <rfprof_sumweight+0x62>
mov    $0x2,%esi
jmp    11c9 <rfprof_sumweight+0xa9>
xorpd  %xmm0,%xmm0
jmp    11f2 <rfprof_sumweight+0xd2>
and    $0xfffffffffffffffc,%rdx
neg    %rdx
mov    $0x2,%esi
xchg   %ax,%ax
mov    (%rbx,%rsi,8),%rdi
mov    0x8(%rbx,%rsi,8),%rcx
addsd  (%rdi,%rax,8),%xmm0
addsd  (%rcx,%rax,8),%xmm0
mov    0x10(%rbx,%rsi,8),%rcx
addsd  (%rcx,%rax,8),%xmm0
mov    0x18(%rbx,%rsi,8),%rcx
addsd  (%rcx,%rax,8),%xmm0
lea    (%rdx,%rsi,1),%rcx
add    $0x4,%rcx
add    $0x4,%rsi
cmp    $0x2,%rcx
jne    1190 <rfprof_sumweight+0x70>
test   %r8,%r8
je     11f2 <rfprof_sumweight+0xd2>
lea    (%rbx,%rsi,8),%rdx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rdx,%rsi,8),%rcx
addsd  (%rcx,%rax,8),%xmm0
add    $0x1,%rsi
cmp    %rsi,%r8
jne    11e0 <rfprof_sumweight+0xc0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [38 x i8] c"rfprof_sumweight: rfdata length = %d\0A\00"
define double @rfprof_sumweight(double** %0) {
%2 = alloca double**
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store double** %0, double*** %2
store double 0.000000e+00, double* %3
%7 = load double**, double*** %2
%8 = call i32 @rfprof_len(double** %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = call i32 @noprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load double**, double*** %2
%12 = getelementptr inbounds double*, double** %11, i64 1
%13 = load double*, double** %12
%14 = bitcast double* %13 to i32*
%15 = load i32, i32* %14
store i32 %15, i32* %6
store i32 1, i32* %4
br label %16
16: ; preds = %32, %1
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = load double**, double*** %2
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double*, double** %21, i64 %23
%25 = load double*, double** %24
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = load double, double* %3
%31 = fadd double %30, %29
store double %31, double* %3
br label %32
32: ; preds = %20
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %16
35: ; preds = %16
%36 = load double, double* %3
ret double %36
}

LLVM IR (-O2):
@.str = [38 x i8] c"rfprof_sumweight: rfdata length = %d\0A\00"
define double @rfprof_sumweight(double** %0) {
%2 = tail call i32 @rfprof_len(double** %0)
%3 = tail call i32 @noprintf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp slt i32 %2, 1
br i1 %4, label %72, label %5
5: ; preds = %1
%6 = getelementptr inbounds double*, double** %0, i64 1
%7 = bitcast double** %6 to i32**
%8 = load i32*, i32** %7
%9 = load i32, i32* %8
%10 = sext i32 %9 to i64
%11 = add nuw i32 %2, 1
%12 = zext i32 %11 to i64
%13 = bitcast i32* %8 to double*
%14 = getelementptr inbounds double, double* %13, i64 %10
%15 = load double, double* %14
%16 = fadd double %15, 0.000000e+00
%17 = icmp eq i32 %11, 2
br i1 %17, label %72, label %18
18: ; preds = %5
%19 = add nsw i64 %12, -2
%20 = add nsw i64 %12, -3
%21 = and i64 %19, 3
%22 = icmp ult i64 %20, 3
br i1 %22, label %55, label %23
23: ; preds = %18
%24 = and i64 %19, -4
br label %25
25: ; preds = %25, %23
%26 = phi i64 [ 2, %23 ], [ %52, %25 ]
%27 = phi double [ %16, %23 ], [ %51, %25 ]
%28 = phi i64 [ 0, %23 ], [ %53, %25 ]
%29 = getelementptr inbounds double*, double** %0, i64 %26
%30 = load double*, double** %29
%31 = getelementptr inbounds double, double* %30, i64 %10
%32 = load double, double* %31
%33 = fadd double %27, %32
%34 = or i64 %26, 1
%35 = getelementptr inbounds double*, double** %0, i64 %34
%36 = load double*, double** %35
%37 = getelementptr inbounds double, double* %36, i64 %10
%38 = load double, double* %37
%39 = fadd double %33, %38
%40 = add nuw nsw i64 %26, 2
%41 = getelementptr inbounds double*, double** %0, i64 %40
%42 = load double*, double** %41
%43 = getelementptr inbounds double, double* %42, i64 %10
%44 = load double, double* %43
%45 = fadd double %39, %44
%46 = add nuw nsw i64 %26, 3
%47 = getelementptr inbounds double*, double** %0, i64 %46
%48 = load double*, double** %47
%49 = getelementptr inbounds double, double* %48, i64 %10
%50 = load double, double* %49
%51 = fadd double %45, %50
%52 = add nuw nsw i64 %26, 4
%53 = add i64 %28, 4
%54 = icmp eq i64 %53, %24
br i1 %54, label %55, label %25
55: ; preds = %25, %18
%56 = phi double [ undef, %18 ], [ %51, %25 ]
%57 = phi i64 [ 2, %18 ], [ %52, %25 ]
%58 = phi double [ %16, %18 ], [ %51, %25 ]
%59 = icmp eq i64 %21, 0
br i1 %59, label %72, label %60
60: ; preds = %55, %60
%61 = phi i64 [ %69, %60 ], [ %57, %55 ]
%62 = phi double [ %68, %60 ], [ %58, %55 ]
%63 = phi i64 [ %70, %60 ], [ 0, %55 ]
%64 = getelementptr inbounds double*, double** %0, i64 %61
%65 = load double*, double** %64
%66 = getelementptr inbounds double, double* %65, i64 %10
%67 = load double, double* %66
%68 = fadd double %62, %67
%69 = add nuw nsw i64 %61, 1
%70 = add i64 %63, 1
%71 = icmp eq i64 %70, %21
br i1 %71, label %72, label %60
72: ; preds = %55, %60, %5, %1
%73 = phi double [ 0.000000e+00, %1 ], [ %16, %5 ], [ %56, %55 ], [ %68, %60 ]
ret double %73
}