#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 */
float KahanSumFloat(int, float *);
int /*<<< orphan*/ KahanTransposeFloat(int, int, float *, float *);
int /*<<< orphan*/ free(float *);
float *malloc(int);
void KahanWrapperFloat(int commsize, int count, float *tempbuf, float *result) {
  float *transpose = malloc(commsize * count * sizeof(float));
  KahanTransposeFloat(commsize, count, tempbuf, transpose);
  for (int j = 0; j < count; ++j) {
    result[j] = KahanSumFloat(commsize, &(transpose[j]));
  }
  free(transpose);
  return;
}


x86 assembly (clang, -O0):
<KahanWrapperFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1060 <KahanTransposeFloat@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c6 <KahanWrapperFloat+0x86>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1040 <KahanSumFloat@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1188 <KahanWrapperFloat+0x48>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<KahanWrapperFloat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %edi,%r13d
imul   %esi,%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %r13d,%edi
mov    %r15d,%esi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1060 <KahanTransposeFloat@plt>
test   %r15d,%r15d
jle    11ab <KahanWrapperFloat+0x6b>
mov    %r15d,%ebp
shl    $0x2,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%r12,%rbx,1),%rsi
mov    %r13d,%edi
call   1040 <KahanSumFloat@plt>
movss  %xmm0,(%r14,%rbx,1)
add    $0x4,%rbx
cmp    %rbx,%rbp
jne    1190 <KahanWrapperFloat+0x50>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @KahanWrapperFloat(i32 %0, i32 %1, float* %2, float* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store float* %2, float** %7
store float* %3, float** %8
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = mul nsw i32 %11, %12
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call float* @malloc(i32 %16)
store float* %17, float** %9
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = load float*, float** %7
%21 = load float*, float** %9
%22 = call i32 @KahanTransposeFloat(i32 %18, i32 %19, float* %20, float* %21)
store i32 0, i32* %10
br label %23
23: ; preds = %38, %4
%24 = load i32, i32* %10
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %41
27: ; preds = %23
%28 = load i32, i32* %5
%29 = load float*, float** %9
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float, float* %29, i64 %31
%33 = call float @KahanSumFloat(i32 %28, float* %32)
%34 = load float*, float** %8
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds float, float* %34, i64 %36
store float %33, float* %37
br label %38
38: ; preds = %27
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
store i32 %40, i32* %10
br label %23
41: ; preds = %23
%42 = load float*, float** %9
%43 = call i32 @free(float* %42)
ret void
}

LLVM IR (-O2):
define void @KahanWrapperFloat(i32 %0, i32 %1, float* %2, float* nocapture writeonly %3) {
%5 = shl i32 %0, 2
%6 = mul i32 %5, %1
%7 = tail call float* @malloc(i32 %6)
%8 = tail call i32 @KahanTransposeFloat(i32 %0, i32 %1, float* %2, float* %7)
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = zext i32 %1 to i64
br label %14
12: ; preds = %14, %4
%13 = tail call i32 @free(float* %7)
ret void
14: ; preds = %10, %14
%15 = phi i64 [ 0, %10 ], [ %19, %14 ]
%16 = getelementptr inbounds float, float* %7, i64 %15
%17 = tail call float @KahanSumFloat(i32 %0, float* %16)
%18 = getelementptr inbounds float, float* %3, i64 %15
store float %17, float* %18
%19 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, %11
br i1 %20, label %12, label %14
}