#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 sinf(int);
float sawf(float a) {
  float v = 0.0f;
  int km = 100;
  for (int k = 1; k <= km; k++) {
    v += sinf(k * a) / k;
  }
  return 4.0f / 3.14159265358979323846 * v;
}


x86 assembly (clang, -O0):
<sawf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x64,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1172 <sawf+0x62>
cvtsi2ssl -0x10(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1030 <sinf@plt>
cltd
idivl  -0x10(%rbp)
cvtsi2ss %eax,%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1133 <sawf+0x23>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe7d(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sawf>:
push   %rbp
push   %rbx
push   %rax
movss  %xmm0,0x4(%rsp)
xorps  %xmm0,%xmm0
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
mulss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1030 <sinf@plt>
cltd
idiv   %ebx
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
lea    0x1(%rbx),%ebp
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
addss  (%rsp),%xmm1
movss  %xmm1,(%rsp)
mulss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1030 <sinf@plt>
cltd
idiv   %ebp
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  (%rsp),%xmm0
add    $0x2,%ebx
cmp    $0x65,%ebx
jne    1130 <sawf+0x20>
cvtss2sd %xmm0,%xmm0
mulsd  0xe65(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define float @sawf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
store float %0, float* %2
store float 0.000000e+00, float* %3
store i32 100, i32* %4
store i32 1, i32* %5
br label %6
6: ; preds = %22, %1
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %25
10: ; preds = %6
%11 = load i32, i32* %5
%12 = sitofp i32 %11 to float
%13 = load float, float* %2
%14 = fmul float %12, %13
%15 = fptosi float %14 to i32
%16 = call i32 @sinf(i32 %15)
%17 = load i32, i32* %5
%18 = sdiv i32 %16, %17
%19 = sitofp i32 %18 to float
%20 = load float, float* %3
%21 = fadd float %20, %19
store float %21, float* %3
br label %22
22: ; preds = %10
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %6
25: ; preds = %6
%26 = load float, float* %3
%27 = fpext float %26 to double
%28 = fmul double 0x3FF45F306DC9C883, %27
%29 = fptrunc double %28 to float
ret float %29
}

LLVM IR (-O2):
define float @sawf(float %0) {
br label %6
2: ; preds = %6
%3 = fpext float %23 to double
%4 = fmul double %3, 0x3FF45F306DC9C883
%5 = fptrunc double %4 to float
ret float %5
6: ; preds = %6, %1
%7 = phi i32 [ 1, %1 ], [ %24, %6 ]
%8 = phi float [ 0.000000e+00, %1 ], [ %23, %6 ]
%9 = sitofp i32 %7 to float
%10 = fmul float %9, %0
%11 = fptosi float %10 to i32
%12 = tail call i32 @sinf(i32 %11)
%13 = sdiv i32 %12, %7
%14 = sitofp i32 %13 to float
%15 = fadd float %8, %14
%16 = add nuw nsw i32 %7, 1
%17 = sitofp i32 %16 to float
%18 = fmul float %17, %0
%19 = fptosi float %18 to i32
%20 = tail call i32 @sinf(i32 %19)
%21 = sdiv i32 %20, %16
%22 = sitofp i32 %21 to float
%23 = fadd float %15, %22
%24 = add nuw nsw i32 %7, 2
%25 = icmp eq i32 %24, 101
br i1 %25, label %2, label %6
}