#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 */
char getchar();
int /*<<< orphan*/ printf(char *);
int readTypology() {
  char tmpChar = 'b';
  char prevTmpChar = 'b';
  int number = 0;
  while (tmpChar != '\n') {
    tmpChar = getchar();
    if (tmpChar == '\n') {
      number = (int)prevTmpChar - '0';
      if (number < 0 || number > 2) {
        tmpChar = 'b';
        number = 0;
        printf("Error: Typology must be a nummer form 0 to 2\n");
      }
    }
    prevTmpChar = tmpChar;
  }
  return number;
}


x86 assembly (clang, -O0):
<readTypology>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movb   $0x62,-0x1(%rbp)
movb   $0x62,-0x2(%rbp)
movl   $0x0,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0xa,%eax
je     11a0 <readTypology+0x80>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0xa,%eax
jne    1195 <readTypology+0x75>
movsbl -0x2(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     1179 <readTypology+0x59>
cmpl   $0x2,-0x8(%rbp)
jle    1190 <readTypology+0x70>
movb   $0x62,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <readTypology+0x75>
mov    -0x1(%rbp),%al
mov    %al,-0x2(%rbp)
jmp    1137 <readTypology+0x17>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readTypology>:
push   %r14
push   %rbx
push   %rax
mov    $0x62,%al
lea    0xed3(%rip),%r14
nopl   (%rax)
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1130 <readTypology+0x10>
lea    -0x33(%rbx),%eax
cmp    $0xfc,%al
ja     1150 <readTypology+0x30>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x62,%al
jmp    1130 <readTypology+0x10>
movsbl %bl,%eax
add    $0xffffffd0,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Error: Typology must be a nummer form 0 to 2\0A\00"
define i32 @readTypology() {
%1 = alloca i8
%2 = alloca i8
%3 = alloca i32
store i8 98, i8* %1
store i8 98, i8* %2
store i32 0, i32* %3
br label %4
4: ; preds = %25, %0
%5 = load i8, i8* %1
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %27
8: ; preds = %4
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %1
%10 = load i8, i8* %1
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 10
br i1 %12, label %13, label %25
13: ; preds = %8
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = sub nsw i32 %15, 48
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %13
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, 2
br i1 %21, label %22, label %24
22: ; preds = %19, %13
store i8 98, i8* %1
store i32 0, i32* %3
%23 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
br label %25
25: ; preds = %24, %8
%26 = load i8, i8* %1
store i8 %26, i8* %2
br label %4
27: ; preds = %4
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@str = [45 x i8] c"Error: Typology must be a nummer form 0 to 2\00"
define i32 @readTypology() {
br label %1
1: ; preds = %10, %0
%2 = phi i8 [ 98, %0 ], [ %11, %10 ]
%3 = tail call signext i8 (...) @getchar()
%4 = icmp eq i8 %3, 10
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = add i8 %2, -51
%7 = icmp ult i8 %6, -3
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = phi i8 [ 98, %8 ], [ %3, %1 ]
br label %1
12: ; preds = %5
%13 = sext i8 %2 to i32
%14 = add nsw i32 %13, -48
ret i32 %14
}