#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 *, int *);
int main() {
  int a;
  printf("Enter number: ");
  scanf("%d", &a);
  long long int n, x = 0, y = 1, z, sum = 0;
  for (n = 1; n < a; n++) {
    sum = sum + y;
    z = y;
    y = x + y;
    x = z;
    if (sum < y) {
      printf("...\n...\nCannot calculate more than %lld!\n...\n...\n", n);
      return 0;
    }
  }
  printf("Sum is: %lld\n\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movq   $0x0,-0x18(%rbp)
movq   $0x1,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jge    11e8 <main+0xc8>
mov    -0x30(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11d2 <main+0xb2>
mov    -0x10(%rbp),%rsi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1201 <main+0xe1>
jmp    11d7 <main+0xb7>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116d <main+0x4d>
mov    -0x30(%rbp),%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0xc(%rsp),%rax
cmp    $0x2,%rax
jl     117d <main+0x5d>
mov    $0x1,%edx
xor    %ebx,%ebx
xor    %ecx,%ecx
mov    $0x1,%esi
nop
cmp    %rcx,%rbx
jl     1189 <main+0x69>
mov    %rdx,%rdi
add    %rdx,%rcx
add    %rdx,%rbx
add    $0x1,%rsi
mov    %rcx,%rdx
mov    %rdi,%rcx
cmp    %rsi,%rax
jne    1160 <main+0x40>
lea    0xec0(%rip),%rdi
mov    %rbx,%rsi
jmp    1190 <main+0x70>
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Enter number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [50 x i8] c"...\0A...\0ACannot calculate more than %lld!\0A...\0A...\0A\00"
@.str.3 = [15 x i8] c"Sum is: %lld\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i64 0, i64* %4
store i64 1, i64* %5
store i64 0, i64* %7
store i64 1, i64* %3
br label %10
10: ; preds = %31, %0
%11 = load i64, i64* %3
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = icmp slt i64 %11, %13
br i1 %14, label %15, label %34
15: ; preds = %10
%16 = load i64, i64* %7
%17 = load i64, i64* %5
%18 = add nsw i64 %16, %17
store i64 %18, i64* %7
%19 = load i64, i64* %5
store i64 %19, i64* %6
%20 = load i64, i64* %4
%21 = load i64, i64* %5
%22 = add nsw i64 %20, %21
store i64 %22, i64* %5
%23 = load i64, i64* %6
store i64 %23, i64* %4
%24 = load i64, i64* %7
%25 = load i64, i64* %5
%26 = icmp slt i64 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %15
%28 = load i64, i64* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i64 %28)
store i32 0, i32* %1
br label %37
30: ; preds = %15
br label %31
31: ; preds = %30
%32 = load i64, i64* %3
%33 = add nsw i64 %32, 1
store i64 %33, i64* %3
br label %10
34: ; preds = %10
%35 = load i64, i64* %7
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 %35)
store i32 0, i32* %1
br label %37
37: ; preds = %34, %27
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str = [15 x i8] c"Enter number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [50 x i8] c"...\0A...\0ACannot calculate more than %lld!\0A...\0A...\0A\00"
@.str.3 = [15 x i8] c"Sum is: %lld\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 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), i32* %1)
%5 = load i32, i32* %1
%6 = sext i32 %5 to i64
%7 = icmp sgt i32 %5, 1
br i1 %7, label %8, label %21
8: ; preds = %0, %16
%9 = phi i64 [ %18, %16 ], [ 0, %0 ]
%10 = phi i64 [ %17, %16 ], [ 1, %0 ]
%11 = phi i64 [ %10, %16 ], [ 0, %0 ]
%12 = phi i64 [ %19, %16 ], [ 1, %0 ]
%13 = icmp slt i64 %9, %11
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i64 %12)
br label %24
16: ; preds = %8
%17 = add nsw i64 %10, %11
%18 = add nsw i64 %9, %10
%19 = add nuw nsw i64 %12, 1
%20 = icmp eq i64 %19, %6
br i1 %20, label %21, label %8
21: ; preds = %16, %0
%22 = phi i64 [ 0, %0 ], [ %18, %16 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 %22)
br label %24
24: ; preds = %21, %14
ret i32 0
}