#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, ...);
int /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(void) {
  srand((unsigned)time(NULL));
  int nr1 = rand() % 100;
  int nr2 = rand() % 100;
  int temp;
  while (1) {
    if (nr1 == nr2) {
      nr2 = rand() & 100;
      continue;
    } else if (nr2 > nr1) {
      temp = nr2;
      nr2 = nr1;
      nr1 = temp;
      break;
    } else
      break;
  }
  puts("\n\tGreatest common divisor program\n");
  puts("So let's say we have 2 numbers..");
  printf("\t%d  and  %d\n", nr1, nr2);
  puts("Their greatest common divisor would be...");
  printf("\t    %d\n\n", gcd(nr1, nr2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11c1 <main+0x61>
mov    $0x0,%al
call   1080 <rand@plt>
and    $0x64,%eax
mov    %eax,-0xc(%rbp)
jmp    11a3 <main+0x43>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    11e4 <main+0x84>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11e9 <main+0x89>
jmp    11e9 <main+0x89>
lea    0xe10(%rip),%rdi
call   1030 <puts@plt>
lea    0xe27(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe36(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <gcd@plt>
mov    %eax,%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
cmp    %eax,%ebx
jne    11ce <main+0x6e>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <rand@plt>
and    $0x64,%eax
cmp    %eax,%ebx
je     11c0 <main+0x60>
cmp    %ebx,%eax
mov    %eax,%ebp
cmovg  %ebx,%ebp
cmovg  %eax,%ebx
lea    0xe21(%rip),%rdi
call   1030 <puts@plt>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4d(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe49(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1070 <gcd@plt>
lea    0xe5e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0A\09Greatest common divisor program\0A\00"
@.str.1 = [33 x i8] c"So let's say we have 2 numbers..\00"
@.str.2 = [14 x i8] c"\09%d and %d\0A\00"
@.str.3 = [42 x i8] c"Their greatest common divisor would be...\00"
@.str.4 = [10 x i8] c"\09 %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = call i32 @srand(i32 %6)
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 100
store i32 %9, i32* %2
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 100
store i32 %11, i32* %3
br label %12
12: ; preds = %0, %16
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = call i32 (...) @rand()
%18 = and i32 %17, 100
store i32 %18, i32* %3
br label %12
19: ; preds = %12
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i32, i32* %3
store i32 %24, i32* %4
%25 = load i32, i32* %2
store i32 %25, i32* %3
%26 = load i32, i32* %4
store i32 %26, i32* %2
br label %28
27: ; preds = %19
br label %28
28: ; preds = %27, %23
%29 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %32)
%34 = call i32 @puts(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = call i32 @gcd(i32 %35, i32 %36)
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"\0A\09Greatest common divisor program\0A\00"
@.str.1 = [33 x i8] c"So let's say we have 2 numbers..\00"
@.str.2 = [14 x i8] c"\09%d and %d\0A\00"
@.str.3 = [42 x i8] c"Their greatest common divisor would be...\00"
@.str.4 = [10 x i8] c"\09 %d\0A\0A\00"
define i32 @main() {
%1 = tail call i64 @time(i32* null)
%2 = trunc i64 %1 to i32
%3 = tail call i32 @srand(i32 %2)
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 100
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 100
%8 = icmp eq i32 %5, %7
br i1 %8, label %9, label %13
9: ; preds = %0, %9
%10 = tail call i32 (...) @rand()
%11 = and i32 %10, 100
%12 = icmp eq i32 %5, %11
br i1 %12, label %9, label %13
13: ; preds = %9, %0
%14 = phi i32 [ %7, %0 ], [ %11, %9 ]
%15 = icmp sgt i32 %14, %5
%16 = select i1 %15, i32 %5, i32 %14
%17 = select i1 %15, i32 %14, i32 %5
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %16)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 @gcd(i32 %17, i32 %16)
%23 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %22)
ret i32 0
}