#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 /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int x, n, r, p;
  char s1[100];
  printf("Enter the string");
  scanf("%s", s1);
  x = 1;
  n = strlen(s1);
  for (p = n; p >= 1; p--) {
    x = x * p;
  }
  printf("Permutations of N charecters of a string is %d ", x);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xeb6(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x1,-0x8(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     119b <main+0x6b>
mov    -0x8(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1179 <main+0x49>
mov    -0x8(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xf64(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf67(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1170 <main+0x40>
cmp    $0x8,%eax
jae    117a <main+0x4a>
mov    $0x1,%esi
jmp    13a0 <main+0x270>
mov    $0x1,%esi
jmp    13ad <main+0x27d>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
movd   %eax,%xmm0
pshufd $0x0,%xmm0,%xmm6
paddd  0xe70(%rip),%xmm6
lea    -0x8(%rcx),%edi
mov    %edi,%esi
shr    $0x3,%esi
add    $0x1,%esi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0x18,%edi
jae    11b6 <main+0x86>
movdqa 0xe63(%rip),%xmm1
movdqa %xmm1,%xmm4
jmp    12f1 <main+0x1c1>
and    $0xfffffffc,%esi
movdqa 0xe4f(%rip),%xmm1
movdqa 0xe66(%rip),%xmm9
movdqa 0xe6d(%rip),%xmm10
movdqa 0xe74(%rip),%xmm11
movdqa 0xe7b(%rip),%xmm12
movdqa 0xe82(%rip),%xmm13
movdqa 0xe89(%rip),%xmm14
movdqa 0xe90(%rip),%xmm15
movdqa %xmm1,%xmm4
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movdqa %xmm6,%xmm0
paddd  0xe04(%rip),%xmm0
pshufd $0xf5,%xmm1,%xmm5
pshufd $0xf5,%xmm6,%xmm7
pmuludq %xmm5,%xmm7
pmuludq %xmm6,%xmm1
pshufd $0xf5,%xmm4,%xmm5
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm5,%xmm2
pmuludq %xmm4,%xmm0
movdqa %xmm6,%xmm4
paddd  %xmm9,%xmm4
movdqa %xmm6,%xmm5
paddd  %xmm10,%xmm5
pmuludq %xmm4,%xmm1
pshufd $0xf5,%xmm4,%xmm4
pmuludq %xmm7,%xmm4
pmuludq %xmm5,%xmm0
pshufd $0xf5,%xmm5,%xmm5
pmuludq %xmm2,%xmm5
movdqa %xmm6,%xmm2
paddd  %xmm11,%xmm2
movdqa %xmm6,%xmm7
paddd  %xmm12,%xmm7
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm4,%xmm3
pmuludq %xmm1,%xmm2
pshufd $0xf5,%xmm7,%xmm8
pmuludq %xmm5,%xmm8
pmuludq %xmm0,%xmm7
movdqa %xmm6,%xmm0
paddd  %xmm13,%xmm0
movdqa %xmm6,%xmm5
paddd  %xmm14,%xmm5
pmuludq %xmm0,%xmm2
pshufd $0xe8,%xmm2,%xmm1
pshufd $0xf5,%xmm0,%xmm0
pmuludq %xmm3,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm1
pmuludq %xmm5,%xmm7
pshufd $0xe8,%xmm7,%xmm4
pshufd $0xf5,%xmm5,%xmm0
pmuludq %xmm8,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm4
paddd  %xmm15,%xmm6
add    $0xfffffffc,%esi
jne    1210 <main+0xe0>
movdqa %xmm1,%xmm5
movdqa %xmm4,%xmm0
test   %edx,%edx
je     136d <main+0x23d>
movdqa 0xd1b(%rip),%xmm2
movdqa 0xd23(%rip),%xmm3
nopl   (%rax)
movdqa %xmm6,%xmm0
paddd  %xmm2,%xmm0
movdqa %xmm6,%xmm5
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pshufd $0xf5,%xmm1,%xmm1
pshufd $0xf5,%xmm6,%xmm7
pmuludq %xmm1,%xmm7
pshufd $0xe8,%xmm7,%xmm1
punpckldq %xmm1,%xmm5
pshufd $0xf5,%xmm0,%xmm1
pmuludq %xmm4,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pshufd $0xf5,%xmm4,%xmm4
pmuludq %xmm1,%xmm4
pshufd $0xe8,%xmm4,%xmm1
punpckldq %xmm1,%xmm0
paddd  %xmm3,%xmm6
movdqa %xmm5,%xmm1
movdqa %xmm0,%xmm4
add    $0xffffffff,%edx
jne    1310 <main+0x1e0>
pshufd $0xf5,%xmm5,%xmm1
pshufd $0xf5,%xmm0,%xmm2
pmuludq %xmm1,%xmm2
pmuludq %xmm5,%xmm0
pshufd $0xee,%xmm0,%xmm1
pmuludq %xmm0,%xmm1
pshufd $0xaa,%xmm2,%xmm0
pmuludq %xmm2,%xmm0
pmuludq %xmm1,%xmm0
movd   %xmm0,%esi
cmp    %ecx,%eax
je     13ad <main+0x27d>
and    $0x7,%eax
imul   %eax,%esi
lea    -0x1(%rax),%ecx
cmp    $0x1,%eax
mov    %ecx,%eax
ja     13a0 <main+0x270>
lea    0xd00(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter the string\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [48 x i8] c"Permutations of N charecters of a string is %d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x i8]
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
store i32 1, i32* %2
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %3
%12 = load i32, i32* %3
store i32 %12, i32* %5
br label %13
13: ; preds = %20, %0
%14 = load i32, i32* %5
%15 = icmp sge i32 %14, 1
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %2
%18 = load i32, i32* %5
%19 = mul nsw i32 %17, %18
store i32 %19, i32* %2
br label %20
20: ; preds = %16
%21 = load i32, i32* %5
%22 = add nsw i32 %21, -1
store i32 %22, i32* %5
br label %13
23: ; preds = %13
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter the string\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [48 x i8] c"Permutations of N charecters of a string is %d \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %78
7: ; preds = %0
%8 = icmp ult i32 %5, 8
br i1 %8, label %69, label %9
9: ; preds = %7
%10 = and i32 %5, -8
%11 = and i32 %5, 7
%12 = insertelement <4 x i32> poison, i32 %5, i64 0
%13 = shufflevector <4 x i32> %12, <4 x i32> poison, <4 x i32> zeroinitializer
%14 = add <4 x i32> %13, <i32 0, i32 -1, i32 -2, i32 -3>
%15 = add i32 %10, -8
%16 = lshr exact i32 %15, 3
%17 = add nuw nsw i32 %16, 1
%18 = and i32 %17, 3
%19 = icmp ult i32 %15, 24
br i1 %19, label %45, label %20
20: ; preds = %9
%21 = and i32 %17, 1073741820
br label %22
22: ; preds = %22, %20
%23 = phi <4 x i32> [ %14, %20 ], [ %42, %22 ]
%24 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %20 ], [ %40, %22 ]
%25 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %20 ], [ %41, %22 ]
%26 = phi i32 [ 0, %20 ], [ %43, %22 ]
%27 = add <4 x i32> %23, <i32 -4, i32 -4, i32 -4, i32 -4>
%28 = mul <4 x i32> %23, %24
%29 = mul <4 x i32> %27, %25
%30 = add <4 x i32> %23, <i32 -8, i32 -8, i32 -8, i32 -8>
%31 = add <4 x i32> %23, <i32 -12, i32 -12, i32 -12, i32 -12>
%32 = mul <4 x i32> %30, %28
%33 = mul <4 x i32> %31, %29
%34 = add <4 x i32> %23, <i32 -16, i32 -16, i32 -16, i32 -16>
%35 = add <4 x i32> %23, <i32 -20, i32 -20, i32 -20, i32 -20>
%36 = mul <4 x i32> %34, %32
%37 = mul <4 x i32> %35, %33
%38 = add <4 x i32> %23, <i32 -24, i32 -24, i32 -24, i32 -24>
%39 = add <4 x i32> %23, <i32 -28, i32 -28, i32 -28, i32 -28>
%40 = mul <4 x i32> %38, %36
%41 = mul <4 x i32> %39, %37
%42 = add <4 x i32> %23, <i32 -32, i32 -32, i32 -32, i32 -32>
%43 = add i32 %26, 4
%44 = icmp eq i32 %43, %21
br i1 %44, label %45, label %22
45: ; preds = %22, %9
%46 = phi <4 x i32> [ undef, %9 ], [ %40, %22 ]
%47 = phi <4 x i32> [ undef, %9 ], [ %41, %22 ]
%48 = phi <4 x i32> [ %14, %9 ], [ %42, %22 ]
%49 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %9 ], [ %40, %22 ]
%50 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %9 ], [ %41, %22 ]
%51 = icmp eq i32 %18, 0
br i1 %51, label %63, label %52
52: ; preds = %45, %52
%53 = phi <4 x i32> [ %60, %52 ], [ %48, %45 ]
%54 = phi <4 x i32> [ %58, %52 ], [ %49, %45 ]
%55 = phi <4 x i32> [ %59, %52 ], [ %50, %45 ]
%56 = phi i32 [ %61, %52 ], [ 0, %45 ]
%57 = add <4 x i32> %53, <i32 -4, i32 -4, i32 -4, i32 -4>
%58 = mul <4 x i32> %53, %54
%59 = mul <4 x i32> %57, %55
%60 = add <4 x i32> %53, <i32 -8, i32 -8, i32 -8, i32 -8>
%61 = add i32 %56, 1
%62 = icmp eq i32 %61, %18
br i1 %62, label %63, label %52
63: ; preds = %52, %45
%64 = phi <4 x i32> [ %46, %45 ], [ %58, %52 ]
%65 = phi <4 x i32> [ %47, %45 ], [ %59, %52 ]
%66 = mul <4 x i32> %65, %64
%67 = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %66)
%68 = icmp eq i32 %5, %10
br i1 %68, label %78, label %69
69: ; preds = %7, %63
%70 = phi i32 [ %5, %7 ], [ %11, %63 ]
%71 = phi i32 [ 1, %7 ], [ %67, %63 ]
br label %72
72: ; preds = %69, %72
%73 = phi i32 [ %76, %72 ], [ %70, %69 ]
%74 = phi i32 [ %75, %72 ], [ %71, %69 ]
%75 = mul nsw i32 %73, %74
%76 = add nsw i32 %73, -1
%77 = icmp ugt i32 %73, 1
br i1 %77, label %72, label %78
78: ; preds = %72, %63, %0
%79 = phi i32 [ 1, %0 ], [ %67, %63 ], [ %75, %72 ]
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i32 %79)
ret i32 0
}