#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 powf(float, float);
void weight(float ak[], float gamma, int order, float akw[]) {
  int i;
  for (i = 1; i <= order; i++)
    akw[i] = ak[i] * powf(gamma, (float)i);
}


x86 assembly (clang, -O0):
<weight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1183 <weight+0x73>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
call   1030 <powf@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
mulss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112f <weight+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<weight>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11de <weight+0xce>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %esi,%r12d
mov    $0x1,%ebx
cmp    $0x1,%esi
je     11b6 <weight+0xa6>
mov    %r12d,%r13d
and    $0xfffffffe,%r13d
mov    $0x1,%ebx
movss  %xmm0,(%rsp)
nopl   0x0(%rax,%rax,1)
movss  (%r15,%rbx,4),%xmm0
movss  %xmm0,0x4(%rsp)
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
movss  (%rsp),%xmm0
call   1030 <powf@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,(%r14,%rbx,4)
movss  0x4(%r15,%rbx,4),%xmm0
movss  %xmm0,0x4(%rsp)
lea    0x1(%rbx),%rbp
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
movss  (%rsp),%xmm0
call   1030 <powf@plt>
mulss  0x4(%rsp),%xmm0
movss  %xmm0,0x4(%r14,%rbx,4)
add    $0x2,%rbx
cmp    %r13,%rbp
jne    1150 <weight+0x40>
movss  (%rsp),%xmm0
test   $0x1,%r12b
je     11de <weight+0xce>
movss  (%r15,%rbx,4),%xmm1
movss  %xmm1,(%rsp)
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
call   1030 <powf@plt>
mulss  (%rsp),%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @weight(float* %0, float %1, i32 %2, float* %3) {
%5 = alloca float*
%6 = alloca float
%7 = alloca i32
%8 = alloca float*
%9 = alloca i32
store float* %0, float** %5
store float %1, float* %6
store i32 %2, i32* %7
store float* %3, float** %8
store i32 1, i32* %9
br label %10
10: ; preds = %29, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %7
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %32
14: ; preds = %10
%15 = load float*, float** %5
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds float, float* %15, i64 %17
%19 = load float, float* %18
%20 = load float, float* %6
%21 = load i32, i32* %9
%22 = sitofp i32 %21 to float
%23 = call float @powf(float %20, float %22)
%24 = fmul float %19, %23
%25 = load float*, float** %8
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds float, float* %25, i64 %27
store float %24, float* %28
br label %29
29: ; preds = %14
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %10
32: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @weight(float* nocapture %0, float %1, i32 %2, float* nocapture writeonly %3) {
%5 = icmp slt i32 %2, 1
br i1 %5, label %44, label %6
6: ; preds = %4
%7 = zext i32 %2 to i64
%8 = and i64 %7, 1
%9 = icmp eq i32 %2, 1
br i1 %9, label %33, label %10
10: ; preds = %6
%11 = and i64 %7, 4294967294
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 1, %10 ], [ %30, %12 ]
%14 = phi i64 [ 0, %10 ], [ %31, %12 ]
%15 = getelementptr inbounds float, float* %0, i64 %13
%16 = load float, float* %15
%17 = trunc i64 %13 to i32
%18 = sitofp i32 %17 to float
%19 = tail call float @powf(float %1, float %18)
%20 = fmul float %16, %19
%21 = getelementptr inbounds float, float* %3, i64 %13
store float %20, float* %21
%22 = add nuw nsw i64 %13, 1
%23 = getelementptr inbounds float, float* %0, i64 %22
%24 = load float, float* %23
%25 = trunc i64 %22 to i32
%26 = sitofp i32 %25 to float
%27 = tail call float @powf(float %1, float %26)
%28 = fmul float %24, %27
%29 = getelementptr inbounds float, float* %3, i64 %22
store float %28, float* %29
%30 = add nuw nsw i64 %13, 2
%31 = add i64 %14, 2
%32 = icmp eq i64 %31, %11
br i1 %32, label %33, label %12
33: ; preds = %12, %6
%34 = phi i64 [ 1, %6 ], [ %30, %12 ]
%35 = icmp eq i64 %8, 0
br i1 %35, label %44, label %36
36: ; preds = %33
%37 = getelementptr inbounds float, float* %0, i64 %34
%38 = load float, float* %37
%39 = trunc i64 %34 to i32
%40 = sitofp i32 %39 to float
%41 = tail call float @powf(float %1, float %40)
%42 = fmul float %38, %41
%43 = getelementptr inbounds float, float* %3, i64 %34
store float %42, float* %43
br label %44
44: ; preds = %36, %33, %4
ret void
}