#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*/ fflush(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, unsigned int *);
int /*<<< orphan*/ stdin;
int main(void) {
  int run = 1;
  unsigned int input;
  printf("Harmonische Reihe\n");
  printf("========================================\n");
  printf("Druecke 'q' zum beenden.\n");
  while (run) {
    printf("\nBis zu welchem n soll die harmonische Reihe berechnet werden? ");
    int inputok = scanf("%u", &input);
    if (!inputok) {
      char quit = getchar();
      if (quit == 'q' || quit == 'Q')
        break;
      printf("Eingabe ist keine gueltige positive Ganzzahl!\n");
      continue;
    }
    double summe = 0;
    for (int i = 1; i <= input; i++)
      summe += 1.0 / i;
    printf("  Summe bis 1/%u: %f\n", input, summe);
  }
  printf("Die Anwendung wurde vom Benutzer beendet.");
  fflush(stdin);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1250 <main+0x110>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11f1 <main+0xb1>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x71,%eax
je     11d9 <main+0x99>
movsbl -0x11(%rbp),%eax
cmp    $0x51,%eax
jne    11de <main+0x9e>
jmp    1250 <main+0x110>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1180 <main+0x40>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     1235 <main+0xf5>
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xde7(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1200 <main+0xc0>
mov    -0xc(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1180 <main+0x40>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xf27(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2d(%rip),%rdi
call   1030 <puts@plt>
lea    0xf4a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe80(%rip),%r14
lea    0xeb9(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xf44(%rip),%r12
lea    0xea9(%rip),%r13
jmp    11be <main+0x6e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xorpd  %xmm0,%xmm0
mov    %r13,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
test   %eax,%eax
je     11f0 <main+0xa0>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     11b0 <main+0x60>
cmp    $0x1,%esi
jne    1207 <main+0xb7>
xorpd  %xmm0,%xmm0
mov    $0x1,%eax
jmp    1250 <main+0x100>
nop
xor    %eax,%eax
call   1050 <getchar@plt>
and    $0xdf,%al
cmp    $0x51,%al
je     1276 <main+0x126>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    11be <main+0x6e>
mov    %esi,%ecx
and    $0xfffffffe,%ecx
xorpd  %xmm0,%xmm0
mov    $0x1,%eax
movsd  0xde3(%rip),%xmm3
nopl   (%rax)
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd %xmm3,%xmm2
divsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
lea    0x1(%rax),%edx
xorps  %xmm1,%xmm1
cvtsi2sd %edx,%xmm1
movapd %xmm3,%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
add    $0x2,%eax
cmp    %ecx,%edx
jne    1220 <main+0xd0>
test   $0x1,%sil
je     11b4 <main+0x64>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xd97(%rip),%xmm2
divsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
jmp    11b4 <main+0x64>
lea    0xde4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Harmonische Reihe\0A\00"
@.str.1 = [42 x i8] c"========================================\0A\00"
@.str.2 = [26 x i8] c"Druecke 'q' zum beenden.\0A\00"
@.str.3 = [64 x i8] c"\0ABis zu welchem n soll die harmonische Reihe berechnet werden? \00"
@.str.4 = [3 x i8] c"%u\00"
@.str.5 = [47 x i8] c"Eingabe ist keine gueltige positive Ganzzahl!\0A\00"
@.str.6 = [22 x i8] c" Summe bis 1/%u: %f\0A\00"
@.str.7 = [42 x i8] c"Die Anwendung wurde vom Benutzer beendet.\00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca double
%7 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %45, %29, %0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %49
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %31, label %19
19: ; preds = %14
%20 = call signext i8 (...) @getchar()
store i8 %20, i8* %5
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 113
br i1 %23, label %28, label %24
24: ; preds = %19
%25 = load i8, i8* %5
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 81
br i1 %27, label %28, label %29
28: ; preds = %24, %19
br label %49
29: ; preds = %24
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
br label %11
31: ; preds = %14
store double 0.000000e+00, double* %6
store i32 1, i32* %7
br label %32
32: ; preds = %42, %31
%33 = load i32, i32* %7
%34 = load i32, i32* %3
%35 = icmp ule i32 %33, %34
br i1 %35, label %36, label %45
36: ; preds = %32
%37 = load i32, i32* %7
%38 = sitofp i32 %37 to double
%39 = fdiv double 1.000000e+00, %38
%40 = load double, double* %6
%41 = fadd double %40, %39
store double %41, double* %6
br label %42
42: ; preds = %36
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %32
45: ; preds = %32
%46 = load i32, i32* %3
%47 = load double, double* %6
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %46, double %47)
br label %11
49: ; preds = %28, %11
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%51 = load i32, i32* @stdin
%52 = call i32 @fflush(i32 %51)
%53 = call signext i8 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [64 x i8] c"\0ABis zu welchem n soll die harmonische Reihe berechnet werden? \00"
@.str.4 = [3 x i8] c"%u\00"
@.str.6 = [22 x i8] c" Summe bis 1/%u: %f\0A\00"
@.str.7 = [42 x i8] c"Die Anwendung wurde vom Benutzer beendet.\00"
@stdin = global i32 0
@str = [18 x i8] c"Harmonische Reihe\00"
@str.8 = [41 x i8] c"========================================\00"
@str.9 = [25 x i8] c"Druecke 'q' zum beenden.\00"
@str.10 = [46 x i8] c"Eingabe ist keine gueltige positive Ganzzahl!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.8, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.9, i64 0, i64 0))
br label %6
6: ; preds = %24, %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %6
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %34, label %13
13: ; preds = %10
%14 = and i32 %11, 1
%15 = icmp eq i32 %11, 1
br i1 %15, label %25, label %16
16: ; preds = %13
%17 = and i32 %11, -2
br label %37
18: ; preds = %6
%19 = call signext i8 (...) @getchar()
%20 = and i8 %19, -33
%21 = icmp eq i8 %20, 81
br i1 %21, label %51, label %22
22: ; preds = %18
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.10, i64 0, i64 0))
br label %24
24: ; preds = %22, %34
br label %6
25: ; preds = %37, %13
%26 = phi double [ undef, %13 ], [ %47, %37 ]
%27 = phi i32 [ 1, %13 ], [ %48, %37 ]
%28 = phi double [ 0.000000e+00, %13 ], [ %47, %37 ]
%29 = icmp eq i32 %14, 0
br i1 %29, label %34, label %30
30: ; preds = %25
%31 = sitofp i32 %27 to double
%32 = fdiv double 1.000000e+00, %31
%33 = fadd double %28, %32
br label %34
34: ; preds = %30, %25, %10
%35 = phi double [ 0.000000e+00, %10 ], [ %26, %25 ], [ %33, %30 ]
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %11, double %35)
br label %24
37: ; preds = %37, %16
%38 = phi i32 [ 1, %16 ], [ %48, %37 ]
%39 = phi double [ 0.000000e+00, %16 ], [ %47, %37 ]
%40 = phi i32 [ 0, %16 ], [ %49, %37 ]
%41 = sitofp i32 %38 to double
%42 = fdiv double 1.000000e+00, %41
%43 = fadd double %39, %42
%44 = add nuw i32 %38, 1
%45 = sitofp i32 %44 to double
%46 = fdiv double 1.000000e+00, %45
%47 = fadd double %43, %46
%48 = add nuw i32 %38, 2
%49 = add i32 %40, 2
%50 = icmp eq i32 %49, %17
br i1 %50, label %25, label %37
51: ; preds = %18
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%53 = load i32, i32* @stdin
%54 = call i32 @fflush(i32 %53)
%55 = call signext i8 (...) @getchar()
ret i32 0
}