#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 */
int GreatestCommonDenominator(int, int);
int GreatestCommonDenominatorArray(int iNumbers[], int iCount) {
  while (iCount != 1) {
    int iTmpCount = iCount - (iCount % 2);
    for (int i = 0; i < (iTmpCount / 2); ++i) {
      iNumbers[i] =
          GreatestCommonDenominator(iNumbers[i * 2], iNumbers[(i * 2) + 1]);
    }
    if (iCount % 2) {
      iNumbers[iTmpCount / 2] = iNumbers[iCount - 1];
    }
    iCount = (iTmpCount / 2) + (iCount % 2);
  }
  return iNumbers[0];
}


x86 assembly (clang, -O0):
<GreatestCommonDenominatorArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     1219 <GreatestCommonDenominatorArray+0x109>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
sub    %edx,%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11aa <GreatestCommonDenominatorArray+0x9a>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <GreatestCommonDenominator@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <GreatestCommonDenominatorArray+0x39>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11f3 <GreatestCommonDenominatorArray+0xe3>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x2c(%rbp),%edx
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%eax
add    %edx,%eax
mov    %eax,-0xc(%rbp)
jmp    111f <GreatestCommonDenominatorArray+0xf>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GreatestCommonDenominatorArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    $0x1,%esi
jne    1134 <GreatestCommonDenominatorArray+0x24>
mov    (%rbx),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %esi,%r14d
mov    %esi,%r12d
jmp    114c <GreatestCommonDenominatorArray+0x3c>
nopl   0x0(%rax)
add    %r15d,%r12d
mov    %r12d,%r14d
cmp    $0x1,%r12d
je     1123 <GreatestCommonDenominatorArray+0x13>
shr    $0x1f,%r12d
add    %r14d,%r12d
mov    %r12d,%eax
and    $0xfffffffe,%eax
mov    %r14d,%r15d
sub    %eax,%r15d
sar    %r12d
cmp    $0x2,%r14d
jl     1188 <GreatestCommonDenominatorArray+0x78>
mov    %r12d,%r13d
xor    %ebp,%ebp
nopl   (%rax)
mov    (%rbx,%rbp,8),%edi
mov    0x4(%rbx,%rbp,8),%esi
call   1030 <GreatestCommonDenominator@plt>
mov    %eax,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1170 <GreatestCommonDenominatorArray+0x60>
test   %r15d,%r15d
je     1140 <GreatestCommonDenominatorArray+0x30>
movslq %r14d,%rax
mov    -0x4(%rbx,%rax,4),%eax
movslq %r12d,%rcx
mov    %eax,(%rbx,%rcx,4)
jmp    1140 <GreatestCommonDenominatorArray+0x30>

LLVM IR (-O0):
define i32 @GreatestCommonDenominatorArray(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
br label %7
7: ; preds = %58, %2
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 1
br i1 %9, label %10, label %64
10: ; preds = %7
%11 = load i32, i32* %4
%12 = load i32, i32* %4
%13 = srem i32 %12, 2
%14 = sub nsw i32 %11, %13
store i32 %14, i32* %5
store i32 0, i32* %6
br label %15
15: ; preds = %39, %10
%16 = load i32, i32* %6
%17 = load i32, i32* %5
%18 = sdiv i32 %17, 2
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %42
20: ; preds = %15
%21 = load i32*, i32** %3
%22 = load i32, i32* %6
%23 = mul nsw i32 %22, 2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %21, i64 %24
%26 = load i32, i32* %25
%27 = load i32*, i32** %3
%28 = load i32, i32* %6
%29 = mul nsw i32 %28, 2
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %27, i64 %31
%33 = load i32, i32* %32
%34 = call i32 @GreatestCommonDenominator(i32 %26, i32 %33)
%35 = load i32*, i32** %3
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
store i32 %34, i32* %38
br label %39
39: ; preds = %20
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %15
42: ; preds = %15
%43 = load i32, i32* %4
%44 = srem i32 %43, 2
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %58
46: ; preds = %42
%47 = load i32*, i32** %3
%48 = load i32, i32* %4
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %47, i64 %50
%52 = load i32, i32* %51
%53 = load i32*, i32** %3
%54 = load i32, i32* %5
%55 = sdiv i32 %54, 2
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %53, i64 %56
store i32 %52, i32* %57
br label %58
58: ; preds = %46, %42
%59 = load i32, i32* %5
%60 = sdiv i32 %59, 2
%61 = load i32, i32* %4
%62 = srem i32 %61, 2
%63 = add nsw i32 %60, %62
store i32 %63, i32* %4
br label %7
64: ; preds = %7
%65 = load i32*, i32** %3
%66 = getelementptr inbounds i32, i32* %65, i64 0
%67 = load i32, i32* %66
ret i32 %67
}

LLVM IR (-O2):
define i32 @GreatestCommonDenominatorArray(i32* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 1
br i1 %3, label %35, label %4
4: ; preds = %2, %32
%5 = phi i32 [ %33, %32 ], [ %1, %2 ]
%6 = srem i32 %5, 2
%7 = sdiv i32 %5, 2
%8 = icmp sgt i32 %5, 1
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = zext i32 %7 to i64
br label %13
11: ; preds = %13, %4
%12 = icmp eq i32 %6, 0
br i1 %12, label %32, label %25
13: ; preds = %9, %13
%14 = phi i64 [ 0, %9 ], [ %23, %13 ]
%15 = shl nuw nsw i64 %14, 1
%16 = getelementptr inbounds i32, i32* %0, i64 %15
%17 = load i32, i32* %16
%18 = or i64 %15, 1
%19 = getelementptr inbounds i32, i32* %0, i64 %18
%20 = load i32, i32* %19
%21 = tail call i32 @GreatestCommonDenominator(i32 %17, i32 %20)
%22 = getelementptr inbounds i32, i32* %0, i64 %14
store i32 %21, i32* %22
%23 = add nuw nsw i64 %14, 1
%24 = icmp eq i64 %23, %10
br i1 %24, label %11, label %13
25: ; preds = %11
%26 = add nsw i32 %5, -1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %0, i64 %27
%29 = load i32, i32* %28
%30 = sext i32 %7 to i64
%31 = getelementptr inbounds i32, i32* %0, i64 %30
store i32 %29, i32* %31
br label %32
32: ; preds = %25, %11
%33 = add nsw i32 %7, %6
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %4
35: ; preds = %32, %2
%36 = load i32, i32* %0
ret i32 %36
}