#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 */
double atof(char *);
double sub(int numValues, char *values[]) {
  double diff = 0.0;
  if (numValues > 0) {
    diff = atof(values[0]);
    int index;
    for (index = 1; index < numValues; index++) {
      diff -= atof(values[index]);
    }
  }
  return diff;
}


x86 assembly (clang, -O0):
<sub>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    118a <sub+0x7a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1185 <sub+0x75>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <atof@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1149 <sub+0x39>
jmp    118a <sub+0x7a>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sub>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
jle    1170 <sub+0x60>
mov    %rsi,%r14
mov    %edi,%ebp
mov    (%rsi),%rdi
call   1030 <atof@plt>
cmp    $0x1,%ebp
je     1173 <sub+0x63>
mov    %ebp,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x8(%rsp)
mov    (%r14,%rbx,8),%rdi
call   1030 <atof@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <sub+0x30>
jmp    1173 <sub+0x63>
xorps  %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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