#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 EOF;
int add_one(int);
int getchar();
scalar_t__ isdigit(int);
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  int c;
  while ((c = getchar()) != EOF)
    if (isdigit(c))
      printf("%d + 1 = %d\n", c - '0', add_one(c - '0'));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%eax
je     11a4 <main+0x64>
mov    -0x8(%rbp),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     119f <main+0x5f>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x30,%edi
call   1030 <add_one@plt>
mov    -0xc(%rbp),%esi
mov    %eax,%edx
lea    0xe66(%rip),%rdi
call   1050 <printf@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e96(%rip),%rbx
cmp    (%rbx),%eax
jne    115d <main+0x1d>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe9a(%rip),%r14
jmp    117d <main+0x3d>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebp
cmp    (%rbx),%eax
je     1156 <main+0x16>
mov    %ebp,%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     1170 <main+0x30>
add    $0xffffffd0,%ebp
mov    %ebp,%edi
call   1030 <add_one@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1050 <printf@plt>
jmp    1170 <main+0x30>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [13 x i8] c"%d + 1 = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %18, %0
%4 = call i32 (...) @getchar()
store i32 %4, i32* %2
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
br i1 %6, label %7, label %19
7: ; preds = %3
%8 = load i32, i32* %2
%9 = call i64 @isdigit(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load i32, i32* %2
%13 = sub nsw i32 %12, 48
%14 = load i32, i32* %2
%15 = sub nsw i32 %14, 48
%16 = call i32 @add_one(i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %16)
br label %18
18: ; preds = %11, %7
br label %3
19: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [13 x i8] c"%d + 1 = %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %16, label %4
4: ; preds = %0, %12
%5 = phi i32 [ %13, %12 ], [ %1, %0 ]
%6 = tail call i64 @isdigit(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = add nsw i32 %5, -48
%10 = tail call i32 @add_one(i32 %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
br label %12
12: ; preds = %8, %4
%13 = tail call i32 (...) @getchar()
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %4
16: ; preds = %12, %0
ret i32 0
}