#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*/ fprintf(int /*<<< orphan*/, char *, float);
int /*<<< orphan*/ stderr;
int work_counter_serial(int);
void custom() {
  float out_time = 0;
  for (short iter = 0; iter < 3; iter++) {
    out_time += work_counter_serial(1000000) / 3;
  }
  fprintf(stderr, "%f\n", out_time);
}


x86 assembly (clang, -O0):
<custom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movw   $0x0,-0x6(%rbp)
movswl -0x6(%rbp),%eax
cmp    $0x3,%eax
jge    1174 <custom+0x54>
mov    $0xf4240,%edi
call   1030 <work_counter_serial@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0x6(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x6(%rbp)
jmp    1136 <custom+0x16>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
movss  -0x4(%rbp),%xmm0
lea    0xe77(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<custom>:
push   %rax
mov    $0xf4240,%edi
call   1030 <work_counter_serial@plt>
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0xf4240,%edi
call   1030 <work_counter_serial@plt>
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0x4(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
mov    $0xf4240,%edi
call   1030 <work_counter_serial@plt>
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
addss  0x4(%rsp),%xmm0
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
pop    %rax
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [4 x i8] c"%f\0A\00"
define void @custom() {
%1 = alloca float
%2 = alloca i16
store float 0.000000e+00, float* %1
store i16 0, i16* %2
br label %3
3: ; preds = %13, %0
%4 = load i16, i16* %2
%5 = sext i16 %4 to i32
%6 = icmp slt i32 %5, 3
br i1 %6, label %7, label %16
7: ; preds = %3
%8 = call i32 @work_counter_serial(i32 1000000)
%9 = sdiv i32 %8, 3
%10 = sitofp i32 %9 to float
%11 = load float, float* %1
%12 = fadd float %11, %10
store float %12, float* %1
br label %13
13: ; preds = %7
%14 = load i16, i16* %2
%15 = add i16 %14, 1
store i16 %15, i16* %2
br label %3
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = load float, float* %1
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), float %18)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"%f\0A\00"
define void @custom() {
%1 = tail call i32 @work_counter_serial(i32 1000000)
%2 = sdiv i32 %1, 3
%3 = sitofp i32 %2 to float
%4 = tail call i32 @work_counter_serial(i32 1000000)
%5 = sdiv i32 %4, 3
%6 = sitofp i32 %5 to float
%7 = fadd float %3, %6
%8 = tail call i32 @work_counter_serial(i32 1000000)
%9 = sdiv i32 %8, 3
%10 = sitofp i32 %9 to float
%11 = fadd float %7, %10
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), float %11)
ret void
}