#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 */
typedef int uint8_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ error(int);
scalar_t__ isdigit(int);
uint8_t *linenumber(uint8_t *n, uint16_t *v) {
  uint16_t vp = 0, vn;
  while (isdigit(*n)) {
    vn = vp * 10 + *n - '0';
    if (vn < vp)
      goto bad;
    vp = vn;
    n++;
  }
  *v = vp;
  return n;
bad:
  error(6);
  return NULL;
}


x86 assembly (clang, -O0):
<linenumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1184 <linenumber+0x64>
imul   $0xa,-0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
add    (%rcx),%eax
sub    $0x30,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    116d <linenumber+0x4d>
jmp    119a <linenumber+0x7a>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    1137 <linenumber+0x17>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ac <linenumber+0x8c>
mov    $0x6,%edi
call   1040 <error@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linenumber>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1030 <isdigit@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1162 <linenumber+0x42>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
lea    (%rax,%rax,4),%ecx
mov    (%rbx),%edx
lea    (%rdx,%rcx,2),%ebp
add    $0xffffffd0,%ebp
cmp    %eax,%ebp
jl     1167 <linenumber+0x47>
mov    0x4(%rbx),%edi
add    $0x4,%rbx
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1140 <linenumber+0x20>
mov    %ebp,(%r14)
jmp    1173 <linenumber+0x53>
mov    $0x6,%edi
call   1040 <error@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32* @linenumber(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 0, i32* %6
br label %8
8: ; preds = %24, %2
%9 = load i32*, i32** %4
%10 = load i32, i32* %9
%11 = call i64 @isdigit(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %8
%14 = load i32, i32* %6
%15 = mul nsw i32 %14, 10
%16 = load i32*, i32** %4
%17 = load i32, i32* %16
%18 = add nsw i32 %15, %17
%19 = sub nsw i32 %18, 48
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %13
br label %32
24: ; preds = %13
%25 = load i32, i32* %7
store i32 %25, i32* %6
%26 = load i32*, i32** %4
%27 = getelementptr inbounds i32, i32* %26, i32 1
store i32* %27, i32** %4
br label %8
28: ; preds = %8
%29 = load i32, i32* %6
%30 = load i32*, i32** %5
store i32 %29, i32* %30
%31 = load i32*, i32** %4
store i32* %31, i32** %3
br label %34
32: ; preds = %23
%33 = call i32 @error(i32 6)
store i32* null, i32** %3
br label %34
34: ; preds = %32, %28
%35 = load i32*, i32** %3
ret i32* %35
}

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