#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 */
scalar_t__ analogRead(int);
int /*<<< orphan*/ delay(int);
float MGRead(int mg_pin) {
  int i;
  float v = 0;
  for (i = 0; i < (5); i++) {
    v += analogRead(mg_pin);
    delay((50));
  }
  v = (v / (5)) * 5 / 1024;
  return v;
}


x86 assembly (clang, -O0):
<MGRead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1173 <MGRead+0x53>
mov    -0x4(%rbp),%edi
call   1040 <analogRead@plt>
cvtsi2ss %rax,%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    $0x32,%edi
call   1030 <delay@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113a <MGRead+0x1a>
movss  -0xc(%rbp),%xmm0
movss  0xe84(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe78(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xe68(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MGRead>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
call   1040 <analogRead@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x32,%edi
call   1030 <delay@plt>
mov    %ebx,%edi
call   1040 <analogRead@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x32,%edi
call   1030 <delay@plt>
mov    %ebx,%edi
call   1040 <analogRead@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x32,%edi
call   1030 <delay@plt>
mov    %ebx,%edi
call   1040 <analogRead@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x32,%edi
call   1030 <delay@plt>
mov    %ebx,%edi
call   1040 <analogRead@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x32,%edi
call   1030 <delay@plt>
movss  0xe23(%rip),%xmm1
movss  0xc(%rsp),%xmm0
divss  %xmm1,%xmm0
mulss  %xmm1,%xmm0
mulss  0xe11(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @MGRead(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
store i32 %0, i32* %2
store float 0.000000e+00, float* %4
store i32 0, i32* %3
br label %5
5: ; preds = %15, %1
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %2
%10 = call i64 @analogRead(i32 %9)
%11 = sitofp i64 %10 to float
%12 = load float, float* %4
%13 = fadd float %12, %11
store float %13, float* %4
%14 = call i32 @delay(i32 50)
br label %15
15: ; preds = %8
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %5
18: ; preds = %5
%19 = load float, float* %4
%20 = fdiv float %19, 5.000000e+00
%21 = fmul float %20, 5.000000e+00
%22 = fdiv float %21, 1.024000e+03
store float %22, float* %4
%23 = load float, float* %4
ret float %23
}

LLVM IR (-O2):
define float @MGRead(i32 %0) {
%2 = tail call i64 @analogRead(i32 %0)
%3 = sitofp i64 %2 to float
%4 = tail call i32 @delay(i32 50)
%5 = tail call i64 @analogRead(i32 %0)
%6 = sitofp i64 %5 to float
%7 = fadd float %3, %6
%8 = tail call i32 @delay(i32 50)
%9 = tail call i64 @analogRead(i32 %0)
%10 = sitofp i64 %9 to float
%11 = fadd float %7, %10
%12 = tail call i32 @delay(i32 50)
%13 = tail call i64 @analogRead(i32 %0)
%14 = sitofp i64 %13 to float
%15 = fadd float %11, %14
%16 = tail call i32 @delay(i32 50)
%17 = tail call i64 @analogRead(i32 %0)
%18 = sitofp i64 %17 to float
%19 = fadd float %15, %18
%20 = tail call i32 @delay(i32 50)
%21 = fdiv float %19, 5.000000e+00
%22 = fmul float %21, 5.000000e+00
%23 = fmul float %22, 0x3F50000000000000
ret float %23
}