#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 strtof(char *, int /*<<< orphan*/ *);
float sum(int num, char **numbers) {
  int loop;
  float s = 0.0;
  if (num == 0 || numbers == NULL)
    return 0.0;
  for (loop = 0; loop < num; loop++)
    s = s + strtof(numbers[loop], NULL);
  return s;
}


x86 assembly (clang, -O0):
<sum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     113c <sum+0x2c>
cmpq   $0x0,-0x10(%rbp)
jne    1149 <sum+0x39>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11a4 <sum+0x94>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119a <sum+0x8a>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtof@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <sum+0x40>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
test   %edi,%edi
jle    1160 <sum+0x50>
mov    %rsi,%r14
test   %rsi,%rsi
je     1160 <sum+0x50>
mov    %edi,%r15d
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
movss  %xmm0,0xc(%rsp)
mov    (%r14,%rbx,8),%rdi
xor    %esi,%esi
call   1030 <strtof@plt>
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
movss  0xc(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <sum+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float @sum(i32 %0, i8** %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca float
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 0.000000e+00, float* %7
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = icmp eq i8** %11, null
br i1 %12, label %13, label %14
13: ; preds = %10, %2
store float 0.000000e+00, float* %3
br label %33
14: ; preds = %10
store i32 0, i32* %6
br label %15
15: ; preds = %28, %14
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %31
19: ; preds = %15
%20 = load float, float* %7
%21 = load i8**, i8*** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call float @strtof(i8* %25, i32* null)
%27 = fadd float %20, %26
store float %27, float* %7
br label %28
28: ; preds = %19
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %15
31: ; preds = %15
%32 = load float, float* %7
store float %32, float* %3
br label %33
33: ; preds = %31, %13
%34 = load float, float* %3
ret float %34
}

LLVM IR (-O2):
define float @sum(i32 %0, i8** %1) {
%3 = icmp ne i8** %1, null
%4 = icmp sgt i32 %0, 0
%5 = and i1 %4, %3
br i1 %5, label %6, label %17
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %15, %8 ]
%10 = phi float [ 0.000000e+00, %6 ], [ %14, %8 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %9
%12 = load i8*, i8** %11
%13 = tail call float @strtof(i8* nocapture %12, i32* null)
%14 = fadd float %10, %13
%15 = add nuw nsw i64 %9, 1
%16 = icmp eq i64 %15, %7
br i1 %16, label %17, label %8
17: ; preds = %8, %2
%18 = phi float [ 0.000000e+00, %2 ], [ %14, %8 ]
ret float %18
}