#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*/ printf(char *, ...);
int factorial(int n) {
  int r;
  printf("factorial, n=%i\n", n);
  if (n == 1)
    return 1;
  r = n * factorial(n - 1);
  printf("factorial r*5(n=%i): %i\n", n, r * 5);
  if (r * 5 > 100) {
    printf("5r > 100\n");
  } else {
    printf("5r < 100\n");
  }
  return r;
}


x86 assembly (clang, -O0):
<factorial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1152 <factorial+0x32>
movl   $0x1,-0x4(%rbp)
jmp    11b7 <factorial+0x97>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1030 <factorial@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
imul   $0x5,-0xc(%rbp),%edx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
imul   $0x5,-0xc(%rbp),%eax
cmp    $0x64,%eax
jle    11a3 <factorial+0x83>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b1 <factorial+0x91>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factorial>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0xec3(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r14d
cmp    $0x1,%ebx
je     1190 <factorial+0x60>
lea    -0x1(%rbx),%edi
call   1040 <factorial@plt>
mov    %eax,%r14d
imul   %ebx,%r14d
lea    (%r14,%r14,4),%ebp
lea    0xea6(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x65,%ebp
lea    0xeb3(%rip),%rax
lea    0xea3(%rip),%rdi
cmovge %rax,%rdi
call   1030 <puts@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"factorial, n=%i\0A\00"
@.str.1 = [25 x i8] c"factorial r*5(n=%i): %i\0A\00"
@.str.2 = [10 x i8] c"5r > 100\0A\00"
@.str.3 = [10 x i8] c"5r < 100\0A\00"
define i32 @factorial(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 1, i32* %2
br label %29
10: ; preds = %1
%11 = load i32, i32* %3
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
%14 = call i32 @factorial(i32 %13)
%15 = mul nsw i32 %11, %14
store i32 %15, i32* %4
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = mul nsw i32 %17, 5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %18)
%20 = load i32, i32* %4
%21 = mul nsw i32 %20, 5
%22 = icmp sgt i32 %21, 100
br i1 %22, label %23, label %25
23: ; preds = %10
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %27
25: ; preds = %10
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = load i32, i32* %4
store i32 %28, i32* %2
br label %29
29: ; preds = %27, %9
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@.str = [17 x i8] c"factorial, n=%i\0A\00"
@.str.1 = [25 x i8] c"factorial r*5(n=%i): %i\0A\00"
@str = [9 x i8] c"5r < 100\00"
@str.4 = [9 x i8] c"5r > 100\00"
define i32 @factorial(i32 %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = icmp eq i32 %0, 1
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = add nsw i32 %0, -1
%6 = tail call i32 @factorial(i32 %5)
%7 = mul nsw i32 %6, %0
%8 = mul nsw i32 %7, 5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %8)
%10 = icmp sgt i32 %8, 100
%11 = select i1 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0)
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
br label %13
13: ; preds = %4, %1
%14 = phi i32 [ 1, %1 ], [ %7, %4 ]
ret i32 %14
}