#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 */
unsigned char *_sigs_find(unsigned char const *, unsigned char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned char const *);
int /*<<< orphan*/ stderr;
const unsigned char *sigs_field_begin(const unsigned char *lp,
                                      const unsigned char *field) {
  if (field[1]) {
    if ('#' == field[0] && '#' == field[1]) {
      const unsigned char *tmp = (unsigned char *)lp;
      while (1) {
        if ((tmp = _sigs_find(tmp, (const unsigned char *)"#"))) {
          if (tmp[1] == '#')
            return tmp;
          else
            ++tmp;
        } else
          return NULL;
      }
    } else {
      fprintf(stderr, "sigs_field_begin: internal error: illegal field `%s'\n",
              field);
      return NULL;
    }
  } else {
    lp = _sigs_find(lp, field);
    if (lp && *lp)
      return lp;
    else
      return NULL;
  }
}


x86 assembly (clang, -O0):
<sigs_field_begin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,0x1(%rax)
je     11f4 <sigs_field_begin+0xd4>
mov    -0x18(%rbp),%rax
movzbl (%rax),%ecx
mov    $0x23,%eax
cmp    %ecx,%eax
jne    11ce <sigs_field_begin+0xae>
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%ecx
mov    $0x23,%eax
cmp    %ecx,%eax
jne    11ce <sigs_field_begin+0xae>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1030 <_sigs_find@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11bc <sigs_field_begin+0x9c>
mov    -0x20(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x23,%eax
jne    11ab <sigs_field_begin+0x8b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1235 <sigs_field_begin+0x115>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11c9 <sigs_field_begin+0xa9>
movq   $0x0,-0x8(%rbp)
jmp    1235 <sigs_field_begin+0x115>
jmp    116f <sigs_field_begin+0x4f>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe20(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1235 <sigs_field_begin+0x115>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <_sigs_find@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     122d <sigs_field_begin+0x10d>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     122d <sigs_field_begin+0x10d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1235 <sigs_field_begin+0x115>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigs_field_begin>:
push   %rbx
mov    %rsi,%rdx
mov    0x1(%rsi),%al
test   %al,%al
je     115c <sigs_field_begin+0x3c>
cmpb   $0x23,(%rdx)
jne    1170 <sigs_field_begin+0x50>
cmp    $0x23,%al
jne    1170 <sigs_field_begin+0x50>
lea    0xec5(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rsi
call   1030 <_sigs_find@plt>
test   %rax,%rax
je     1185 <sigs_field_begin+0x65>
mov    %rax,%rdi
add    $0x1,%rdi
cmpb   $0x23,0x1(%rax)
jne    1140 <sigs_field_begin+0x20>
pop    %rbx
ret
mov    %rdx,%rsi
call   1030 <_sigs_find@plt>
test   %rax,%rax
je     1185 <sigs_field_begin+0x65>
cmpb   $0x0,(%rax)
jne    115a <sigs_field_begin+0x3a>
jmp    1185 <sigs_field_begin+0x65>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"#\00"
@stderr = global i32 0
@.str.1 = [54 x i8] c"sigs_field_begin: internal error: illegal field `%s'\0A\00"
define i8* @sigs_field_begin(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %47
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp eq i32 35, %15
br i1 %16, label %17, label %43
17: ; preds = %11
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = icmp eq i32 35, %21
br i1 %22, label %23, label %43
23: ; preds = %17
%24 = load i8*, i8** %4
store i8* %24, i8** %6
br label %25
25: ; preds = %23, %42
%26 = load i8*, i8** %6
%27 = call i8* @_sigs_find(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %27, i8** %6
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %41
29: ; preds = %25
%30 = load i8*, i8** %6
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = icmp eq i32 %33, 35
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = load i8*, i8** %6
store i8* %36, i8** %3
br label %61
37: ; preds = %29
%38 = load i8*, i8** %6
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %6
br label %40
40: ; preds = %37
br label %42
41: ; preds = %25
store i8* null, i8** %3
br label %61
42: ; preds = %40
br label %25
43: ; preds = %17, %11
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %5
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %45)
store i8* null, i8** %3
br label %61
47: ; preds = %2
%48 = load i8*, i8** %4
%49 = load i8*, i8** %5
%50 = call i8* @_sigs_find(i8* %48, i8* %49)
store i8* %50, i8** %4
%51 = load i8*, i8** %4
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %60
53: ; preds = %47
%54 = load i8*, i8** %4
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = load i8*, i8** %4
store i8* %59, i8** %3
br label %61
60: ; preds = %53, %47
store i8* null, i8** %3
br label %61
61: ; preds = %60, %58, %43, %41, %35
%62 = load i8*, i8** %3
ret i8* %62
}

LLVM IR (-O2):
@.str = [2 x i8] c"#\00"
@stderr = global i32 0
@.str.1 = [54 x i8] c"sigs_field_begin: internal error: illegal field `%s'\0A\00"
define i8* @sigs_field_begin(i8* %0, i8* %1) {
%3 = getelementptr inbounds i8, i8* %1, i64 1
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %2
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 35
%9 = icmp eq i8 %4, 35
%10 = select i1 %8, i1 %9, i1 false
br i1 %10, label %11, label %19
11: ; preds = %6, %15
%12 = phi i8* [ %16, %15 ], [ %0, %6 ]
%13 = tail call i8* @_sigs_find(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %29, label %15
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %13, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 35
br i1 %18, label %29, label %11
19: ; preds = %6
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %29
22: ; preds = %2
%23 = tail call i8* @_sigs_find(i8* %0, i8* %1)
%24 = icmp eq i8* %23, null
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i8, i8* %23
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %25, %22
br label %29
29: ; preds = %15, %11, %25, %28, %19
%30 = phi i8* [ null, %19 ], [ null, %28 ], [ %23, %25 ], [ null, %11 ], [ %13, %15 ]
ret i8* %30
}