#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_digits_array();
char getchar();
scalar_t__ isdigit(char);
int /*<<< orphan*/ print_digits_array(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ process_digit(int, int);
int main(void) {
  char ch;
  int converted_char;
  int digit_count = 0;
  clear_digits_array();
  printf("Enter a %d digit number: ", 34);
  while ((ch = getchar()) != '\n' && digit_count < 34) {
    if (isdigit(ch)) {
      converted_char = (int)ch - '0';
      process_digit(converted_char, (3 * digit_count));
      digit_count++;
    }
  }
  print_digits_array(3 * digit_count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1070 <clear_digits_array@plt>
lea    0xe7c(%rip),%rdi
mov    $0x22,%esi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x11(%rbp)
je     11b3 <main+0x53>
cmpl   $0x22,-0x10(%rbp)
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11c3 <main+0x63>
jmp    11fa <main+0x9a>
movsbl -0x5(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11f5 <main+0x95>
movsbl -0x5(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
imul   $0x3,-0x10(%rbp),%esi
call   1080 <process_digit@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118e <main+0x2e>
imul   $0x3,-0x10(%rbp),%edi
call   1050 <print_digits_array@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <clear_digits_array@plt>
lea    0xe8b(%rip),%rdi
mov    $0x22,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     11c2 <main+0x62>
xor    %r14d,%r14d
nopl   (%rax)
movsbl %al,%ebx
mov    %ebx,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11b1 <main+0x51>
add    $0xffffffd0,%ebx
lea    (%r14,%r14,2),%esi
mov    %ebx,%edi
call   1080 <process_digit@plt>
add    $0x1,%r14d
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0xa,%al
je     11c2 <main+0x62>
cmp    $0x22,%r14d
jl     1190 <main+0x30>
lea    (%r14,%r14,2),%edi
call   1050 <print_digits_array@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter a %d digit number: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (...) @clear_digits_array()
%6 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 34)
br label %7
7: ; preds = %30, %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 %14
11: ; preds = %7
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 34
br label %14
14: ; preds = %11, %7
%15 = phi i1 [ false, %7 ], [ %13, %11 ]
br i1 %15, label %16, label %31
16: ; preds = %14
%17 = load i8, i8* %2
%18 = call i64 @isdigit(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load i8, i8* %2
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 48
store i32 %23, i32* %3
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = mul nsw i32 3, %25
%27 = call i32 @process_digit(i32 %24, i32 %26)
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %30
30: ; preds = %20, %16
br label %7
31: ; preds = %14
%32 = load i32, i32* %4
%33 = mul nsw i32 3, %32
%34 = call i32 @print_digits_array(i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter a %d digit number: \00"
define i32 @main() {
%1 = tail call i32 (...) @clear_digits_array()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 34)
%3 = tail call signext i8 (...) @getchar()
%4 = icmp eq i8 %3, 10
br i1 %4, label %22, label %5
5: ; preds = %0, %16
%6 = phi i8 [ %18, %16 ], [ %3, %0 ]
%7 = phi i32 [ %17, %16 ], [ 0, %0 ]
%8 = tail call i64 @isdigit(i8 signext %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %5
%11 = sext i8 %6 to i32
%12 = add nsw i32 %11, -48
%13 = mul nsw i32 %7, 3
%14 = tail call i32 @process_digit(i32 %12, i32 %13)
%15 = add nsw i32 %7, 1
br label %16
16: ; preds = %10, %5
%17 = phi i32 [ %15, %10 ], [ %7, %5 ]
%18 = tail call signext i8 (...) @getchar()
%19 = icmp ne i8 %18, 10
%20 = icmp slt i32 %17, 34
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %5, label %22
22: ; preds = %16, %0
%23 = phi i32 [ 0, %0 ], [ %17, %16 ]
%24 = mul nsw i32 %23, 3
%25 = tail call i32 @print_digits_array(i32 %24)
ret i32 0
}