#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 /*<<< orphan*/ fill_array(int *, int);
int gcd_couple(int, int);
char *int_to_string(int);
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ readStr();
int str_to_int(int /*<<< orphan*/);
void gcd() {
  print("\nHow many numbers: ");
  int n = str_to_int(readStr());
  int i = 0;
  print("\n");
  int arr[n];
  int matrix[n][n];
  fill_array(arr, n);
  for (i = 0; i < n; i++) {
    matrix[0][i] = arr[i];
  }
  int j = 0;
  for (i = 1; i < n; i++) {
    for (j = 0; j < n - 1; j++) {
      matrix[i][j] = gcd_couple(matrix[i - 1][j], matrix[i - 1][j + 1]);
    }
  }
  print("Result: ");
  print(int_to_string(matrix[n - 1][0]));
  print("\n");
}


x86 assembly (clang, -O0):
<gcd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xe91(%rip),%rdi
call   1040 <print@plt>
xor    %eax,%eax
call   1060 <readStr@plt>
mov    %eax,%edi
call   1030 <str_to_int@plt>
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe81(%rip),%rdi
call   1040 <print@plt>
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x48(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    %rcx,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x38(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%esi
call   1050 <fill_array@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1241 <gcd+0xe1>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%rdx
movslq -0x8(%rbp),%rsi
mov    (%rdx,%rsi,4),%edx
imul   $0x0,%rcx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1202 <gcd+0xa2>
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12ff <gcd+0x19f>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12ec <gcd+0x18c>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rdx
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rsi
imul   %rdx,%rsi
shl    $0x2,%rsi
mov    %rax,%rcx
add    %rsi,%rcx
movslq -0x2c(%rbp),%rsi
mov    (%rcx,%rsi,4),%edi
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1070 <gcd_couple@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
mov    -0x38(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1262 <gcd+0x102>
jmp    12f1 <gcd+0x191>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    124f <gcd+0xef>
lea    0xd10(%rip),%rdi
call   1040 <print@plt>
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   %rdx,%rcx
mov    (%rax,%rcx,4),%edi
call   1080 <int_to_string@plt>
mov    %rax,%rdi
call   1040 <print@plt>
lea    0xcdd(%rip),%rdi
call   1040 <print@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcd>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe78(%rip),%rdi
call   1040 <print@plt>
xor    %eax,%eax
call   1070 <readStr@plt>
mov    %eax,%edi
call   1030 <str_to_int@plt>
mov    %eax,%ebx
lea    0xe70(%rip),%rdi
call   1040 <print@plt>
mov    %ebx,%r12d
mov    %rsp,%r15
lea    0xf(,%r12,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %r12,%rax
imul   %r12,%rax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %r15,%rdi
mov    %ebx,%esi
call   1060 <fill_array@plt>
test   %ebx,%ebx
jle    1208 <gcd+0x98>
lea    0x0(,%r12,4),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rdx,-0x40(%rbp)
call   1050 <memcpy@plt>
cmp    $0x1,%r12d
jne    120f <gcd+0x9f>
lea    -0x1(%r12),%r15d
jmp    127d <gcd+0x10d>
lea    -0x1(%r12),%r15d
lea    (%r14,%r12,4),%rbx
mov    %r14,-0x30(%rbp)
add    $0x4,%r14
mov    $0x1,%ecx
mov    %r12,-0x38(%rbp)
nopl   0x0(%rax)
mov    %rcx,-0x48(%rbp)
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
lea    0x1(%r13),%r12
mov    -0x4(%r14,%r13,4),%edi
mov    (%r14,%r13,4),%esi
call   1080 <gcd_couple@plt>
mov    %eax,(%rbx,%r13,4)
mov    %r12,%r13
cmp    %r12,%r15
jne    1240 <gcd+0xd0>
mov    -0x48(%rbp),%rcx
add    $0x1,%rcx
mov    -0x40(%rbp),%rax
add    %rax,%rbx
add    %rax,%r14
mov    -0x38(%rbp),%r12
cmp    %r12,%rcx
jne    1230 <gcd+0xc0>
mov    -0x30(%rbp),%r14
lea    0xd92(%rip),%rdi
call   1040 <print@plt>
movslq %r15d,%rax
imul   %r12,%rax
mov    (%r14,%rax,4),%edi
call   1090 <int_to_string@plt>
mov    %rax,%rdi
call   1040 <print@plt>
lea    0xd6c(%rip),%rdi
call   1040 <print@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0AHow many numbers: \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [9 x i8] c"Result: \00"
define void @gcd() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = call i32 @print(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @readStr()
%10 = call i32 @str_to_int(i32 %9)
store i32 %10, i32* %1
store i32 0, i32* %2
%11 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %3
%15 = alloca i32, i64 %13
store i64 %13, i64* %4
%16 = load i32, i32* %1
%17 = zext i32 %16 to i64
%18 = load i32, i32* %1
%19 = zext i32 %18 to i64
%20 = mul nuw i64 %17, %19
%21 = alloca i32, i64 %20
store i64 %17, i64* %5
store i64 %19, i64* %6
%22 = load i32, i32* %1
%23 = call i32 @fill_array(i32* %15, i32 %22)
store i32 0, i32* %2
br label %24
24: ; preds = %38, %0
%25 = load i32, i32* %2
%26 = load i32, i32* %1
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %41
28: ; preds = %24
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %15, i64 %30
%32 = load i32, i32* %31
%33 = mul nsw i64 0, %19
%34 = getelementptr inbounds i32, i32* %21, i64 %33
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %32, i32* %37
br label %38
38: ; preds = %28
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
br label %24
41: ; preds = %24
store i32 0, i32* %7
store i32 1, i32* %2
br label %42
42: ; preds = %84, %41
%43 = load i32, i32* %2
%44 = load i32, i32* %1
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %87
46: ; preds = %42
store i32 0, i32* %7
br label %47
47: ; preds = %80, %46
%48 = load i32, i32* %7
%49 = load i32, i32* %1
%50 = sub nsw i32 %49, 1
%51 = icmp slt i32 %48, %50
br i1 %51, label %52, label %83
52: ; preds = %47
%53 = load i32, i32* %2
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = mul nsw i64 %55, %19
%57 = getelementptr inbounds i32, i32* %21, i64 %56
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %57, i64 %59
%61 = load i32, i32* %60
%62 = load i32, i32* %2
%63 = sub nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = mul nsw i64 %64, %19
%66 = getelementptr inbounds i32, i32* %21, i64 %65
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %66, i64 %69
%71 = load i32, i32* %70
%72 = call i32 @gcd_couple(i32 %61, i32 %71)
%73 = load i32, i32* %2
%74 = sext i32 %73 to i64
%75 = mul nsw i64 %74, %19
%76 = getelementptr inbounds i32, i32* %21, i64 %75
%77 = load i32, i32* %7
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32, i32* %76, i64 %78
store i32 %72, i32* %79
br label %80
80: ; preds = %52
%81 = load i32, i32* %7
%82 = add nsw i32 %81, 1
store i32 %82, i32* %7
br label %47
83: ; preds = %47
br label %84
84: ; preds = %83
%85 = load i32, i32* %2
%86 = add nsw i32 %85, 1
store i32 %86, i32* %2
br label %42
87: ; preds = %42
%88 = call i32 @print(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%89 = load i32, i32* %1
%90 = sub nsw i32 %89, 1
%91 = sext i32 %90 to i64
%92 = mul nsw i64 %91, %19
%93 = getelementptr inbounds i32, i32* %21, i64 %92
%94 = getelementptr inbounds i32, i32* %93, i64 0
%95 = load i32, i32* %94
%96 = call i8* @int_to_string(i32 %95)
%97 = call i32 @print(i8* %96)
%98 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%99 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"\0AHow many numbers: \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [9 x i8] c"Result: \00"
define void @gcd() {
%1 = tail call i32 @print(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @readStr()
%3 = tail call i32 @str_to_int(i32 %2)
%4 = tail call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = zext i32 %3 to i64
%6 = alloca i32, i64 %5
%7 = mul nuw i64 %5, %5
%8 = alloca i32, i64 %7
%9 = call i32 @fill_array(i32* %6, i32 %3)
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = bitcast i32* %8 to i8*
%13 = bitcast i32* %6 to i8*
%14 = shl nuw nsw i64 %5, 2
%15 = icmp eq i32 %3, 1
br i1 %15, label %16, label %18
16: ; preds = %0, %11
%17 = add nsw i32 %3, -1
br label %41
18: ; preds = %11
%19 = add nsw i32 %3, -1
%20 = zext i32 %19 to i64
br label %21
21: ; preds = %38, %18
%22 = phi i64 [ 1, %18 ], [ %39, %38 ]
%23 = add nsw i64 %22, -1
%24 = mul nuw nsw i64 %23, %5
%25 = getelementptr inbounds i32, i32* %8, i64 %24
%26 = mul nuw nsw i64 %22, %5
%27 = getelementptr inbounds i32, i32* %8, i64 %26
br label %28
28: ; preds = %21, %28
%29 = phi i64 [ 0, %21 ], [ %32, %28 ]
%30 = getelementptr inbounds i32, i32* %25, i64 %29
%31 = load i32, i32* %30
%32 = add nuw nsw i64 %29, 1
%33 = getelementptr inbounds i32, i32* %25, i64 %32
%34 = load i32, i32* %33
%35 = call i32 @gcd_couple(i32 %31, i32 %34)
%36 = getelementptr inbounds i32, i32* %27, i64 %29
store i32 %35, i32* %36
%37 = icmp eq i64 %32, %20
br i1 %37, label %38, label %28
38: ; preds = %28
%39 = add nuw nsw i64 %22, 1
%40 = icmp eq i64 %39, %5
br i1 %40, label %41, label %21
41: ; preds = %38, %16
%42 = phi i32 [ %17, %16 ], [ %19, %38 ]
%43 = call i32 @print(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%44 = sext i32 %42 to i64
%45 = mul nsw i64 %44, %5
%46 = getelementptr inbounds i32, i32* %8, i64 %45
%47 = load i32, i32* %46
%48 = call i8* @int_to_string(i32 %47)
%49 = call i32 @print(i8* %48)
%50 = call i32 @print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}