#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 atoi(char *);
int /*<<< orphan*/ clear_digits();
char getchar();
int /*<<< orphan*/ print_digits();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ process_digit(int, int);
int main(void) {
  char input;
  int current_digit, digits_processed;
  clear_digits();
  printf("Welcome to Calculator Numbers!\nDigits please: ");
  digits_processed = 0;
  while ((input = getchar()) != '\n') {
    if (digits_processed == 10)
      break;
    if (input < '/' || input > ':')
      continue;
    current_digit = atoi(&input);
    process_digit(current_digit, digits_processed);
    digits_processed++;
  }
  print_digits();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <clear_digits@plt>
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     11f2 <main+0x92>
cmpl   $0xa,-0x10(%rbp)
jne    11ae <main+0x4e>
jmp    11f2 <main+0x92>
movsbl -0x5(%rbp),%eax
cmp    $0x2f,%eax
jl     11c8 <main+0x68>
movsbl -0x5(%rbp),%eax
cmp    $0x3a,%eax
jle    11cd <main+0x6d>
jmp    1189 <main+0x29>
lea    -0x5(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <process_digit@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1189 <main+0x29>
mov    $0x0,%al
call   1050 <print_digits@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <clear_digits@plt>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
lea    0x7(%rsp),%rbx
xor    %ebp,%ebp
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     11b2 <main+0x52>
cmp    $0xa,%ebp
je     11b2 <main+0x52>
lea    -0x3b(%rax),%ecx
cmp    $0xf4,%cl
jb     1180 <main+0x20>
mov    %al,0x7(%rsp)
mov    %rbx,%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1060 <process_digit@plt>
add    $0x1,%ebp
jmp    1180 <main+0x20>
xor    %eax,%eax
call   1050 <print_digits@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Welcome to Calculator Numbers!\0ADigits please: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @clear_digits()
%6 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %7
7: ; preds = %24, %23, %0
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 10
br i1 %10, label %11, label %31
11: ; preds = %7
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 10
br i1 %13, label %14, label %15
14: ; preds = %11
br label %31
15: ; preds = %11
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = icmp slt i32 %17, 47
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i8, i8* %2
%21 = sext i8 %20 to i32
%22 = icmp sgt i32 %21, 58
br i1 %22, label %23, label %24
23: ; preds = %19, %15
br label %7
24: ; preds = %19
%25 = call i32 @atoi(i8* %2)
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = call i32 @process_digit(i32 %26, i32 %27)
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %7
31: ; preds = %14, %7
%32 = call i32 (...) @print_digits()
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [47 x i8] c"Welcome to Calculator Numbers!\0ADigits please: \00"
define i32 @main() {
%1 = alloca i8
%2 = tail call i32 (...) @clear_digits()
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %14, %0
%5 = phi i32 [ %17, %14 ], [ 0, %0 ]
%6 = icmp eq i32 %5, 10
br label %7
7: ; preds = %4, %11
%8 = tail call signext i8 (...) @getchar()
%9 = icmp eq i8 %8, 10
%10 = select i1 %9, i1 true, i1 %6
br i1 %10, label %18, label %11
11: ; preds = %7
%12 = add i8 %8, -59
%13 = icmp ult i8 %12, -12
br i1 %13, label %7, label %14
14: ; preds = %11
store i8 %8, i8* %1
%15 = call i32 @atoi(i8* %1)
%16 = tail call i32 @process_digit(i32 %15, i32 %5)
%17 = add nuw nsw i32 %5, 1
br label %4
18: ; preds = %7
%19 = tail call i32 (...) @print_digits()
ret i32 0
}