#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 RE_DUP_MAX;
int /*<<< orphan*/ isdigit(char const);
const char *parse_dup_count(const char *s, int *n) {
  *n = -1;
  if (!isdigit(*s))
    return s;
  *n = 0;
  for (;;) {
    *n = 10 * *n + (*s - '0');
    s++;
    if (!isdigit(*s) || *n > RE_DUP_MAX)
      break;
  }
  return s;
}


x86 assembly (clang, -O0):
<parse_dup_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    114c <parse_dup_count+0x3c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b7 <parse_dup_count+0xa7>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
imul   $0xa,(%rax),%ecx
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
add    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11a5 <parse_dup_count+0x95>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%eax
jle    11aa <parse_dup_count+0x9a>
jmp    11af <parse_dup_count+0x9f>
jmp    1156 <parse_dup_count+0x46>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_dup_count>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0xffffffff,(%rsi)
movsbl (%rdi),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     117b <parse_dup_count+0x6b>
movl   $0x0,(%r14)
add    $0x1,%rbx
xor    %eax,%eax
mov    0x2eb7(%rip),%r15
mov    %rbx,%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rcx,%rbx
lea    (%rax,%rax,4),%eax
movsbl -0x1(%rcx),%ecx
lea    (%rcx,%rax,2),%eax
add    $0xffffffd0,%eax
mov    %eax,(%r14)
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     117b <parse_dup_count+0x6b>
mov    (%r14),%eax
lea    0x1(%rbx),%rcx
cmp    (%r15),%eax
jle    1150 <parse_dup_count+0x40>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RE_DUP_MAX = global i32 0
define i8* @parse_dup_count(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i32*, i32** %5
store i32 -1, i32* %6
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = call i32 @isdigit(i8 signext %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = load i8*, i8** %4
store i8* %12, i8** %3
br label %40
13: ; preds = %2
%14 = load i32*, i32** %5
store i32 0, i32* %14
br label %15
15: ; preds = %37, %13
%16 = load i32*, i32** %5
%17 = load i32, i32* %16
%18 = mul nsw i32 10, %17
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = sub nsw i32 %21, 48
%23 = add nsw i32 %18, %22
%24 = load i32*, i32** %5
store i32 %23, i32* %24
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %4
%27 = load i8*, i8** %4
%28 = load i8, i8* %27
%29 = call i32 @isdigit(i8 signext %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %15
%32 = load i32*, i32** %5
%33 = load i32, i32* %32
%34 = load i32, i32* @RE_DUP_MAX
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %31, %15
br label %38
37: ; preds = %31
br label %15
38: ; preds = %36
%39 = load i8*, i8** %4
store i8* %39, i8** %3
br label %40
40: ; preds = %38, %11
%41 = load i8*, i8** %3
ret i8* %41
}

LLVM IR (-O2):
@RE_DUP_MAX = global i32 0
define i8* @parse_dup_count(i8* %0, i32* nocapture %1) {
store i32 -1, i32* %1
%3 = load i8, i8* %0
%4 = tail call i32 @isdigit(i8 signext %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %23, label %6
6: ; preds = %2
store i32 0, i32* %1
br label %7
7: ; preds = %19, %6
%8 = phi i32 [ 0, %6 ], [ %20, %19 ]
%9 = phi i8* [ %0, %6 ], [ %15, %19 ]
%10 = mul nsw i32 %8, 10
%11 = load i8, i8* %9
%12 = sext i8 %11 to i32
%13 = add i32 %10, -48
%14 = add i32 %13, %12
store i32 %14, i32* %1
%15 = getelementptr inbounds i8, i8* %9, i64 1
%16 = load i8, i8* %15
%17 = tail call i32 @isdigit(i8 signext %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %7
%20 = load i32, i32* %1
%21 = load i32, i32* @RE_DUP_MAX
%22 = icmp sgt i32 %20, %21
br i1 %22, label %23, label %7
23: ; preds = %19, %7, %2
%24 = phi i8* [ %0, %2 ], [ %15, %7 ], [ %15, %19 ]
ret i8* %24
}