#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 */
struct timespec {
  int tv_nsec;
};

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ TIME_UTC;
int gcd(int, int);
int gcd_info(int, int);
int gcd_ptr(int *, int *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *, int *);
int /*<<< orphan*/ timespec_get(struct timespec *, int /*<<< orphan*/);
int main() {
  struct timespec ts;
  int start, end;
  printf("Enter two digits: ");
  int x, y;
  while (scanf("%d %d", &x, &y) != EOF) {
    timespec_get(&ts, TIME_UTC);
    start = ts.tv_nsec;
    printf("The greatest common denominator is %d\n", gcd(x, y));
    timespec_get(&ts, TIME_UTC);
    end = ts.tv_nsec;
    printf("took %d nanoseconds\n", end - start);
    int xp = x;
    int yp = y;
    timespec_get(&ts, TIME_UTC);
    start = ts.tv_nsec;
    printf("The greatest common denominator (ptr) is %d\n", gcd_ptr(&xp, &yp));
    timespec_get(&ts, TIME_UTC);
    end = ts.tv_nsec;
    printf("took %d nanoseconds\n", end - start);
    timespec_get(&ts, TIME_UTC);
    start = ts.tv_nsec;
    printf("The greatest common denominator (info) is %d\n", gcd_info(x, y));
    timespec_get(&ts, TIME_UTC);
    end = ts.tv_nsec;
    printf("took %d nanoseconds\n", end - start);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <scanf@plt>
mov    0x2e50(%rip),%rcx
cmp    (%rcx),%rax
je     12d1 <main+0x171>
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1030 <timespec_get@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <gcd@plt>
mov    %eax,%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1030 <timespec_get@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2dc5(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1030 <timespec_get@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <gcd_ptr@plt>
mov    %eax,%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1030 <timespec_get@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1030 <timespec_get@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <gcd_info@plt>
mov    %eax,%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1030 <timespec_get@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    117d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe90(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
mov    0x2e4f(%rip),%r13
cmp    0x0(%r13),%rax
je     12c3 <main+0x163>
mov    0x2e2e(%rip),%r14
mov    %rsp,%rbx
lea    0xe8c(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <timespec_get@plt>
mov    (%rsp),%r12d
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1070 <gcd@plt>
lea    0xe36(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <timespec_get@plt>
mov    (%rsp),%esi
sub    %r12d,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
mov    %eax,0x14(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,0x10(%rsp)
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <timespec_get@plt>
mov    (%rsp),%ebp
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1080 <gcd_ptr@plt>
lea    0xe1a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <timespec_get@plt>
mov    (%rsp),%esi
sub    %ebp,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <timespec_get@plt>
mov    (%rsp),%ebp
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1050 <gcd_info@plt>
lea    0xe02(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <timespec_get@plt>
mov    (%rsp),%esi
sub    %ebp,%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd69(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
cmp    0x0(%r13),%rax
jne    11c0 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
@.str = [19 x i8] c"Enter two digits: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@EOF = global i64 0
@TIME_UTC = global i32 0
@.str.2 = [39 x i8] c"The greatest common denominator is %d\0A\00"
@.str.3 = [21 x i8] c"took %d nanoseconds\0A\00"
@.str.4 = [45 x i8] c"The greatest common denominator (ptr) is %d\0A\00"
@.str.5 = [46 x i8] c"The greatest common denominator (info) is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timespec
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %14, %0
%11 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6)
%12 = load i64, i64* @EOF
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %63
14: ; preds = %10
%15 = load i32, i32* @TIME_UTC
%16 = call i32 @timespec_get(%struct.timespec* %2, i32 %15)
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%18 = load i32, i32* %17
store i32 %18, i32* %3
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i32 @gcd(i32 %19, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* @TIME_UTC
%24 = call i32 @timespec_get(%struct.timespec* %2, i32 %23)
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%26 = load i32, i32* %25
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = load i32, i32* %3
%29 = sub nsw i32 %27, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %5
store i32 %31, i32* %7
%32 = load i32, i32* %6
store i32 %32, i32* %8
%33 = load i32, i32* @TIME_UTC
%34 = call i32 @timespec_get(%struct.timespec* %2, i32 %33)
%35 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%36 = load i32, i32* %35
store i32 %36, i32* %3
%37 = call i32 @gcd_ptr(i32* %7, i32* %8)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = load i32, i32* @TIME_UTC
%40 = call i32 @timespec_get(%struct.timespec* %2, i32 %39)
%41 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%42 = load i32, i32* %41
store i32 %42, i32* %4
%43 = load i32, i32* %4
%44 = load i32, i32* %3
%45 = sub nsw i32 %43, %44
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = load i32, i32* @TIME_UTC
%48 = call i32 @timespec_get(%struct.timespec* %2, i32 %47)
%49 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%50 = load i32, i32* %49
store i32 %50, i32* %3
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = call i32 @gcd_info(i32 %51, i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = load i32, i32* @TIME_UTC
%56 = call i32 @timespec_get(%struct.timespec* %2, i32 %55)
%57 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%58 = load i32, i32* %57
store i32 %58, i32* %4
%59 = load i32, i32* %4
%60 = load i32, i32* %3
%61 = sub nsw i32 %59, %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %61)
br label %10
63: ; preds = %10
%64 = load i32, i32* %1
ret i32 %64
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@.str = [19 x i8] c"Enter two digits: \00"
@.str.1 = [6 x i8] c"%d %d\00"
@EOF = global i64 0
@TIME_UTC = global i32 0
@.str.2 = [39 x i8] c"The greatest common denominator is %d\0A\00"
@.str.3 = [21 x i8] c"took %d nanoseconds\0A\00"
@.str.4 = [45 x i8] c"The greatest common denominator (ptr) is %d\0A\00"
@.str.5 = [46 x i8] c"The greatest common denominator (info) is %d\0A\00"
define i32 @main() {
%1 = alloca %struct.timespec
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast %struct.timespec* %1 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %57, label %13
13: ; preds = %0
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%15 = bitcast i32* %4 to i8*
%16 = bitcast i32* %5 to i8*
br label %17
17: ; preds = %13, %17
%18 = load i32, i32* @TIME_UTC
%19 = call i32 @timespec_get(%struct.timespec* %1, i32 %18)
%20 = load i32, i32* %14
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = call i32 @gcd(i32 %21, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @TIME_UTC
%26 = call i32 @timespec_get(%struct.timespec* %1, i32 %25)
%27 = load i32, i32* %14
%28 = sub nsw i32 %27, %20
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %2
store i32 %30, i32* %4
%31 = load i32, i32* %3
store i32 %31, i32* %5
%32 = load i32, i32* @TIME_UTC
%33 = call i32 @timespec_get(%struct.timespec* %1, i32 %32)
%34 = load i32, i32* %14
%35 = call i32 @gcd_ptr(i32* %4, i32* %5)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @TIME_UTC
%38 = call i32 @timespec_get(%struct.timespec* %1, i32 %37)
%39 = load i32, i32* %14
%40 = sub nsw i32 %39, %34
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i32, i32* @TIME_UTC
%43 = call i32 @timespec_get(%struct.timespec* %1, i32 %42)
%44 = load i32, i32* %14
%45 = load i32, i32* %2
%46 = load i32, i32* %3
%47 = call i32 @gcd_info(i32 %45, i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32 %47)
%49 = load i32, i32* @TIME_UTC
%50 = call i32 @timespec_get(%struct.timespec* %1, i32 %49)
%51 = load i32, i32* %14
%52 = sub nsw i32 %51, %44
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %52)
%54 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%55 = load i64, i64* @EOF
%56 = icmp eq i64 %54, %55
br i1 %56, label %57, label %17
57: ; preds = %17, %0
ret i32 0
}