#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) {
      return -1;
    }
    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,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1212 <pinInput+0xc2>
mov    $0x0,%al
call   1070 <getch@plt>
mov    %al,-0xa(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
movsbl -0xa(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1b,-0x14(%rbp)
jne    11c1 <pinInput+0x71>
movl   $0xffffffff,-0x4(%rbp)
jmp    1235 <pinInput+0xe5>
cmpl   $0x2f,-0x14(%rbp)
jle    11d5 <pinInput+0x85>
cmpl   $0x3a,-0x14(%rbp)
jl     11e3 <pinInput+0x93>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1204 <pinInput+0xb4>
mov    -0xa(%rbp),%cl
movslq -0x10(%rbp),%rax
mov    %cl,-0x9(%rbp,%rax,1)
movb   $0x2a,-0xa(%rbp)
movsbl -0xa(%rbp),%esi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1182 <pinInput+0x32>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x9(%rbp,%rax,1)
lea    -0x9(%rbp),%rdi
lea    0xe14(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pinInput>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1050 <Clear@plt>
lea    0xea1(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e48(%rip),%r14
xor    %ebp,%ebp
jmp    11cb <pinInput+0x5b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %ebp,%rax
mov    %bl,0x7(%rsp,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
lea    0x1(%rax),%ebp
cmp    $0x3,%eax
jge    11ed <pinInput+0x7d>
xor    %eax,%eax
call   1090 <getch@plt>
mov    %eax,%ebx
mov    (%r14),%edi
call   1070 <fflush@plt>
cmp    $0x1b,%bl
je     1210 <pinInput+0xa0>
lea    -0x3a(%rbx),%eax
cmp    $0xf5,%al
ja     11b0 <pinInput+0x40>
add    $0xffffffff,%ebp
jmp    11c1 <pinInput+0x51>
mov    %ebp,%eax
movb   $0x0,0x7(%rsp,%rax,1)
lea    0xe29(%rip),%rsi
lea    0x7(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1080 <sscanf@plt>
mov    0xc(%rsp),%eax
jmp    1215 <pinInput+0xa5>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
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 i32
%2 = alloca [5 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = call i32 (...) @Clear()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %10
10: ; preds = %39, %0
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %42
13: ; preds = %10
%14 = call signext i8 (...) @getch()
store i8 %14, i8* %3
%15 = load i32, i32* @stdin
%16 = call i32 @fflush(i32 %15)
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 27
br i1 %20, label %21, label %22
21: ; preds = %13
store i32 -1, i32* %1
br label %49
22: ; preds = %13
%23 = load i32, i32* %5
%24 = icmp sle i32 %23, 47
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %5
%27 = icmp sge i32 %26, 58
br i1 %27, label %28, label %31
28: ; preds = %25, %22
%29 = load i32, i32* %4
%30 = add nsw i32 %29, -1
store i32 %30, i32* %4
br label %39
31: ; preds = %25
%32 = load i8, i8* %3
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %34
store i8 %32, i8* %35
store i8 42, i8* %3
%36 = load i8, i8* %3
%37 = sext i8 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %31, %28
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %10
42: ; preds = %10
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %44
store i8 0, i8* %45
%46 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%47 = call i32 @sscanf(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%48 = load i32, i32* %6
store i32 %48, i32* %1
br label %49
49: ; preds = %42, %21
%50 = load i32, i32* %1
ret i32 %50
}

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 %32, 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 = %23
%28 = zext i32 %25 to i64
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%31 = load i32, i32* %2
br label %32
32: ; preds = %8, %27
%33 = phi i32 [ %31, %27 ], [ -1, %8 ]
ret i32 %33
}