#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 fact(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int i;
  char flag = 'y';
  while (flag != 'n') {
    scanf("%d", &i);
    printf("\nFactorial of %d is %d\nnext no.  or 'n' to exit : ", i, fact(i));
    scanf("%c", &flag);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x79,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x6e,%eax
je     1198 <main+0x68>
lea    0xea9(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <fact@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%edx
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x9(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
jmp    1143 <main+0x13>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0x79,0x3(%rsp)
lea    0xeb9(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xeb0(%rip),%r12
lea    0xedc(%rip),%r13
lea    0x3(%rsp),%rbx
nop
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%ebp
mov    %ebp,%edi
call   1040 <fact@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpb   $0x6e,0x3(%rsp)
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [51 x i8] c"\0AFactorial of %d is %d\0Anext no. or 'n' to exit : \00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
store i8 121, i8* %3
br label %4
4: ; preds = %8, %0
%5 = load i8, i8* %3
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 110
br i1 %7, label %8, label %15
8: ; preds = %4
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = call i32 @fact(i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %12)
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %4
15: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [51 x i8] c"\0AFactorial of %d is %d\0Anext no. or 'n' to exit : \00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
store i8 121, i8* %2
br label %4
4: ; preds = %0, %4
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 @fact(i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7)
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%10 = load i8, i8* %2
%11 = icmp eq i8 %10, 110
br i1 %11, label %12, label %4
12: ; preds = %4
ret i32 0
}