#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__ atoi(char *);
int /*<<< orphan*/ printf(char *, float);
int main(int argc, char **argv) {
  int sum = 0;
  for (int i = 1; i < argc; i++) {
    char *currentStr = argv[i];
    sum += atoi(currentStr);
  }
  printf("The average of the parameters is: %.2f\n", ((float)sum / (argc - 1)));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1184 <main+0x64>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <atoi@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <main+0x24>
cvtsi2ssl -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
xorps  %xmm0,%xmm0
cmp    $0x2,%edi
jl     115b <main+0x3b>
mov    %rsi,%r15
mov    %r14d,%r12d
xor    %ebx,%ebx
mov    $0x1,%ebp
mov    (%r15,%rbp,8),%rdi
call   1040 <atoi@plt>
add    %eax,%ebx
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1140 <main+0x20>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
add    $0xffffffff,%r14d
cvtsi2ss %r14d,%xmm1
divss  %xmm1,%xmm0
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"The average of the parameters is: %.2f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %7
br label %9
9: ; preds = %25, %2
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = call i64 @atoi(i8* %19)
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = add nsw i64 %22, %20
%24 = trunc i64 %23 to i32
store i32 %24, i32* %6
br label %25
25: ; preds = %13
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %9
28: ; preds = %9
%29 = load i32, i32* %6
%30 = sitofp i32 %29 to float
%31 = load i32, i32* %4
%32 = sub nsw i32 %31, 1
%33 = sitofp i32 %32 to float
%34 = fdiv float %30, %33
%35 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), float %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"The average of the parameters is: %.2f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %14
6: ; preds = %14
%7 = sitofp i32 %21 to float
br label %8
8: ; preds = %6, %2
%9 = phi float [ 0.000000e+00, %2 ], [ %7, %6 ]
%10 = add nsw i32 %0, -1
%11 = sitofp i32 %10 to float
%12 = fdiv float %9, %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), float %12)
ret i32 0
14: ; preds = %4, %14
%15 = phi i64 [ 1, %4 ], [ %22, %14 ]
%16 = phi i32 [ 0, %4 ], [ %21, %14 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %15
%18 = load i8*, i8** %17
%19 = tail call i64 @atoi(i8* %18)
%20 = trunc i64 %19 to i32
%21 = add i32 %16, %20
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, %5
br i1 %23, label %6, label %14
}