#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int read_dec(FILE *config_fp, int *value) {
  int c = getc(config_fp);
  while (((c) >= '0' && (c) <= '9')) {
    *value = (*value * 10) + (c - '0');
    c = getc(config_fp);
  }
  ungetc(c, config_fp);
  return 1;
}


x86 assembly (clang, -O0):
<read_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x30,-0x14(%rbp)
mov    %al,-0x15(%rbp)
jl     1155 <read_dec+0x35>
cmpl   $0x39,-0x14(%rbp)
setle  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1165 <read_dec+0x45>
jmp    118b <read_dec+0x6b>
mov    -0x10(%rbp),%rax
imul   $0xa,(%rax),%ecx
mov    -0x14(%rbp),%eax
sub    $0x30,%eax
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x14(%rbp)
jmp    113c <read_dec+0x1c>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <ungetc@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_dec>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <getc@plt>
mov    %eax,%ecx
add    $0xffffffd0,%ecx
cmp    $0x9,%ecx
ja     115a <read_dec+0x3a>
nopl   0x0(%rax)
mov    (%rbx),%eax
lea    (%rax,%rax,4),%eax
lea    (%rcx,%rax,2),%eax
mov    %eax,(%rbx)
mov    %r14,%rdi
call   1040 <getc@plt>
lea    -0x30(%rax),%ecx
cmp    $0xa,%ecx
jb     1140 <read_dec+0x20>
mov    %eax,%edi
mov    %r14,%rsi
call   1030 <ungetc@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @read_dec(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %3
%7 = call i32 @getc(i32* %6)
store i32 %7, i32* %5
br label %8
8: ; preds = %16, %2
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 48
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* %5
%13 = icmp sle i32 %12, 57
br label %14
14: ; preds = %11, %8
%15 = phi i1 [ false, %8 ], [ %13, %11 ]
br i1 %15, label %16, label %26
16: ; preds = %14
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = mul nsw i32 %18, 10
%20 = load i32, i32* %5
%21 = sub nsw i32 %20, 48
%22 = add nsw i32 %19, %21
%23 = load i32*, i32** %4
store i32 %22, i32* %23
%24 = load i32*, i32** %3
%25 = call i32 @getc(i32* %24)
store i32 %25, i32* %5
br label %8
26: ; preds = %14
%27 = load i32, i32* %5
%28 = load i32*, i32** %3
%29 = call i32 @ungetc(i32 %27, i32* %28)
ret i32 1
}

LLVM IR (-O2):
define i32 @read_dec(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @getc(i32* %0)
%4 = add i32 %3, -48
%5 = icmp ult i32 %4, 10
br i1 %5, label %6, label %14
6: ; preds = %2, %6
%7 = phi i32 [ %12, %6 ], [ %4, %2 ]
%8 = load i32, i32* %1
%9 = mul nsw i32 %8, 10
%10 = add nsw i32 %9, %7
store i32 %10, i32* %1
%11 = tail call i32 @getc(i32* %0)
%12 = add i32 %11, -48
%13 = icmp ult i32 %12, 10
br i1 %13, label %6, label %14
14: ; preds = %6, %2
%15 = phi i32 [ %3, %2 ], [ %11, %6 ]
%16 = tail call i32 @ungetc(i32 %15, i32* %0)
ret i32 1
}