#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 */
double berechne_anfangs_tilgung(double, double);
double berechne_annuitaet(double, double);
double berechne_zinsen(double, double);
int /*<<< orphan*/ printf(char *, ...);
void schreibe_tilgungsplan(double kredit, double zinssatz,
                           double tilgungsrate) {
  int jahr = 1;
  double tilgung = berechne_anfangs_tilgung(tilgungsrate, kredit);
  double zinsen = berechne_zinsen(zinssatz, kredit);
  double annuitaet = berechne_annuitaet(zinsen, tilgung);
  double restkredit = kredit - tilgung;
  double gesamtaufwand = annuitaet;
  printf("\n\t\t\t\t\t\tTILGUNGSPLAN\n");
  printf("\n%-6s %20s %20s %20s %20s %20s\n", "Jahr", "Kredit A", "Annuität",
         "Tilgung", "Zinsen", "Kredit E");
  printf("\n%-6d %20.2lf %20.2lf %20.2lf %20.2lf %20.2lf\n", jahr, kredit,
         annuitaet, tilgung, zinsen, restkredit);
  do {
    jahr = jahr + 1;
    kredit = restkredit;
    zinsen = berechne_zinsen(zinssatz, kredit);
    tilgung = annuitaet - zinsen;
    restkredit = kredit - tilgung;
    gesamtaufwand = gesamtaufwand + annuitaet;
    printf("%-6d %20.2lf %20.2lf %20.2lf %20.2lf %20.2lf\n", jahr, kredit,
           annuitaet, tilgung, zinsen, restkredit);
  } while (kredit >= annuitaet);
  gesamtaufwand = gesamtaufwand + restkredit;
  printf("\n%-20s %20.2lf Euro\n", "Adirhlusszahlung: ", restkredit);
  printf("%-20s %20.2lf Euro\n", "Gesamtaufwand: ", gesamtaufwand);
}


x86 assembly (clang, -O0):
<schreibe_tilgungsplan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1060 <berechne_anfangs_tilgung@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1050 <berechne_zinsen@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1040 <berechne_annuitaet@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe4d(%rip),%rdi
lea    0xe66(%rip),%rsi
lea    0xe64(%rip),%rdx
lea    0xe66(%rip),%rcx
lea    0xe69(%rip),%r8
lea    0xe6a(%rip),%r9
lea    0xe6a(%rip),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
movsd  -0x8(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
lea    0xe45(%rip),%rdi
mov    $0x5,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1050 <berechne_zinsen@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x1c(%rbp),%esi
movsd  -0x8(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm4
lea    0xdc8(%rip),%rdi
mov    $0x5,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jae    1227 <schreibe_tilgungsplan+0xe7>
movsd  -0x48(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
lea    0xdc4(%rip),%rdi
lea    0xdd2(%rip),%rsi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x48(%rbp),%xmm0
lea    0xdab(%rip),%rdi
lea    0xdcb(%rip),%rsi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<schreibe_tilgungsplan>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movsd  %xmm1,0x28(%rsp)
movaps %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
movaps %xmm2,%xmm0
call   1070 <berechne_anfangs_tilgung@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1060 <berechne_zinsen@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm1
call   1050 <berechne_annuitaet@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rax
mov    %rax,(%rsp)
lea    0xe34(%rip),%rdi
lea    0xe4d(%rip),%rsi
lea    0xe4b(%rip),%rdx
lea    0xe4d(%rip),%rcx
lea    0xe50(%rip),%r8
lea    0xe51(%rip),%r9
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe53(%rip),%rdi
mov    $0x1,%esi
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  0x30(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
mov    $0x5,%al
call   1040 <printf@plt>
mov    $0x2,%ebx
lea    0xe1e(%rip),%r14
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
nop
movsd  0x18(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
call   1060 <berechne_zinsen@plt>
movapd %xmm0,%xmm3
movsd  0x20(%rsp),%xmm1
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
movsd  0x18(%rsp),%xmm4
subsd  %xmm2,%xmm4
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
movsd  0x10(%rsp),%xmm0
movsd  %xmm4,0x18(%rsp)
mov    $0x5,%al
call   1040 <printf@plt>
add    $0x1,%ebx
movsd  0x10(%rsp),%xmm0
ucomisd 0x20(%rsp),%xmm0
jae    1240 <schreibe_tilgungsplan+0xf0>
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0xdb6(%rip),%rdi
lea    0xdc4(%rip),%rsi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xda2(%rip),%rdi
lea    0xdc2(%rip),%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
add    $0x38,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"\0A\09\09\09\09\09\09TILGUNGSPLAN\0A\00"
@.str.1 = [32 x i8] c"\0A%-6s %20s %20s %20s %20s %20s\0A\00"
@.str.2 = [5 x i8] c"Jahr\00"
@.str.3 = [9 x i8] c"Kredit A\00"
@.str.4 = [10 x i8] c"Annuit\C3\A4t\00"
@.str.5 = [8 x i8] c"Tilgung\00"
@.str.6 = [7 x i8] c"Zinsen\00"
@.str.7 = [9 x i8] c"Kredit E\00"
@.str.8 = [47 x i8] c"\0A%-6d %20.2lf %20.2lf %20.2lf %20.2lf %20.2lf\0A\00"
@.str.9 = [46 x i8] c"%-6d %20.2lf %20.2lf %20.2lf %20.2lf %20.2lf\0A\00"
@.str.10 = [21 x i8] c"\0A%-20s %20.2lf Euro\0A\00"
@.str.11 = [19 x i8] c"Adirhlusszahlung: \00"
@.str.12 = [20 x i8] c"%-20s %20.2lf Euro\0A\00"
@.str.13 = [16 x i8] c"Gesamtaufwand: \00"
define void @schreibe_tilgungsplan(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
store i32 1, i32* %7
%13 = load double, double* %6
%14 = load double, double* %4
%15 = call double @berechne_anfangs_tilgung(double %13, double %14)
store double %15, double* %8
%16 = load double, double* %5
%17 = load double, double* %4
%18 = call double @berechne_zinsen(double %16, double %17)
store double %18, double* %9
%19 = load double, double* %9
%20 = load double, double* %8
%21 = call double @berechne_annuitaet(double %19, double %20)
store double %21, double* %10
%22 = load double, double* %4
%23 = load double, double* %8
%24 = fsub double %22, %23
store double %24, double* %11
%25 = load double, double* %10
store double %25, double* %12
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%28 = load i32, i32* %7
%29 = load double, double* %4
%30 = load double, double* %10
%31 = load double, double* %8
%32 = load double, double* %9
%33 = load double, double* %11
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i32 %28, double %29, double %30, double %31, double %32, double %33)
br label %35
35: ; preds = %58, %3
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
%38 = load double, double* %11
store double %38, double* %4
%39 = load double, double* %5
%40 = load double, double* %4
%41 = call double @berechne_zinsen(double %39, double %40)
store double %41, double* %9
%42 = load double, double* %10
%43 = load double, double* %9
%44 = fsub double %42, %43
store double %44, double* %8
%45 = load double, double* %4
%46 = load double, double* %8
%47 = fsub double %45, %46
store double %47, double* %11
%48 = load double, double* %12
%49 = load double, double* %10
%50 = fadd double %48, %49
store double %50, double* %12
%51 = load i32, i32* %7
%52 = load double, double* %4
%53 = load double, double* %10
%54 = load double, double* %8
%55 = load double, double* %9
%56 = load double, double* %11
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i32 %51, double %52, double %53, double %54, double %55, double %56)
br label %58
58: ; preds = %35
%59 = load double, double* %4
%60 = load double, double* %10
%61 = fcmp oge double %59, %60
br i1 %61, label %35, label %62
62: ; preds = %58
%63 = load double, double* %12
%64 = load double, double* %11
%65 = fadd double %63, %64
store double %65, double* %12
%66 = load double, double* %11
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), double %66)
%68 = load double, double* %12
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0), double %68)
ret void
}

