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

/* Variables and functions */
char *extractStringField(char *, char *, int, unsigned int *, unsigned int);
int /*<<< orphan*/ isdigit(char);
char *extractUnsignedField(char *name, unsigned int *result,
                           unsigned int *attrp, unsigned int bit) {
  char buf[256];
  char *c;
  unsigned int i;
  name = extractStringField(name, buf, sizeof(buf), attrp, bit);
  if (!name)
    return 0;
  if (!(*attrp & bit))
    return name;
  i = 0;
  for (c = buf; *c; c++) {
    if (!isdigit(*c))
      return 0;
    i = i * 10 + (*c - '0');
  }
  *result = i;
  return name;
}


x86 assembly (clang, -O0):
<extractUnsignedField>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    $0x100,%edx
call   1040 <extractStringField@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1173 <extractUnsignedField+0x53>
movq   $0x0,-0x8(%rbp)
jmp    1226 <extractUnsignedField+0x106>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
and    -0x24(%rbp),%eax
cmp    $0x0,%eax
jne    1192 <extractUnsignedField+0x72>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1226 <extractUnsignedField+0x106>
movl   $0x0,-0x13c(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x138(%rbp),%rax
cmpb   $0x0,(%rax)
je     1212 <extractUnsignedField+0xf2>
mov    -0x138(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11df <extractUnsignedField+0xbf>
movq   $0x0,-0x8(%rbp)
jmp    1226 <extractUnsignedField+0x106>
imul   $0xa,-0x13c(%rbp),%eax
mov    -0x138(%rbp),%rcx
movsbl (%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x13c(%rbp)
mov    -0x138(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138(%rbp)
jmp    11aa <extractUnsignedField+0x8a>
mov    -0x13c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extractUnsignedField>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rsp,%rsi
mov    $0x100,%edx
mov    %rbx,%rcx
mov    %ebp,%r8d
call   1040 <extractStringField@plt>
test   %rax,%rax
je     1197 <extractUnsignedField+0x77>
mov    %rax,%r15
test   %ebp,(%rbx)
je     11a1 <extractUnsignedField+0x81>
mov    (%rsp),%al
test   %al,%al
je     119c <extractUnsignedField+0x7c>
lea    0x1(%rsp),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1197 <extractUnsignedField+0x77>
lea    0x0(%rbp,%rbp,4),%eax
movsbl -0x1(%rbx),%ecx
lea    (%rcx,%rax,2),%ebp
add    $0xffffffd0,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1170 <extractUnsignedField+0x50>
jmp    119e <extractUnsignedField+0x7e>
xor    %r15d,%r15d
jmp    11a1 <extractUnsignedField+0x81>
xor    %ebp,%ebp
mov    %ebp,(%r14)
mov    %r15,%rax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @extractUnsignedField(i8* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca [256 x i8]
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32 %3, i32* %9
%13 = load i8*, i8** %6
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%15 = load i32*, i32** %8
%16 = load i32, i32* %9
%17 = call i8* @extractStringField(i8* %13, i8* %14, i32 256, i32* %15, i32 %16)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %4
store i8* null, i8** %5
br label %56
21: ; preds = %4
%22 = load i32*, i32** %8
%23 = load i32, i32* %22
%24 = load i32, i32* %9
%25 = and i32 %23, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %21
%28 = load i8*, i8** %6
store i8* %28, i8** %5
br label %56
29: ; preds = %21
store i32 0, i32* %12
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
store i8* %30, i8** %11
br label %31
31: ; preds = %49, %29
%32 = load i8*, i8** %11
%33 = load i8, i8* %32
%34 = icmp ne i8 %33, 0
br i1 %34, label %35, label %52
35: ; preds = %31
%36 = load i8*, i8** %11
%37 = load i8, i8* %36
%38 = call i32 @isdigit(i8 signext %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %35
store i8* null, i8** %5
br label %56
41: ; preds = %35
%42 = load i32, i32* %12
%43 = mul i32 %42, 10
%44 = load i8*, i8** %11
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = sub nsw i32 %46, 48
%48 = add i32 %43, %47
store i32 %48, i32* %12
br label %49
49: ; preds = %41
%50 = load i8*, i8** %11
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %11
br label %31
52: ; preds = %31
%53 = load i32, i32* %12
%54 = load i32*, i32** %7
store i32 %53, i32* %54
%55 = load i8*, i8** %6
store i8* %55, i8** %5
br label %56
56: ; preds = %52, %40, %27, %20
%57 = load i8*, i8** %5
ret i8* %57
}

LLVM IR (-O2):
define i8* @extractUnsignedField(i8* %0, i32* nocapture writeonly %1, i32* %2, i32 %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = call i8* @extractStringField(i8* %0, i8* %6, i32 256, i32* %2, i32 %3)
%8 = icmp eq i8* %7, null
br i1 %8, label %33, label %9
9: ; preds = %4
%10 = load i32, i32* %2
%11 = and i32 %10, %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %33, label %13
13: ; preds = %9
%14 = load i8, i8* %6
%15 = icmp eq i8 %14, 0
br i1 %15, label %31, label %16
16: ; preds = %13, %22
%17 = phi i8 [ %29, %22 ], [ %14, %13 ]
%18 = phi i32 [ %27, %22 ], [ 0, %13 ]
%19 = phi i8* [ %28, %22 ], [ %6, %13 ]
%20 = call i32 @isdigit(i8 signext %17)
%21 = icmp eq i32 %20, 0
br i1 %21, label %33, label %22
22: ; preds = %16
%23 = mul i32 %18, 10
%24 = load i8, i8* %19
%25 = sext i8 %24 to i32
%26 = add i32 %23, -48
%27 = add i32 %26, %25
%28 = getelementptr inbounds i8, i8* %19, i64 1
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %16
31: ; preds = %22, %13
%32 = phi i32 [ 0, %13 ], [ %27, %22 ]
store i32 %32, i32* %1
br label %33
33: ; preds = %16, %9, %4, %31
%34 = phi i8* [ %7, %31 ], [ null, %4 ], [ %7, %9 ], [ null, %16 ]
ret i8* %34
}