#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 */
char EOF;
int EXIT_SUCCESS;
double GcdArray(double *, int);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int scanf(char *, int *);
int main(void) {
  double values[2] = {0};
  double gcd = 1.0;
  int count = 0;
  int input = 0;
  char c = '\0';
  printf("Enter %d integers: ", 2);
  while (count < 2) {
    while (scanf("%d", &input) != 1) {
      puts("Input invalid. Please try again.");
      count = 0;
      while ((c = getchar()) != '\n' && c != EOF)
        continue;
    }
    values[count] = (double)input;
    ++count;
  }
  while ((c = getchar()) != '\n' && c != EOF)
    continue;
  printf("Greatest common divisor for numbers:");
  gcd = GcdArray(values, count);
  for (int i = 0; i < count; ++i) {
    printf(" %g", values[i]);
  }
  printf(";\nis %g\n", gcd);
  getchar();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
movsd  0xe79(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movb   $0x0,-0x31(%rbp)
lea    0xe63(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x2,-0x2c(%rbp)
jge    1254 <main+0xf4>
jmp    11c0 <main+0x60>
lea    0xe55(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     1237 <main+0xd7>
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x2c(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x31(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x39(%rbp)
je     121d <main+0xbd>
movsbl -0x31(%rbp),%eax
mov    0x2dd6(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    122d <main+0xcd>
jmp    1232 <main+0xd2>
jmp    11ec <main+0x8c>
jmp    11c0 <main+0x60>
cvtsi2sdl -0x30(%rbp),%xmm0
movslq -0x2c(%rbp),%rax
movsd  %xmm0,-0x20(%rbp,%rax,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b1 <main+0x51>
jmp    1259 <main+0xf9>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x31(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x3a(%rbp)
je     128a <main+0x12a>
movsbl -0x31(%rbp),%eax
mov    0x2d69(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x3a(%rbp)
mov    -0x3a(%rbp),%al
test   $0x1,%al
jne    129a <main+0x13a>
jmp    129f <main+0x13f>
jmp    1259 <main+0xf9>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1080 <GcdArray@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12f7 <main+0x197>
movslq -0x38(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
lea    0xd83(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12c5 <main+0x165>
movsd  -0x28(%rbp),%xmm0
lea    0xd66(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    0x2cc0(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xe89(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8a(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0xe81(%rip),%r15
mov    0x2e4b(%rip),%rbp
xor    %r12d,%r12d
jmp    11cd <main+0x7d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %r13d,%r13d
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rsp),%xmm0
movslq %r13d,%rax
movsd  %xmm0,0x10(%rsp,%rax,8)
lea    0x1(%rax),%r12d
test   %eax,%eax
jg     1230 <main+0xe0>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %r12d,%r13d
cmp    $0x1,%eax
jne    1200 <main+0xb0>
jmp    11b3 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
je     11b0 <main+0x60>
mov    %r15,%rdi
call   1030 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11f0 <main+0xa0>
cmp    0x0(%rbp),%al
jne    1210 <main+0xc0>
jmp    11f0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1240 <main+0xf0>
cmp    0x0(%rbp),%al
jne    1230 <main+0xe0>
lea    0xdf1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rdi
mov    %r12d,%esi
call   1070 <GcdArray@plt>
movsd  %xmm0,0x20(%rsp)
test   %r13d,%r13d
js     1299 <main+0x149>
mov    %r12d,%ebp
xor    %ebx,%ebx
lea    0xdeb(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x10(%rsp,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1280 <main+0x130>
lea    0xdc1(%rip),%rdi
movsd  0x20(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2d1d(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter %d integers: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Input invalid. Please try again.\00"
@EOF = global i8 0
@.str.3 = [37 x i8] c"Greatest common divisor for numbers:\00"
@.str.4 = [4 x i8] c" %g\00"
@.str.5 = [9 x i8] c";\0Ais %g\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x double]
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [2 x double]* %2 to i8*
store double 1.000000e+00, double* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i8 0, i8* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 2)
br label %10
10: ; preds = %33, %0
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %41
13: ; preds = %10
br label %14
14: ; preds = %32, %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%16 = icmp ne i32 %15, 1
br i1 %16, label %17, label %33
17: ; preds = %14
%18 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %19
19: ; preds = %31, %17
%20 = call signext i8 (...) @getchar()
store i8 %20, i8* %6
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i8, i8* %6
%25 = sext i8 %24 to i32
%26 = load i8, i8* @EOF
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %25, %27
br label %29
29: ; preds = %23, %19
%30 = phi i1 [ false, %19 ], [ %28, %23 ]
br i1 %30, label %31, label %32
31: ; preds = %29
br label %19
32: ; preds = %29
br label %14
33: ; preds = %14
%34 = load i32, i32* %5
%35 = sitofp i32 %34 to double
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %37
store double %35, double* %38
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %10
41: ; preds = %10
br label %42
42: ; preds = %54, %41
%43 = call signext i8 (...) @getchar()
store i8 %43, i8* %6
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 10
br i1 %45, label %46, label %52
46: ; preds = %42
%47 = load i8, i8* %6
%48 = sext i8 %47 to i32
%49 = load i8, i8* @EOF
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %48, %50
br label %52
52: ; preds = %46, %42
%53 = phi i1 [ false, %42 ], [ %51, %46 ]
br i1 %53, label %54, label %55
54: ; preds = %52
br label %42
55: ; preds = %52
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%57 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 0
%58 = load i32, i32* %4
%59 = call double @GcdArray(double* %57, i32 %58)
store double %59, double* %3
store i32 0, i32* %7
br label %60
60: ; preds = %70, %55
%61 = load i32, i32* %7
%62 = load i32, i32* %4
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %73
64: ; preds = %60
%65 = load i32, i32* %7
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %66
%68 = load double, double* %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %68)
br label %70
70: ; preds = %64
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %60
73: ; preds = %60
%74 = load double, double* %3
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), double %74)
%76 = call signext i8 (...) @getchar()
%77 = load i32, i32* @EXIT_SUCCESS
ret i32 %77
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter %d integers: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Input invalid. Please try again.\00"
@EOF = global i8 0
@.str.3 = [37 x i8] c"Greatest common divisor for numbers:\00"
@.str.4 = [4 x i8] c" %g\00"
@.str.5 = [9 x i8] c";\0Ais %g\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [2 x double]
%2 = alloca i32
%3 = bitcast [2 x double]* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 2)
br label %6
6: ; preds = %0, %21
%7 = phi i32 [ 0, %0 ], [ %27, %21 ]
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %21, label %13
10: ; preds = %15
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = icmp eq i32 %11, 1
br i1 %12, label %21, label %13
13: ; preds = %6, %10
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %15, %13
%16 = call signext i8 (...) @getchar()
%17 = icmp ne i8 %16, 10
%18 = load i8, i8* @EOF
%19 = icmp ne i8 %16, %18
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %15, label %10
21: ; preds = %10, %6
%22 = phi i32 [ %7, %6 ], [ 0, %10 ]
%23 = load i32, i32* %2
%24 = sitofp i32 %23 to double
%25 = sext i32 %22 to i64
%26 = getelementptr inbounds [2 x double], [2 x double]* %1, i64 0, i64 %25
store double %24, double* %26
%27 = add i32 %22, 1
%28 = icmp slt i32 %22, 1
br i1 %28, label %6, label %29
29: ; preds = %21, %29
%30 = call signext i8 (...) @getchar()
%31 = icmp ne i8 %30, 10
%32 = load i8, i8* @EOF
%33 = icmp ne i8 %30, %32
%34 = select i1 %31, i1 %33, i1 false
br i1 %34, label %29, label %35
35: ; preds = %29
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%37 = getelementptr inbounds [2 x double], [2 x double]* %1, i64 0, i64 0
%38 = call double @GcdArray(double* %37, i32 %27)
%39 = icmp sgt i32 %22, -1
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = zext i32 %27 to i64
br label %46
42: ; preds = %46, %35
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), double %38)
%44 = call signext i8 (...) @getchar()
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
46: ; preds = %40, %46
%47 = phi i64 [ 0, %40 ], [ %51, %46 ]
%48 = getelementptr inbounds [2 x double], [2 x double]* %1, i64 0, i64 %47
%49 = load double, double* %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double %49)
%51 = add nuw nsw i64 %47, 1
%52 = icmp eq i64 %51, %41
br i1 %52, label %42, label %46
}