#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*/ Clear();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
char getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int PinInput(void) {
  char pin[5], ch;
  int i, asc, intPin;
  Clear();
  printf("ESC zum Abbrechen\n");
  printf("PIN bitte eingeben <4 characters>: ");
  for (i = 0; i < 4; i++) {
    ch = getch();
    fflush(stdin);
    asc = ch;
    if (asc == 27) {
      break;
    }
    if (asc <= 47 || asc >= 58) {
      i--;
      continue;
    }
    pin[i] = ch;
    ch = '*';
    printf("%c", ch);
  }
  pin[i] = '\0';
  sscanf(pin, "%d", &intPin);
  return intPin;
}


x86 assembly (clang, -O0):
<PinInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <Clear@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    120b <PinInput+0xbb>
mov    $0x0,%al
call   1070 <getch@plt>
mov    %al,-0x6(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
movsbl -0x6(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1b,-0x10(%rbp)
jne    11ba <PinInput+0x6a>
jmp    120b <PinInput+0xbb>
cmpl   $0x2f,-0x10(%rbp)
jle    11ce <PinInput+0x7e>
cmpl   $0x3a,-0x10(%rbp)
jl     11dc <PinInput+0x8c>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11fd <PinInput+0xad>
mov    -0x6(%rbp),%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x5(%rbp,%rax,1)
movb   $0x2a,-0x6(%rbp)
movsbl -0x6(%rbp),%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1182 <PinInput+0x32>
movslq -0xc(%rbp),%rax
movb   $0x0,-0x5(%rbp,%rax,1)
lea    -0x5(%rbp),%rdi
lea    0xe1b(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PinInput>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <Clear@plt>
lea    0xea0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e47(%rip),%r14
xor    %r15d,%r15d
jmp    11ce <PinInput+0x5e>
cs nopw 0x0(%rax,%rax,1)
movslq %r15d,%rax
mov    %bl,0x7(%rsp,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
lea    0x1(%r15),%eax
cmp    $0x3,%r15d
mov    %eax,%r15d
jge    11f4 <PinInput+0x84>
xor    %eax,%eax
call   1090 <getch@plt>
mov    %eax,%ebx
mov    (%r14),%edi
call   1070 <fflush@plt>
cmp    $0x1b,%bl
je     11f1 <PinInput+0x81>
lea    -0x3a(%rbx),%eax
cmp    $0xf5,%al
ja     11b0 <PinInput+0x40>
add    $0xffffffff,%r15d
jmp    11c1 <PinInput+0x51>
mov    %r15d,%eax
cltq
movb   $0x0,0x7(%rsp,%rax,1)
lea    0xe22(%rip),%rsi
lea    0x7(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1080 <sscanf@plt>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"ESC zum Abbrechen\0A\00"
@.str.1 = [36 x i8] c"PIN bitte eingeben <4 characters>: \00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @PinInput() {
%1 = alloca [5 x i8]
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (...) @Clear()
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %9
9: ; preds = %38, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %41
12: ; preds = %9
%13 = call signext i8 (...) @getch()
store i8 %13, i8* %2
%14 = load i32, i32* @stdin
%15 = call i32 @fflush(i32 %14)
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 27
br i1 %19, label %20, label %21
20: ; preds = %12
br label %41
21: ; preds = %12
%22 = load i32, i32* %4
%23 = icmp sle i32 %22, 47
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* %4
%26 = icmp sge i32 %25, 58
br i1 %26, label %27, label %30
27: ; preds = %24, %21
%28 = load i32, i32* %3
%29 = add nsw i32 %28, -1
store i32 %29, i32* %3
br label %38
30: ; preds = %24
%31 = load i8, i8* %2
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %33
store i8 %31, i8* %34
store i8 42, i8* %2
%35 = load i8, i8* %2
%36 = sext i8 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %30, %27
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %9
41: ; preds = %20, %9
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %43
store i8 0, i8* %44
%45 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%46 = call i32 @sscanf(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%47 = load i32, i32* %5
ret i32 %47
}

LLVM IR (-O2):
@.str.1 = [36 x i8] c"PIN bitte eingeben <4 characters>: \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%d\00"
@str = [18 x i8] c"ESC zum Abbrechen\00"
define i32 @PinInput() {
%1 = alloca [5 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @Clear()
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %0, %23
%9 = phi i32 [ 0, %0 ], [ %25, %23 ]
%10 = tail call signext i8 (...) @getch()
%11 = load i32, i32* @stdin
%12 = tail call i32 @fflush(i32 %11)
%13 = icmp eq i8 %10, 27
br i1 %13, label %27, label %14
14: ; preds = %8
%15 = add i8 %10, -58
%16 = icmp ult i8 %15, -10
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = add nsw i32 %9, -1
br label %23
19: ; preds = %14
%20 = sext i32 %9 to i64
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %20
store i8 %10, i8* %21
%22 = tail call i32 @putchar(i32 42)
br label %23
23: ; preds = %19, %17
%24 = phi i32 [ %18, %17 ], [ %9, %19 ]
%25 = add nsw i32 %24, 1
%26 = icmp slt i32 %24, 3
br i1 %26, label %8, label %27
27: ; preds = %8, %23
%28 = phi i32 [ %9, %8 ], [ %25, %23 ]
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %29
store i8 0, i8* %30
%31 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%32 = load i32, i32* %2
ret i32 %32
}