#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 persons;
  printf("Haendeschuetteln aller Personen auf einer Party\n");
  printf("===============================================\n");
  printf("Druecke 'q' zum beenden.\n");
  while (run) {
    printf("\nWieviele Personen sind auf der Party? ");
    int inputok = scanf("%u", &persons);
    if (!inputok) {
      char quit = getchar();
      if (quit == 'q' || quit == 'Q')
        run = 0;
      printf("Eingabe ist keine gueltige positive Ganzzahl!\n");
      continue;
    }
    unsigned int summe = 0;
    for (unsigned int i = persons - 1; i > 0; i--)
      summe += i;
    printf("  Es werden %u mal die Haende geschuettelt.\n", 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    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     123a <main+0xfa>
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf05(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11f3 <main+0xb3>
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    11e0 <main+0xa0>
movl   $0x0,-0x8(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1180 <main+0x40>
movl   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jbe    1224 <main+0xe4>
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1203 <main+0xc3>
mov    -0x18(%rbp),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1180 <main+0x40>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d99(%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   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf20(%rip),%rdi
call   1030 <puts@plt>
lea    0xf44(%rip),%rdi
call   1030 <puts@plt>
lea    0xf68(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7a(%rip),%r14
lea    0xe9b(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xf62(%rip),%r12
lea    0xe8b(%rip),%r13
jmp    11d9 <main+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%esi
add    $0xfffffffe,%eax
imul   %rsi,%rax
shr    %rax
imul   %esi,%esi
sub    %eax,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
test   %ebp,%ebp
je     120f <main+0xbf>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
test   %eax,%eax
jne    11b0 <main+0x60>
xor    %eax,%eax
call   1050 <getchar@plt>
and    $0xdf,%al
xor    %ebp,%ebp
cmp    $0x51,%al
setne  %bpl
mov    %r12,%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
jne    11d9 <main+0x89>
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Haendeschuetteln aller Personen auf einer Party\0A\00"
@.str.1 = [49 x i8] c"===============================================\0A\00"
@.str.2 = [26 x i8] c"Druecke 'q' zum beenden.\0A\00"
@.str.3 = [40 x i8] c"\0AWieviele Personen sind auf der Party? \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 = [45 x i8] c" Es werden %u mal die Haende geschuettelt.\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 ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 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 = %44, %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 ([40 x i8], [40 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
store i32 0, i32* %2
br label %29
29: ; preds = %28, %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
%32 = load i32, i32* %3
%33 = sub i32 %32, 1
store i32 %33, i32* %7
br label %34
34: ; preds = %41, %31
%35 = load i32, i32* %7
%36 = icmp ugt i32 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i32, i32* %7
%39 = load i32, i32* %6
%40 = add i32 %39, %38
store i32 %40, i32* %6
br label %41
41: ; preds = %37
%42 = load i32, i32* %7
%43 = add i32 %42, -1
store i32 %43, i32* %7
br label %34
44: ; preds = %34
%45 = load i32, i32* %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %45)
br label %11
47: ; preds = %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 = [40 x i8] c"\0AWieviele Personen sind auf der Party? \00"
@.str.4 = [3 x i8] c"%u\00"
@.str.6 = [45 x i8] c" Es werden %u mal die Haende geschuettelt.\0A\00"
@.str.7 = [42 x i8] c"Die Anwendung wurde vom Benutzer beendet.\00"
@stdin = global i32 0
@str = [48 x i8] c"Haendeschuetteln aller Personen auf einer Party\00"
@str.8 = [48 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 ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 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 = %0, %28
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 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 %10, label %16
10: ; preds = %6
%11 = call signext i8 (...) @getchar()
%12 = and i8 %11, -33
%13 = icmp ne i8 %12, 81
%14 = zext i1 %13 to i32
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.10, i64 0, i64 0))
br label %28
16: ; preds = %6
%17 = load i32, i32* %1
%18 = add i32 %17, -1
%19 = zext i32 %18 to i33
%20 = add i32 %17, -2
%21 = zext i32 %20 to i33
%22 = mul i33 %19, %21
%23 = lshr i33 %22, 1
%24 = trunc i33 %23 to i32
%25 = mul i32 %18, %18
%26 = sub i32 %25, %24
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %16, %10
%29 = phi i32 [ 1, %16 ], [ %14, %10 ]
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %6
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%33 = load i32, i32* @stdin
%34 = call i32 @fflush(i32 %33)
%35 = call signext i8 (...) @getchar()
ret i32 0
}