#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 readNumber() {
  int invalidInput = 0, number;
  char c;
  do {
    printf("Zahl?: ");
    invalidInput = scanf("%d%c", &number, &c) != 2 || c != '\n';
    if (invalidInput)
      printf("Die Eingabe ist inkorrekt. Bitte eine korrekte Ganzzahl "
             "eingeben:\n");
  } while (invalidInput);
  return number;
}


x86 assembly (clang, -O0):
<readNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xec6(%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    116c <readNumber+0x4c>
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     118d <readNumber+0x6d>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
jmp    1192 <readNumber+0x72>
cmpl   $0x0,-0x4(%rbp)
jne    112f <readNumber+0xf>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readNumber>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0xb(%rsp),%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    116b <readNumber+0x3b>
cmpb   $0xa,0xb(%rsp)
je     11ba <readNumber+0x8a>
lea    0xe9b(%rip),%r14
lea    0xe87(%rip),%r15
lea    0xe88(%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 <readNumber+0x60>
cmpb   $0xa,0xb(%rsp)
jne    1190 <readNumber+0x60>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Zahl?: \00"
@.str.1 = [5 x i8] c"%d%c\00"
@.str.2 = [67 x i8] c"Die Eingabe ist inkorrekt. Bitte eine korrekte Ganzzahl eingeben:\0A\00"
define i32 @readNumber() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
br label %4
4: ; preds = %20, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 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 ([67 x i8], [67 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 = [8 x i8] c"Zahl?: \00"
@.str.1 = [5 x i8] c"%d%c\00"
@str = [66 x i8] c"Die Eingabe ist inkorrekt. Bitte eine korrekte Ganzzahl eingeben:\00"
define i32 @readNumber() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 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 ([66 x i8], [66 x i8]* @str, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 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
}