#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*/ cleaninput();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, double *);
int /*<<< orphan*/ stdin;
int main(void) {
  double max;
  int ok = 0;
  printf("Fibonacci-Zahlen\n");
  printf("================\n\n");
  printf("Bis wohin? ");
  while (!ok) {
    ok = scanf("%lf", &max);
    ok = ok && max >= 0.9;
    if (ok)
      break;
    printf("Die Zahl muss eine positive Zahl sein.\nBis wohin? ");
    cleaninput();
  }
  unsigned int i = 3u;
  double last1 = 1.0, last2 = 1.0;
  if (max > 0.1)
    printf("%4u. %10.0lf\n", 1u, last2);
  if (max > 1.1)
    printf("%4u. %10.0lf\n", 2u, last1);
  double current = last2 + last1;
  last2 = last1;
  last1 = current;
  while (current <= max) {
    printf("%4u. %10.0lf\n", i, current);
    if (!(i % 20)) {
      fflush(stdin);
      printf("Beliebige Taste zum fortfahren druecken...\n");
      getchar();
    }
    current = last2 + last1;
    last2 = last1;
    last1 = current;
    i++;
  }
  fflush(stdin);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a6 <main+0x56>
jmp    1213 <main+0xc3>
lea    0xe98(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x31(%rbp)
je     11df <main+0x8f>
movsd  -0x10(%rbp),%xmm0
movsd  0xe2b(%rip),%xmm1
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11f9 <main+0xa9>
jmp    1213 <main+0xc3>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <cleaninput@plt>
jmp    1190 <main+0x40>
movl   $0x3,-0x18(%rbp)
movsd  0xdee(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xde1(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdc7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1263 <main+0x113>
movsd  -0x28(%rbp),%xmm0
lea    0xe25(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xda8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1292 <main+0x142>
movsd  -0x20(%rbp),%xmm0
lea    0xdf6(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1348 <main+0x1f8>
mov    -0x18(%rbp),%esi
movsd  -0x30(%rbp),%xmm0
lea    0xda4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x14,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
jne    1317 <main+0x1c7>
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12b5 <main+0x165>
mov    0x2c99(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xef8(%rip),%rdi
call   1040 <puts@plt>
lea    0xefd(%rip),%rdi
call   1040 <puts@plt>
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8d(%rip),%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
test   %eax,%eax
je     11b6 <main+0x56>
movsd  (%rsp),%xmm0
ucomisd 0xe4c(%rip),%xmm0
jae    11ff <main+0x9f>
lea    0xe6f(%rip),%r14
lea    0xe64(%rip),%r15
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <cleaninput@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
test   %eax,%eax
je     11d0 <main+0x70>
movsd  (%rsp),%xmm0
ucomisd 0xe03(%rip),%xmm0
jb     11d0 <main+0x70>
ucomisd 0xe01(%rip),%xmm0
ja     121f <main+0xbf>
ucomisd 0xe07(%rip),%xmm0
ja     1249 <main+0xe9>
ucomisd 0xe05(%rip),%xmm0
jb     1273 <main+0x113>
jmp    1299 <main+0x139>
lea    0xe39(%rip),%rdi
movsd  0xde2(%rip),%xmm0
mov    $0x1,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
ucomisd 0xdd1(%rip),%xmm0
jbe    1213 <main+0xb3>
lea    0xe0f(%rip),%rdi
movsd  0xdb8(%rip),%xmm0
mov    $0x2,%esi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
ucomisd 0xdaf(%rip),%xmm0
jae    1299 <main+0x139>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x3,%ebx
movsd  0xd6a(%rip),%xmm1
movsd  0xd72(%rip),%xmm0
mov    $0xcccccccd,%r12d
lea    0xda4(%rip),%r14
mov    0x2d26(%rip),%r13
lea    0xdc7(%rip),%r15
jmp    12fa <main+0x19a>
nopl   0x0(%rax,%rax,1)
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
addsd  %xmm2,%xmm1
add    $0x1,%ebx
movsd  (%rsp),%xmm0
ucomisd %xmm1,%xmm0
movapd %xmm1,%xmm0
movapd %xmm2,%xmm1
jb     1273 <main+0x113>
movsd  %xmm1,0x10(%rsp)
mov    %ebx,%eax
imul   %r12,%rax
shr    $0x24,%rax
shl    $0x2,%eax
lea    (%rax,%rax,4),%ebp
mov    %r14,%rdi
mov    %ebx,%esi
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1050 <printf@plt>
cmp    %ebp,%ebx
jne    12d0 <main+0x170>
mov    0x0(%r13),%edi
call   1070 <fflush@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
jmp    12d0 <main+0x170>

LLVM IR (-O0):
@.str = [18 x i8] c"Fibonacci-Zahlen\0A\00"
@.str.1 = [19 x i8] c"================\0A\0A\00"
@.str.2 = [12 x i8] c"Bis wohin? \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [51 x i8] c"Die Zahl muss eine positive Zahl sein.\0ABis wohin? \00"
@.str.5 = [14 x i8] c"%4u. %10.0lf\0A\00"
@stdin = global i32 0
@.str.6 = [44 x i8] c"Beliebige Taste zum fortfahren druecken...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
store i32 0, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %28, %0
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %31
15: ; preds = %11
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %2)
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load double, double* %2
%21 = fcmp oge double %20, 9.000000e-01
br label %22
22: ; preds = %19, %15
%23 = phi i1 [ false, %15 ], [ %21, %19 ]
%24 = zext i1 %23 to i32
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
br label %31
28: ; preds = %22
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 (...) @cleaninput()
br label %11
31: ; preds = %27, %11
store i32 3, i32* %4
store double 1.000000e+00, double* %5
store double 1.000000e+00, double* %6
%32 = load double, double* %2
%33 = fcmp ogt double %32, 1.000000e-01
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load double, double* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 1, double %35)
br label %37
37: ; preds = %34, %31
%38 = load double, double* %2
%39 = fcmp ogt double %38, 1.100000e+00
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load double, double* %5
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 2, double %41)
br label %43
43: ; preds = %40, %37
%44 = load double, double* %6
%45 = load double, double* %5
%46 = fadd double %44, %45
store double %46, double* %7
%47 = load double, double* %5
store double %47, double* %6
%48 = load double, double* %7
store double %48, double* %5
br label %49
49: ; preds = %65, %43
%50 = load double, double* %7
%51 = load double, double* %2
%52 = fcmp ole double %50, %51
br i1 %52, label %53, label %73
53: ; preds = %49
%54 = load i32, i32* %4
%55 = load double, double* %7
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %54, double %55)
%57 = load i32, i32* %4
%58 = urem i32 %57, 20
%59 = icmp ne i32 %58, 0
br i1 %59, label %65, label %60
60: ; preds = %53
%61 = load i32, i32* @stdin
%62 = call i32 @fflush(i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%64 = call i32 (...) @getchar()
br label %65
65: ; preds = %60, %53
%66 = load double, double* %6
%67 = load double, double* %5
%68 = fadd double %66, %67
store double %68, double* %7
%69 = load double, double* %5
store double %69, double* %6
%70 = load double, double* %7
store double %70, double* %5
%71 = load i32, i32* %4
%72 = add i32 %71, 1
store i32 %72, i32* %4
br label %49
73: ; preds = %49
%74 = load i32, i32* @stdin
%75 = call i32 @fflush(i32 %74)
%76 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [12 x i8] c"Bis wohin? \00"
@.str.3 = [4 x i8] c"%lf\00"
@.str.4 = [51 x i8] c"Die Zahl muss eine positive Zahl sein.\0ABis wohin? \00"
@.str.5 = [14 x i8] c"%4u. %10.0lf\0A\00"
@stdin = global i32 0
@str = [17 x i8] c"Fibonacci-Zahlen\00"
@str.7 = [18 x i8] c"================\0A\00"
@str.8 = [43 x i8] c"Beliebige Taste zum fortfahren druecken...\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %1)
%7 = icmp ne i32 %6, 0
%8 = load double, double* %1
%9 = fcmp oge double %8, 9.000000e-01
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %19, label %11
11: ; preds = %0, %11
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 (...) @cleaninput()
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double* %1)
%15 = icmp ne i32 %14, 0
%16 = load double, double* %1
%17 = fcmp oge double %16, 9.000000e-01
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %19, label %11
19: ; preds = %11, %0
%20 = phi double [ %8, %0 ], [ %16, %11 ]
%21 = fcmp ogt double %20, 1.000000e-01
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 1, double 1.000000e+00)
%24 = load double, double* %1
br label %25
25: ; preds = %22, %19
%26 = phi double [ %24, %22 ], [ %20, %19 ]
%27 = fcmp ogt double %26, 1.100000e+00
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 2, double 1.000000e+00)
%30 = load double, double* %1
br label %31
31: ; preds = %28, %25
%32 = phi double [ %30, %28 ], [ %26, %25 ]
%33 = fcmp ult double %32, 2.000000e+00
br i1 %33, label %51, label %34
34: ; preds = %31, %46
%35 = phi double [ %47, %46 ], [ 2.000000e+00, %31 ]
%36 = phi double [ %35, %46 ], [ 1.000000e+00, %31 ]
%37 = phi i32 [ %48, %46 ], [ 3, %31 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %37, double %35)
%39 = urem i32 %37, 20
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %34
%42 = load i32, i32* @stdin
%43 = call i32 @fflush(i32 %42)
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.8, i64 0, i64 0))
%45 = call i32 (...) @getchar()
br label %46
46: ; preds = %41, %34
%47 = fadd double %36, %35
%48 = add i32 %37, 1
%49 = load double, double* %1
%50 = fcmp ugt double %47, %49
br i1 %50, label %51, label %34
51: ; preds = %46, %31
%52 = load i32, i32* @stdin
%53 = call i32 @fflush(i32 %52)
%54 = call i32 (...) @getchar()
ret i32 0
}