number(val) int val[];
{
  int k, minus;
  char c;
  k = minus = 1;
  while (k) {
    k = 0;
    if (match("+"))
      k = 1;
    if (match("-")) {
      minus = (-minus);
      k = 1;
    }
  }
  if (numeric(ch()) == 0)
    return 0;
  while (numeric(ch())) {
    c = inbyte();
    k = k * 10 + (c - '0');
  }
  if (minus < 0)
    k = (-k);
  val[0] = k;
  return 1;
}


x86 assembly (clang, -O0):
<number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11b4 <number+0x74>
movl   $0x0,-0x14(%rbp)
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1050 <match@plt>
cmp    $0x0,%eax
je     1189 <number+0x49>
movl   $0x1,-0x14(%rbp)
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <match@plt>
cmp    $0x0,%eax
je     11af <number+0x6f>
xor    %eax,%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    115a <number+0x1a>
mov    $0x0,%al
call   1030 <ch@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1040 <numeric@plt>
cmp    $0x0,%eax
jne    11d9 <number+0x99>
movl   $0x0,-0x4(%rbp)
jmp    1238 <number+0xf8>
jmp    11de <number+0x9e>
mov    $0x0,%al
call   1030 <ch@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1040 <numeric@plt>
cmp    $0x0,%eax
je     1216 <number+0xd6>
mov    $0x0,%al
call   1060 <inbyte@plt>
mov    %al,-0x19(%rbp)
imul   $0xa,-0x14(%rbp),%eax
movsbl -0x19(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    11de <number+0x9e>
cmpl   $0x0,-0x18(%rbp)
jge    1228 <number+0xe8>
xor    %eax,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%ebx
lea    0xea6(%rip),%r15
lea    0xea1(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%r13d
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <match@plt>
mov    %eax,%ebp
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <match@plt>
neg    %ebx
test   %eax,%eax
cmove  %r13d,%ebx
or     %eax,%ebp
jne    1170 <number+0x30>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <ch@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1040 <numeric@plt>
test   %eax,%eax
je     1209 <number+0xc9>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <ch@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1040 <numeric@plt>
test   %eax,%eax
je     11f8 <number+0xb8>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1060 <inbyte@plt>
lea    0x0(%rbp,%rbp,4),%ecx
movsbl %al,%eax
lea    (%rax,%rcx,2),%ebp
add    $0xffffffd0,%ebp
xor    %eax,%eax
call   1030 <ch@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1040 <numeric@plt>
test   %eax,%eax
jne    11d0 <number+0x90>
mov    %ebp,%eax
neg    %eax
test   %ebx,%ebx
cmovns %ebp,%eax
mov    %eax,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
define i32 @number(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32* %0, i32** %3
store i32 1, i32* %5
store i32 1, i32* %4
br label %7
7: ; preds = %20, %1
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7
store i32 0, i32* %4
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 1, i32* %4
br label %14
14: ; preds = %13, %10
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %5
%19 = sub nsw i32 0, %18
store i32 %19, i32* %5
store i32 1, i32* %4
br label %20
20: ; preds = %17, %14
br label %7
21: ; preds = %7
%22 = call i32 (...) @ch()
%23 = call i32 (i32, ...) bitcast (i32 (...)* @numeric to i32 (i32, ...)*)(i32 %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 0, i32* %2
br label %50
26: ; preds = %21
br label %27
27: ; preds = %31, %26
%28 = call i32 (...) @ch()
%29 = call i32 (i32, ...) bitcast (i32 (...)* @numeric to i32 (i32, ...)*)(i32 %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %27
%32 = call i32 (...) @inbyte()
%33 = trunc i32 %32 to i8
store i8 %33, i8* %6
%34 = load i32, i32* %4
%35 = mul nsw i32 %34, 10
%36 = load i8, i8* %6
%37 = sext i8 %36 to i32
%38 = sub nsw i32 %37, 48
%39 = add nsw i32 %35, %38
store i32 %39, i32* %4
br label %27
40: ; preds = %27
%41 = load i32, i32* %5
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* %4
%45 = sub nsw i32 0, %44
store i32 %45, i32* %4
br label %46
46: ; preds = %43, %40
%47 = load i32, i32* %4
%48 = load i32*, i32** %3
%49 = getelementptr inbounds i32, i32* %48, i64 0
store i32 %47, i32* %49
store i32 1, i32* %2
br label %50
50: ; preds = %46, %25
%51 = load i32, i32* %2
ret i32 %51
}

LLVM IR (-O2):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
define i32 @number(i32* nocapture writeonly %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 1, %1 ], [ %9, %2 ]
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
%8 = sub nsw i32 0, %3
%9 = select i1 %7, i32 %3, i32 %8
%10 = select i1 %7, i1 %5, i1 false
br i1 %10, label %11, label %2
11: ; preds = %2
%12 = tail call i32 (...) @ch()
%13 = tail call i32 (i32, ...) bitcast (i32 (...)* @numeric to i32 (i32, ...)*)(i32 %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %35, label %15
15: ; preds = %11
%16 = tail call i32 (...) @ch()
%17 = tail call i32 (i32, ...) bitcast (i32 (...)* @numeric to i32 (i32, ...)*)(i32 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %30, label %19
19: ; preds = %15, %19
%20 = phi i32 [ %26, %19 ], [ 0, %15 ]
%21 = tail call i32 (...) @inbyte()
%22 = mul nsw i32 %20, 10
%23 = shl i32 %21, 24
%24 = ashr exact i32 %23, 24
%25 = add i32 %22, -48
%26 = add i32 %25, %24
%27 = tail call i32 (...) @ch()
%28 = tail call i32 (i32, ...) bitcast (i32 (...)* @numeric to i32 (i32, ...)*)(i32 %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %19
30: ; preds = %19, %15
%31 = phi i32 [ 0, %15 ], [ %26, %19 ]
%32 = icmp slt i32 %9, 0
%33 = sub nsw i32 0, %31
%34 = select i1 %32, i32 %33, i32 %31
store i32 %34, i32* %0
br label %35
35: ; preds = %11, %30
%36 = phi i32 [ 1, %30 ], [ 0, %11 ]
ret i32 %36
}