#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 main(void) {
  int number = 0;
  int counter = 0;
  printf("The number\t!factorial\n");
  for (counter = 1; counter <= 5; ++counter) {
    number = counter;
    int factorial = 1;
    while (number != 1) {
      factorial = factorial * number;
      --number;
    }
    printf("%d\t\t%d\n", counter, factorial);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jg     119d <main+0x8d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     117b <main+0x6b>
mov    -0x10(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1159 <main+0x49>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1142 <main+0x32>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x6,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x18,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x78,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"The number\09!factorial\0A\00"
@.str.1 = [8 x i8] c"%d\09\09%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 5
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load i32, i32* %3
store i32 %10, i32* %2
store i32 1, i32* %4
br label %11
11: ; preds = %14, %9
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = mul nsw i32 %15, %16
store i32 %17, i32* %4
%18 = load i32, i32* %2
%19 = add nsw i32 %18, -1
store i32 %19, i32* %2
br label %11
20: ; preds = %11
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22)
br label %24
24: ; preds = %20
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %6
27: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"%d\09\09%d\0A\00"
@str = [22 x i8] c"The number\09!factorial\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 1)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 2)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 6)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 24)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 120)
ret i32 0
}