#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, fact = 1;
  printf("Podaj liczbę: \n");
  scanf("%d\n", &n);
  if (n < 0 || n > 15) {
    printf("Podaj mniejszą liczbę: \n");
    exit(1);
  } else {
    for (int i = 1; i <= n; i++)
      fact = fact * i;
    printf("Silnia z %d wynosi: %d\n", n, fact);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1178 <main+0x48>
cmpl   $0xf,-0x8(%rbp)
jle    1190 <main+0x60>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11bb <main+0x8b>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1197 <main+0x67>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf40(%rip),%rdi
call   1030 <puts@plt>
lea    0xf30(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0xf,%esi
ja     124b <main+0x10b>
test   %esi,%esi
je     11a7 <main+0x67>
lea    0x3(%rsi),%eax
and    $0xfffffffc,%eax
lea    -0x1(%rsi),%ecx
movd   %ecx,%xmm0
pshufd $0x0,%xmm0,%xmm0
cmp    $0x4,%eax
je     11b1 <main+0x71>
cmp    $0x8,%eax
je     11c5 <main+0x85>
cmp    $0xc,%eax
jne    11dc <main+0x9c>
movdqa 0xe88(%rip),%xmm1
movdqa 0xe90(%rip),%xmm2
mov    $0x8,%eax
jmp    11f1 <main+0xb1>
mov    $0x1,%edx
jmp    1239 <main+0xf9>
movdqa 0xe47(%rip),%xmm1
movdqa 0xe4f(%rip),%xmm2
xor    %eax,%eax
jmp    11f1 <main+0xb1>
movdqa 0xe63(%rip),%xmm1
movdqa 0xe2b(%rip),%xmm2
mov    $0x4,%eax
jmp    11f1 <main+0xb1>
movdqa 0xe5c(%rip),%xmm1
movdqa 0xe34(%rip),%xmm2
mov    $0xc,%eax
movd   %eax,%xmm3
pshufd $0x0,%xmm3,%xmm3
pxor   0xe4e(%rip),%xmm0
por    0xe56(%rip),%xmm3
pcmpgtd %xmm0,%xmm3
pand   %xmm3,%xmm2
pandn  %xmm1,%xmm3
por    %xmm2,%xmm3
pshufd $0xee,%xmm3,%xmm0
pshufd $0xff,%xmm3,%xmm1
pshufd $0xf5,%xmm3,%xmm2
pmuludq %xmm1,%xmm2
pmuludq %xmm3,%xmm0
pmuludq %xmm2,%xmm0
movd   %xmm0,%edx
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe46(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Podaj liczb\C4\99: \0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [27 x i8] c"Podaj mniejsz\C4\85 liczb\C4\99: \0A\00"
@.str.3 = [24 x i8] c"Silnia z %d wynosi: %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 1, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 15
br i1 %11, label %12, label %15
12: ; preds = %9, %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %9
store i32 1, i32* %4
br label %16
16: ; preds = %24, %15
%17 = load i32, i32* %4
%18 = load i32, i32* %2
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = mul nsw i32 %21, %22
store i32 %23, i32* %3
br label %24
24: ; preds = %20
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %16
27: ; preds = %16
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %29)
br label %31
31: ; preds = %27
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.3 = [24 x i8] c"Silnia z %d wynosi: %d\0A\00"
@str = [16 x i8] c"Podaj liczb\C4\99: \00"
@str.4 = [26 x i8] c"Podaj mniejsz\C4\85 liczb\C4\99: \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp ugt i32 %5, 15
br i1 %6, label %28, label %7
7: ; preds = %0
%8 = icmp eq i32 %5, 0
br i1 %8, label %31, label %9
9: ; preds = %7
%10 = add i32 %5, 3
%11 = and i32 %10, -4
%12 = add i32 %5, -1
%13 = insertelement <4 x i32> poison, i32 %12, i64 0
%14 = shufflevector <4 x i32> %13, <4 x i32> poison, <4 x i32> zeroinitializer
switch i32 %11, label %15 [
i32 4, label %18
i32 8, label %16
i32 12, label %17
]
15: ; preds = %9
br label %18
16: ; preds = %9
br label %18
17: ; preds = %9
br label %18
18: ; preds = %9, %17, %16, %15
%19 = phi i32 [ 0, %9 ], [ 12, %15 ], [ 4, %16 ], [ 8, %17 ]
%20 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %9 ], [ <i32 45, i32 120, i32 231, i32 384>, %15 ], [ <i32 1, i32 2, i32 3, i32 4>, %16 ], [ <i32 5, i32 12, i32 21, i32 32>, %17 ]
%21 = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %9 ], [ <i32 585, i32 1680, i32 3465, i32 6144>, %15 ], [ <i32 5, i32 12, i32 21, i32 32>, %16 ], [ <i32 45, i32 120, i32 231, i32 384>, %17 ]
%22 = insertelement <4 x i32> poison, i32 %19, i64 0
%23 = shufflevector <4 x i32> %22, <4 x i32> poison, <4 x i32> zeroinitializer
%24 = or <4 x i32> %23, <i32 0, i32 1, i32 2, i32 3>
%25 = icmp ugt <4 x i32> %24, %14
%26 = select <4 x i1> %25, <4 x i32> %20, <4 x i32> %21
%27 = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %26)
br label %31
28: ; preds = %0
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.4, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %18, %7
%32 = phi i32 [ 1, %7 ], [ %27, %18 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %5, i32 %32)
ret i32 0
}