#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 getchar();
int gc(void) {
  register int c, n = 0;
  do {
    c = getchar();
  } while ((c < '0') || (c > '9'));
  do {
    n = n * 10 + (c - '0');
    c = getchar();
  } while ((c >= '0') && (c <= '9'));
  return n;
}


x86 assembly (clang, -O0):
<gc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    $0x1,%al
cmpl   $0x30,-0x4(%rbp)
mov    %al,-0x9(%rbp)
jl     1142 <gc+0x32>
cmpl   $0x39,-0x4(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    111f <gc+0xf>
jmp    1152 <gc+0x42>
imul   $0xa,-0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0x4(%rbp)
xor    %eax,%eax
cmpl   $0x30,-0x4(%rbp)
mov    %al,-0xa(%rbp)
jl     1184 <gc+0x74>
cmpl   $0x39,-0x4(%rbp)
setle  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    1152 <gc+0x42>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gc>:
push   %rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
lea    -0x3a(%rax),%ecx
cmp    $0xfffffff6,%ecx
jb     1120 <gc+0x10>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rbx,%rbx,4),%ecx
lea    (%rax,%rcx,2),%ebx
add    $0xffffffd0,%ebx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
add    $0xffffffd0,%ecx
cmp    $0xa,%ecx
jb     1140 <gc+0x30>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @gc() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %11, %0
%4 = call i32 (...) @getchar()
store i32 %4, i32* %1
br label %5
5: ; preds = %3
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 48
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 57
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ true, %5 ], [ %10, %8 ]
br i1 %12, label %3, label %13
13: ; preds = %11
br label %14
14: ; preds = %27, %13
%15 = load i32, i32* %2
%16 = mul nsw i32 %15, 10
%17 = load i32, i32* %1
%18 = sub nsw i32 %17, 48
%19 = add nsw i32 %16, %18
store i32 %19, i32* %2
%20 = call i32 (...) @getchar()
store i32 %20, i32* %1
br label %21
21: ; preds = %14
%22 = load i32, i32* %1
%23 = icmp sge i32 %22, 48
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* %1
%26 = icmp sle i32 %25, 57
br label %27
27: ; preds = %24, %21
%28 = phi i1 [ false, %21 ], [ %26, %24 ]
br i1 %28, label %14, label %29
29: ; preds = %27
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @gc() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 (...) @getchar()
%3 = add i32 %2, -58
%4 = icmp ult i32 %3, -10
br i1 %4, label %1, label %5
5: ; preds = %1, %5
%6 = phi i32 [ %11, %5 ], [ %2, %1 ]
%7 = phi i32 [ %10, %5 ], [ 0, %1 ]
%8 = mul nsw i32 %7, 10
%9 = add nsw i32 %6, -48
%10 = add nsw i32 %9, %8
%11 = tail call i32 (...) @getchar()
%12 = add i32 %11, -48
%13 = icmp ult i32 %12, 10
br i1 %13, label %5, label %14
14: ; preds = %5
ret i32 %10
}