#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*/ printf(char *);
int scanf(char *, int *, char *);
int getIterations() {
  int inputinvalid, iterations;
  char c;
  do {
    printf("Anzahl der Simulationen: ");
    inputinvalid = scanf("%d%c", &iterations, &c) != 2 || c != '\n';
    if (inputinvalid)
      printf("Eingabe ungueltig.\n");
  } while (inputinvalid);
  return iterations;
}


x86 assembly (clang, -O0):
<getIterations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x9(%rbp),%rdx
call   1040 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x2,%ecx
mov    %al,-0xa(%rbp)
jne    1165 <getIterations+0x45>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1186 <getIterations+0x66>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
jmp    118b <getIterations+0x6b>
cmpl   $0x0,-0x4(%rbp)
jne    1128 <getIterations+0x8>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIterations>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0xb(%rsp),%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    116b <getIterations+0x3b>
cmpb   $0xa,0xb(%rsp)
je     11ba <getIterations+0x8a>
lea    0xead(%rip),%r14
lea    0xe87(%rip),%r15
lea    0xe9a(%rip),%r12
lea    0xc(%rsp),%r13
lea    0xb(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    1190 <getIterations+0x60>
cmpb   $0xa,0xb(%rsp)
jne    1190 <getIterations+0x60>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Anzahl der Simulationen: \00"
@.str.1 = [5 x i8] c"%d%c\00"
@.str.2 = [20 x i8] c"Eingabe ungueltig.\0A\00"
define i32 @getIterations() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
br label %4
4: ; preds = %20, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i8* %3)
%7 = icmp ne i32 %6, 2
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br label %12
12: ; preds = %8, %4
%13 = phi i1 [ true, %4 ], [ %11, %8 ]
%14 = zext i1 %13 to i32
store i32 %14, i32* %1
%15 = load i32, i32* %1
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
br label %20
20: ; preds = %19
%21 = load i32, i32* %1
%22 = icmp ne i32 %21, 0
br i1 %22, label %4, label %23
23: ; preds = %20
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [26 x i8] c"Anzahl der Simulationen: \00"
@.str.1 = [5 x i8] c"%d%c\00"
@str = [19 x i8] c"Eingabe ungueltig.\00"
define i32 @getIterations() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i8* %2)
%6 = icmp ne i32 %5, 2
%7 = load i8, i8* %2
%8 = icmp ne i8 %7, 10
%9 = select i1 %6, i1 true, i1 %8
br i1 %9, label %10, label %18
10: ; preds = %0, %10
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %1, i8* %2)
%14 = icmp ne i32 %13, 2
%15 = load i8, i8* %2
%16 = icmp ne i8 %15, 10
%17 = select i1 %14, i1 true, i1 %16
br i1 %17, label %10, label %18
18: ; preds = %10, %0
%19 = load i32, i32* %1
ret i32 %19
}