#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 gcd(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int /*<<< orphan*/ system(char *);
int main(void) {
  int num1, num2;
  printf(
      "This is a small application to calculate the GCD of two numbers.\n\n");
  printf("Starting Application......");
  printf("\n");
  system("sleep 3");
  printf("\nEnter two numbers: ");
  scanf("%d%d", &num1, &num2);
  int results = gcd(num1, num2);
  printf("\nThe gcd of %d and %d is %d.\n", num1, num2, results);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
call   1030 <system@plt>
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <gcd@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xef3(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe8f(%rip),%rdi
call   1050 <system@plt>
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe92(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1070 <scanf@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1080 <gcd@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xe70(%rip),%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [67 x i8] c"This is a small application to calculate the GCD of two numbers.\0A\0A\00"
@.str.1 = [27 x i8] c"Starting Application......\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [8 x i8] c"sleep 3\00"
@.str.4 = [21 x i8] c"\0AEnter two numbers: \00"
@.str.5 = [5 x i8] c"%d%d\00"
@.str.6 = [30 x i8] c"\0AThe gcd of %d and %d is %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %2, i32* %3)
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 @gcd(i32 %11, i32 %12)
store i32 %13, i32* %4
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %14, i32 %15, i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"Starting Application......\00"
@.str.3 = [8 x i8] c"sleep 3\00"
@.str.4 = [21 x i8] c"\0AEnter two numbers: \00"
@.str.5 = [5 x i8] c"%d%d\00"
@.str.6 = [30 x i8] c"\0AThe gcd of %d and %d is %d.\0A\00"
@str = [66 x i8] c"This is a small application to calculate the GCD of two numbers.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @putchar(i32 10)
%8 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32* %1, i32* %2)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 @gcd(i32 %11, i32 %12)
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %14, i32 %15, i32 %13)
ret i32 0
}