#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 Gcd(double, double const);
double GcdArray(const double *nums, size_t numsSize) {
  if (!nums || numsSize < 1)
    return 0.0;
  double gcd = nums[0];
  for (size_t i = 0; i < numsSize - 1; ++i) {
    gcd = Gcd(gcd, nums[i + 1]);
  }
  return gcd;
}


x86 assembly (clang, -O0):
<GcdArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1136 <GcdArray+0x26>
cmpq   $0x1,-0x18(%rbp)
jae    1143 <GcdArray+0x33>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a5 <GcdArray+0x95>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    119b <GcdArray+0x8b>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  0x8(%rax,%rcx,8),%xmm1
call   1030 <Gcd@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1158 <GcdArray+0x48>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GcdArray>:
push   %r15
push   %r14
push   %rbx
xorps  %xmm0,%xmm0
test   %rdi,%rdi
je     1154 <GcdArray+0x44>
mov    %rsi,%r14
test   %rsi,%rsi
je     1154 <GcdArray+0x44>
mov    %rdi,%r15
movsd  (%rdi),%xmm0
cmp    $0x1,%r14
je     1154 <GcdArray+0x44>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm1
call   1030 <Gcd@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <GcdArray+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @GcdArray(double* %0, i64 %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca i64
%6 = alloca double
%7 = alloca i64
store double* %0, double** %4
store i64 %1, i64* %5
%8 = load double*, double** %4
%9 = icmp ne double* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i64, i64* %5
%12 = icmp ult i64 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %10, %2
store double 0.000000e+00, double* %3
br label %36
14: ; preds = %10
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
store double %17, double* %6
store i64 0, i64* %7
br label %18
18: ; preds = %31, %14
%19 = load i64, i64* %7
%20 = load i64, i64* %5
%21 = sub i64 %20, 1
%22 = icmp ult i64 %19, %21
br i1 %22, label %23, label %34
23: ; preds = %18
%24 = load double, double* %6
%25 = load double*, double** %4
%26 = load i64, i64* %7
%27 = add i64 %26, 1
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = call double @Gcd(double %24, double %29)
store double %30, double* %6
br label %31
31: ; preds = %23
%32 = load i64, i64* %7
%33 = add i64 %32, 1
store i64 %33, i64* %7
br label %18
34: ; preds = %18
%35 = load double, double* %6
store double %35, double* %3
br label %36
36: ; preds = %34, %13
%37 = load double, double* %3
ret double %37
}

LLVM IR (-O2):
define double @GcdArray(double* %0, i64 %1) {
%3 = icmp eq double* %0, null
%4 = icmp eq i64 %1, 0
%5 = or i1 %3, %4
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = load double, double* %0
%8 = add i64 %1, -1
%9 = icmp eq i64 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %6, %10
%11 = phi i64 [ %13, %10 ], [ 0, %6 ]
%12 = phi double [ %16, %10 ], [ %7, %6 ]
%13 = add nuw i64 %11, 1
%14 = getelementptr inbounds double, double* %0, i64 %13
%15 = load double, double* %14
%16 = tail call double @Gcd(double %12, double %15)
%17 = icmp eq i64 %13, %8
br i1 %17, label %18, label %10
18: ; preds = %10, %6, %2
%19 = phi double [ 0.000000e+00, %2 ], [ %7, %6 ], [ %16, %10 ]
ret double %19
}