LLVM IR (-O2):
@.str.1 = [32 x i8] c"\0A%-6s %20s %20s %20s %20s %20s\0A\00"
@.str.2 = [5 x i8] c"Jahr\00"
@.str.3 = [9 x i8] c"Kredit A\00"
@.str.4 = [10 x i8] c"Annuit\C3\A4t\00"
@.str.5 = [8 x i8] c"Tilgung\00"
@.str.6 = [7 x i8] c"Zinsen\00"
@.str.7 = [9 x i8] c"Kredit E\00"
@.str.8 = [47 x i8] c"\0A%-6d %20.2lf %20.2lf %20.2lf %20.2lf %20.2lf\0A\00"
@.str.9 = [46 x i8] c"%-6d %20.2lf %20.2lf %20.2lf %20.2lf %20.2lf\0A\00"
@.str.10 = [21 x i8] c"\0A%-20s %20.2lf Euro\0A\00"
@.str.11 = [19 x i8] c"Adirhlusszahlung: \00"
@.str.12 = [20 x i8] c"%-20s %20.2lf Euro\0A\00"
@.str.13 = [16 x i8] c"Gesamtaufwand: \00"
@str = [20 x i8] c"\0A\09\09\09\09\09\09TILGUNGSPLAN\00"
define void @schreibe_tilgungsplan(double %0, double %1, double %2) {
%4 = tail call double @berechne_anfangs_tilgung(double %2, double %0)
%5 = tail call double @berechne_zinsen(double %1, double %0)
%6 = tail call double @berechne_annuitaet(double %5, double %4)
%7 = fsub double %0, %4
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i32 1, double %0, double %6, double %4, double %5, double %7)
br label %11
11: ; preds = %11, %3
%12 = phi i32 [ 1, %3 ], [ %15, %11 ]
%13 = phi double [ %7, %3 ], [ %18, %11 ]
%14 = phi double [ %6, %3 ], [ %19, %11 ]
%15 = add nuw nsw i32 %12, 1
%16 = tail call double @berechne_zinsen(double %1, double %13)
%17 = fsub double %6, %16
%18 = fsub double %13, %17
%19 = fadd double %6, %14
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i32 %15, double %13, double %6, double %17, double %16, double %18)
%21 = fcmp ult double %13, %6
br i1 %21, label %22, label %11
22: ; preds = %11
%23 = fadd double %19, %18
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), double %18)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0), double %23)
ret void
}