#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 */
scalar_t__ isdigit(char);
char nextChar();
int /*<<< orphan*/ printf(char *, char *);
char digitprocess(char ch) {
  char buffer[1024];
  int bufPtr = 0;
  while (isdigit(ch) || '.' == ch) {
    buffer[bufPtr++] = ch;
    ch = nextChar();
  }
  buffer[bufPtr] = '\0';
  printf("(3, \"%s\")\n", buffer);
  return ch;
}


x86 assembly (clang, -O0):
<digitprocess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x414(%rbp)
movsbl -0x1(%rbp),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x415(%rbp)
jne    117d <digitprocess+0x4d>
movsbl -0x1(%rbp),%ecx
mov    $0x2e,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x415(%rbp)
mov    -0x415(%rbp),%al
test   $0x1,%al
jne    1190 <digitprocess+0x60>
jmp    11bc <digitprocess+0x8c>
mov    -0x1(%rbp),%cl
mov    -0x414(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x414(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
mov    $0x0,%al
call   1040 <nextChar@plt>
mov    %al,-0x1(%rbp)
jmp    114b <digitprocess+0x1b>
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rsi
lea    0xe27(%rip),%rdi
call   1050 <printf@plt>
movsbl -0x1(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<digitprocess>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %edi,%r14d
call   1030 <isdigit@plt>
cmp    $0x2e,%r14b
je     1152 <digitprocess+0x22>
test   %rax,%rax
jne    1152 <digitprocess+0x22>
xor    %eax,%eax
jmp    1189 <digitprocess+0x59>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14b,(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <nextChar@plt>
mov    %eax,%r14d
movsbl %al,%ebp
mov    %ebp,%edi
call   1030 <isdigit@plt>
cmp    $0x2e,%bpl
je     1160 <digitprocess+0x30>
test   %rax,%rax
jne    1160 <digitprocess+0x30>
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xe6c(%rip),%rdi
mov    %rsp,%rsi
call   1050 <printf@plt>
mov    %r14d,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"(3, \22%s\22)\0A\00"
define signext i8 @digitprocess(i8 signext %0) {
%2 = alloca i8
%3 = alloca [1024 x i8]
%4 = alloca i32
store i8 %0, i8* %2
store i32 0, i32* %4
br label %5
5: ; preds = %15, %1
%6 = load i8, i8* %2
%7 = call i64 @isdigit(i8 signext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp eq i32 46, %11
br label %13
13: ; preds = %9, %5
%14 = phi i1 [ true, %5 ], [ %12, %9 ]
br i1 %14, label %15, label %22
15: ; preds = %13
%16 = load i8, i8* %2
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %19
store i8 %16, i8* %20
%21 = call signext i8 (...) @nextChar()
store i8 %21, i8* %2
br label %5
22: ; preds = %13
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %24
store i8 0, i8* %25
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = load i8, i8* %2
ret i8 %28
}

LLVM IR (-O2):
@.str = [11 x i8] c"(3, \22%s\22)\0A\00"
define signext i8 @digitprocess(i8 signext %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @isdigit(i8 signext %0)
%5 = icmp ne i64 %4, 0
%6 = icmp eq i8 %0, 46
%7 = or i1 %6, %5
br i1 %7, label %8, label %20
8: ; preds = %1, %8
%9 = phi i64 [ %11, %8 ], [ 0, %1 ]
%10 = phi i8 [ %13, %8 ], [ %0, %1 ]
%11 = add nuw i64 %9, 1
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %9
store i8 %10, i8* %12
%13 = tail call signext i8 (...) @nextChar()
%14 = tail call i64 @isdigit(i8 signext %13)
%15 = icmp ne i64 %14, 0
%16 = icmp eq i8 %13, 46
%17 = or i1 %16, %15
br i1 %17, label %8, label %18
18: ; preds = %8
%19 = and i64 %11, 4294967295
br label %20
20: ; preds = %18, %1
%21 = phi i8 [ %0, %1 ], [ %13, %18 ]
%22 = phi i64 [ 0, %1 ], [ %19, %18 ]
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %3)
ret i8 %21
}