#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("Summe von ungeraden Zahlen\n");
  printf("========================================\n");
  printf("Druecke 'q' zum beenden.\n");
  while (run) {
    printf(
        "\nBis zu welchem n sollen alle ungeraden Zahlen aufaddiert 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;
    }
    unsigned int summe = 0;
    for (unsigned int i = 1; i <= input; i += 2)
      summe += i;
    printf("  Summe der ungeraden Zahlen bis %u: %u\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    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     123b <main+0xfb>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf04(%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    123b <main+0xfb>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1180 <main+0x40>
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     1222 <main+0xe2>
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ff <main+0xbf>
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1180 <main+0x40>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xf35(%rip),%rdi
call   1030 <puts@plt>
lea    0xf44(%rip),%rdi
call   1030 <puts@plt>
lea    0xf61(%rip),%rdi
call   1030 <puts@plt>
lea    0xe78(%rip),%r14
lea    0xeb4(%rip),%r15
lea    0xc(%rsp),%rbx
lea    0xf5b(%rip),%r12
lea    0xea4(%rip),%r13
jmp    11d0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x1(%rsi),%eax
shr    %eax
lea    (%rax,%rax,2),%ecx
lea    -0x1(%rax),%edx
imul   %eax,%edx
and    $0xfffffffe,%edx
add    %ecx,%edx
add    $0x1,%edx
mov    %r13,%rdi
xor    %eax,%eax
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     1200 <main+0xb0>
mov    0xc(%rsp),%esi
test   %esi,%esi
jne    11b0 <main+0x60>
xor    %edx,%edx
jmp    11c6 <main+0x76>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <getchar@plt>
and    $0xdf,%al
cmp    $0x51,%al
je     1217 <main+0xc7>
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    11d0 <main+0x80>
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2dbc(%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 = [28 x i8] c"Summe von ungeraden Zahlen\0A\00"
@.str.1 = [42 x i8] c"========================================\0A\00"
@.str.2 = [26 x i8] c"Druecke 'q' zum beenden.\0A\00"
@.str.3 = [67 x i8] c"\0ABis zu welchem n sollen alle ungeraden Zahlen aufaddiert 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 = [41 x i8] c" Summe der ungeraden Zahlen bis %u: %u\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 i32
%7 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 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 = %43, %29, %0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %47
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 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 %47
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 i32 0, i32* %6
store i32 1, i32* %7
br label %32
32: ; preds = %40, %31
%33 = load i32, i32* %7
%34 = load i32, i32* %3
%35 = icmp ule i32 %33, %34
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i32, i32* %7
%38 = load i32, i32* %6
%39 = add i32 %38, %37
store i32 %39, i32* %6
br label %40
40: ; preds = %36
%41 = load i32, i32* %7
%42 = add i32 %41, 2
store i32 %42, i32* %7
br label %32
43: ; preds = %32
%44 = load i32, i32* %3
%45 = load i32, i32* %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i32 %44, i32 %45)
br label %11
47: ; preds = %28, %11
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%49 = load i32, i32* @stdin
%50 = call i32 @fflush(i32 %49)
%51 = call signext i8 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [67 x i8] c"\0ABis zu welchem n sollen alle ungeraden Zahlen aufaddiert werden? \00"
@.str.4 = [3 x i8] c"%u\00"
@.str.6 = [41 x i8] c" Summe der ungeraden Zahlen bis %u: %u\0A\00"
@.str.7 = [42 x i8] c"Die Anwendung wurde vom Benutzer beendet.\00"
@stdin = global i32 0
@str = [27 x i8] c"Summe von ungeraden Zahlen\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 ([27 x i8], [27 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 = %29, %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 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 %23, label %10
10: ; preds = %6
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %30, label %13
13: ; preds = %10
%14 = add i32 %11, -1
%15 = lshr i32 %14, 1
%16 = mul i32 %15, 3
%17 = lshr i32 %14, 1
%18 = add nsw i32 %15, -1
%19 = mul i32 %17, %18
%20 = and i32 %19, -2
%21 = add i32 %16, 1
%22 = add i32 %21, %20
br label %30
23: ; preds = %6
%24 = call signext i8 (...) @getchar()
%25 = and i8 %24, -33
%26 = icmp eq i8 %25, 81
br i1 %26, label %33, label %27
27: ; preds = %23
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.10, i64 0, i64 0))
br label %29
29: ; preds = %27, %30
br label %6
30: ; preds = %13, %10
%31 = phi i32 [ 0, %10 ], [ %22, %13 ]
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i32 %11, i32 %31)
br label %29
33: ; preds = %23
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%35 = load i32, i32* @stdin
%36 = call i32 @fflush(i32 %35)
%37 = call signext i8 (...) @getchar()
ret i32 0
}