#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 *, long *);
int main() {
  long i, n, f;
  printf("Please input a number: ");
  scanf("%ld", &n);
  f = n;
  for (i = n - 1; i > 0; i--) {
    printf("%ld", i + 1);
    f = f * i;
    if (i != 1)
      printf("x");
  }
  printf("x1=%ld\n", f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    11be <main+0x9e>
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x10(%rbp)
je     11a8 <main+0x88>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ad <main+0x8d>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1161 <main+0x41>
mov    -0x20(%rbp),%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%rbx
cmp    $0x2,%rbx
jl     11b7 <main+0x87>
lea    -0x1(%rbx),%r15
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%r14
imul   %r15,%r14
cmp    $0x1,%r15
je     11ba <main+0x8a>
add    $0xfffffffffffffffe,%rbx
lea    0xe8c(%rip),%r15
nopl   0x0(%rax)
lea    0x1(%rbx),%r12
mov    $0x78,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
imul   %rbx,%r14
add    $0xffffffffffffffff,%rbx
jne    1190 <main+0x60>
jmp    11ba <main+0x8a>
mov    %rbx,%r14
lea    0xe5b(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Please input a number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [2 x i8] c"x\00"
@.str.3 = [8 x i8] c"x1=%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 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), i64* %3)
%7 = load i64, i64* %3
store i64 %7, i64* %4
%8 = load i64, i64* %3
%9 = sub nsw i64 %8, 1
store i64 %9, i64* %2
br label %10
10: ; preds = %25, %0
%11 = load i64, i64* %2
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %10
%14 = load i64, i64* %2
%15 = add nsw i64 %14, 1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %15)
%17 = load i64, i64* %4
%18 = load i64, i64* %2
%19 = mul nsw i64 %17, %18
store i64 %19, i64* %4
%20 = load i64, i64* %2
%21 = icmp ne i64 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %13
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %24
24: ; preds = %22, %13
br label %25
25: ; preds = %24
%26 = load i64, i64* %2
%27 = add nsw i64 %26, -1
store i64 %27, i64* %2
br label %10
28: ; preds = %10
%29 = load i64, i64* %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %29)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Please input a number: \00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.3 = [8 x i8] c"x1=%ld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 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), i64* %1)
%5 = load i64, i64* %1
%6 = icmp sgt i64 %5, 1
br i1 %6, label %7, label %20
7: ; preds = %0
%8 = add nsw i64 %5, -1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %5)
%10 = mul nsw i64 %5, %8
%11 = icmp eq i64 %8, 1
br i1 %11, label %20, label %12
12: ; preds = %7, %12
%13 = phi i64 [ %18, %12 ], [ %10, %7 ]
%14 = phi i64 [ %16, %12 ], [ %8, %7 ]
%15 = call i32 @putchar(i32 120)
%16 = add nsw i64 %14, -1
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %14)
%18 = mul nsw i64 %13, %16
%19 = icmp eq i64 %16, 1
br i1 %19, label %20, label %12
20: ; preds = %12, %7, %0
%21 = phi i64 [ %5, %0 ], [ %10, %7 ], [ %18, %12 ]
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %21)
ret i32 0
}