#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 factorial(unsigned int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char getchar();
double pow(unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, unsigned int *);
int /*<<< orphan*/ stdin;
int main(void) {
  int run = 1;
  unsigned int x, n;
  printf("Berechnung der Exponential-Reihe\n");
  printf("========================================\n");
  printf("Druecke 'q' zum beenden.\n");
  while (run) {
    printf("\nx? ");
    int inputok = scanf("%u", &x);
    if (!inputok) {
      char quit = getchar();
      if (quit == 'q' || quit == 'Q')
        run = 0;
      printf("Eingabe ist keine gueltige positive Ganzzahl!\n");
      continue;
    }
    printf("\nn? ");
    inputok = scanf("%u", &n);
    if (!inputok) {
      char quit = getchar();
      if (quit == 'q' || quit == 'Q')
        run = 0;
      printf("Eingabe ist keine gueltige positive Ganzzahl!\n");
      continue;
    }
    double summe = 0;
    for (unsigned int i = 0; i <= n; i++)
      summe += pow(x, i) / factorial(i);
    printf("  e hoch %u = %f (bis zum %u. Glied)\n", x, summe, n);
  }
  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    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     12f1 <main+0x191>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1213 <main+0xb3>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x71,%eax
je     11f9 <main+0x99>
movsbl -0x15(%rbp),%eax
cmp    $0x51,%eax
jne    1200 <main+0xa0>
movl   $0x0,-0x8(%rbp)
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a0 <main+0x40>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe43(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    127c <main+0x11c>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x16(%rbp)
movsbl -0x16(%rbp),%eax
cmp    $0x71,%eax
je     1262 <main+0x102>
movsbl -0x16(%rbp),%eax
cmp    $0x51,%eax
jne    1269 <main+0x109>
movl   $0x0,-0x8(%rbp)
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a0 <main+0x40>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
ja     12d3 <main+0x173>
mov    -0xc(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1080 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%edi
call   1030 <factorial@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    128b <main+0x12b>
mov    -0xc(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%edx
lea    0xdbd(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11a0 <main+0x40>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x30,%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    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe57(%rip),%r14
lea    0xe55(%rip),%r13
mov    %rsp,%r15
lea    0x4(%rsp),%rbp
jmp    11e1 <main+0x71>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
and    $0xdf,%bl
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x51,%bl
je     1276 <main+0x106>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
test   %eax,%eax
je     11c0 <main+0x50>
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1080 <scanf@plt>
test   %eax,%eax
je     11c0 <main+0x50>
xorpd  %xmm0,%xmm0
xor    %r12d,%r12d
xchg   %ax,%ax
movsd  %xmm0,0x10(%rsp)
mov    (%rsp),%edi
mov    %r12d,%esi
call   1090 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r12d,%edi
call   1040 <factorial@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x1,%r12d
mov    0x4(%rsp),%edx
cmp    %edx,%r12d
jbe    1220 <main+0xb0>
mov    (%rsp),%esi
lea    0xda3(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    11e1 <main+0x71>
lea    0xdb6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d5d(%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

LLVM IR (-O0):
@.str = [34 x i8] c"Berechnung der Exponential-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 = [5 x i8] c"\0Ax? \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 = [5 x i8] c"\0An? \00"
@.str.7 = [38 x i8] c" e hoch %u = %f (bis zum %u. Glied)\0A\00"
@.str.8 = [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 i32
%6 = alloca i8
%7 = alloca i8
%8 = alloca double
%9 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %67, %48, %31, %0
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %72
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 0
br i1 %20, label %33, label %21
21: ; preds = %16
%22 = call signext i8 (...) @getchar()
store i8 %22, i8* %6
%23 = load i8, i8* %6
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 113
br i1 %25, label %30, label %26
26: ; preds = %21
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 81
br i1 %29, label %30, label %31
30: ; preds = %26, %21
store i32 0, i32* %2
br label %31
31: ; preds = %30, %26
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
br label %13
33: ; preds = %16
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
store i32 %35, i32* %5
%36 = load i32, i32* %5
%37 = icmp ne i32 %36, 0
br i1 %37, label %50, label %38
38: ; preds = %33
%39 = call signext i8 (...) @getchar()
store i8 %39, i8* %7
%40 = load i8, i8* %7
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 113
br i1 %42, label %47, label %43
43: ; preds = %38
%44 = load i8, i8* %7
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 81
br i1 %46, label %47, label %48
47: ; preds = %43, %38
store i32 0, i32* %2
br label %48
48: ; preds = %47, %43
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
br label %13
50: ; preds = %33
store double 0.000000e+00, double* %8
store i32 0, i32* %9
br label %51
51: ; preds = %64, %50
%52 = load i32, i32* %9
%53 = load i32, i32* %4
%54 = icmp ule i32 %52, %53
br i1 %54, label %55, label %67
55: ; preds = %51
%56 = load i32, i32* %3
%57 = load i32, i32* %9
%58 = call double @pow(i32 %56, i32 %57)
%59 = load i32, i32* %9
%60 = call double @factorial(i32 %59)
%61 = fdiv double %58, %60
%62 = load double, double* %8
%63 = fadd double %62, %61
store double %63, double* %8
br label %64
64: ; preds = %55
%65 = load i32, i32* %9
%66 = add i32 %65, 1
store i32 %66, i32* %9
br label %51
67: ; preds = %51
%68 = load i32, i32* %3
%69 = load double, double* %8
%70 = load i32, i32* %4
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %68, double %69, i32 %70)
br label %13
72: ; preds = %13
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
%74 = load i32, i32* @stdin
%75 = call i32 @fflush(i32 %74)
%76 = call signext i8 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [5 x i8] c"\0Ax? \00"
@.str.4 = [3 x i8] c"%u\00"
@.str.6 = [5 x i8] c"\0An? \00"
@.str.7 = [38 x i8] c" e hoch %u = %f (bis zum %u. Glied)\0A\00"
@.str.8 = [42 x i8] c"Die Anwendung wurde vom Benutzer beendet.\00"
@stdin = global i32 0
@str = [33 x i8] c"Berechnung der Exponential-Reihe\00"
@str.9 = [41 x i8] c"========================================\00"
@str.10 = [25 x i8] c"Druecke 'q' zum beenden.\00"
@str.12 = [46 x i8] c"Eingabe ist keine gueltige positive Ganzzahl!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.9, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.10, i64 0, i64 0))
br label %8
8: ; preds = %40, %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %35, label %12
12: ; preds = %8
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = call signext i8 (...) @getchar()
%18 = and i8 %17, -33
%19 = icmp eq i8 %18, 81
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.12, i64 0, i64 0))
br i1 %19, label %41, label %40
21: ; preds = %24
%22 = load i32, i32* %1
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %22, double %31, i32 %33)
br label %40
24: ; preds = %12, %24
%25 = phi i32 [ %32, %24 ], [ 0, %12 ]
%26 = phi double [ %31, %24 ], [ 0.000000e+00, %12 ]
%27 = load i32, i32* %1
%28 = call double @pow(i32 %27, i32 %25)
%29 = call double @factorial(i32 %25)
%30 = fdiv double %28, %29
%31 = fadd double %26, %30
%32 = add i32 %25, 1
%33 = load i32, i32* %2
%34 = icmp ugt i32 %32, %33
br i1 %34, label %21, label %24
35: ; preds = %8
%36 = call signext i8 (...) @getchar()
%37 = and i8 %36, -33
%38 = icmp eq i8 %37, 81
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.12, i64 0, i64 0))
br i1 %38, label %41, label %40
40: ; preds = %35, %16, %21
br label %8
41: ; preds = %16, %35
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0))
%43 = load i32, i32* @stdin
%44 = call i32 @fflush(i32 %43)
%45 = call signext i8 (...) @getchar()
ret i32 0
}