#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 EXIT_SUCCESS;
scalar_t__ fact(int);
scalar_t__ fact_recursive(int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  srand(time(NULL));
  int j = (rand() % 9) + 2;
  printf("%d! => %d\n", j, fact(j));
  printf("%s\n", (fact(j) == fact_recursive(j)) ? "Agree" : "Ups");
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
add    $0x2,%edx
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <fact@plt>
mov    -0x24(%rbp),%esi
mov    %rax,%rdx
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1060 <fact@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <fact_recursive@plt>
mov    -0x20(%rbp),%rcx
mov    %rax,%rdx
lea    0xe36(%rip),%rsi
lea    0xe29(%rip),%rax
cmp    %rdx,%rcx
cmove  %rax,%rsi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%ebx
add    $0x2,%ebx
mov    %ebx,%edi
call   1070 <fact@plt>
lea    0xe48(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1070 <fact@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1080 <fact_recursive@plt>
cmp    %rax,%r14
lea    0xe2c(%rip),%rax
lea    0xe2b(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%d! => %d\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [6 x i8] c"Agree\00"
@.str.3 = [4 x i8] c"Ups\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 9
%11 = add nsw i32 %10, 2
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = load i32, i32* %6
%14 = call i64 @fact(i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %12, i64 %14)
%16 = load i32, i32* %6
%17 = call i64 @fact(i32 %16)
%18 = load i32, i32* %6
%19 = call i64 @fact_recursive(i32 %18)
%20 = icmp eq i64 %17, %19
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}

LLVM IR (-O2):
@.str = [11 x i8] c"%d! => %d\0A\00"
@.str.2 = [6 x i8] c"Agree\00"
@.str.3 = [4 x i8] c"Ups\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 9
%7 = add nsw i32 %6, 2
%8 = tail call i64 @fact(i32 %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7, i64 %8)
%10 = tail call i64 @fact(i32 %7)
%11 = tail call i64 @fact_recursive(i32 %7)
%12 = icmp eq i64 %10, %11
%13 = select i1 %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%14 = tail call i32 @puts(i8* dereferenceable(1) %13)
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}