#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 */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ sscanf(char const *, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char const *);
scalar_t__ vrna_alloc(int);
scalar_t__ vrna_realloc(char *, int);
char *vrna_extract_record_rest_structure(const char **lines,
                                         unsigned int length,
                                         unsigned int options) {
  char *structure = NULL;
  int r, i, l, cl, stop;
  char *c;
  if (lines) {
    for (r = i = stop = 0; lines[i]; i++) {
      l = (int)strlen(lines[i]);
      c = (char *)vrna_alloc(sizeof(char) * (l + 1));
      (void)sscanf(lines[i], "%s", c);
      cl = (int)strlen(c);
      if ((*c == '#') || (*c == '%') || (*c == ';') || (*c == '/') ||
          (*c == '*' || (*c == '\0'))) {
        if (!r)
          continue;
        else
          break;
      }
      r += cl + 1;
      structure = (char *)vrna_realloc(structure, r * sizeof(char));
      strcat(structure, c);
      free(c);
      if ((length > 0) && (r - 1 == length))
        break;
      if (!(options & 32U))
        break;
    }
  }
  return structure;
}


x86 assembly (clang, -O0):
<vrna_extract_record_rest_structure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     12f7 <vrna_extract_record_rest_structure+0x197>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     12f2 <vrna_extract_record_rest_structure+0x192>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <vrna_alloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x38(%rbp),%rdx
lea    0xe11(%rip),%rsi
call   1050 <sscanf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     1260 <vrna_extract_record_rest_structure+0x100>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
je     1260 <vrna_extract_record_rest_structure+0x100>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
je     1260 <vrna_extract_record_rest_structure+0x100>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     1260 <vrna_extract_record_rest_structure+0x100>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
je     1260 <vrna_extract_record_rest_structure+0x100>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1274 <vrna_extract_record_rest_structure+0x114>
cmpl   $0x0,-0x1c(%rbp)
jne    126f <vrna_extract_record_rest_structure+0x10f>
jmp    12e4 <vrna_extract_record_rest_structure+0x184>
jmp    12f2 <vrna_extract_record_rest_structure+0x192>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%esi
call   1060 <vrna_realloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0xc(%rbp)
jbe    12cb <vrna_extract_record_rest_structure+0x16b>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cmp    -0xc(%rbp),%eax
jne    12cb <vrna_extract_record_rest_structure+0x16b>
jmp    12f2 <vrna_extract_record_rest_structure+0x192>
mov    -0x10(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
jne    12df <vrna_extract_record_rest_structure+0x17f>
jmp    12f2 <vrna_extract_record_rest_structure+0x192>
jmp    12e4 <vrna_extract_record_rest_structure+0x184>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119a <vrna_extract_record_rest_structure+0x3a>
jmp    12f7 <vrna_extract_record_rest_structure+0x197>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vrna_extract_record_rest_structure>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
test   %rdi,%rdi
je     1251 <vrna_extract_record_rest_structure+0xf1>
mov    %rdi,%rbx
mov    (%rdi),%rdi
xor    %ebp,%ebp
test   %rdi,%rdi
je     1251 <vrna_extract_record_rest_structure+0xf1>
mov    %esi,%r13d
add    $0x8,%rbx
xor    %r12d,%r12d
mov    %esi,(%rsp)
jmp    11bd <vrna_extract_record_rest_structure+0x5d>
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
mov    $0x0,%ebp
jne    1254 <vrna_extract_record_rest_structure+0xf4>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     1254 <vrna_extract_record_rest_structure+0xf4>
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1070 <vrna_alloc@plt>
mov    %rax,%r14
mov    -0x8(%rbx),%rdi
lea    0xe28(%rip),%rsi
mov    %rax,%rdx
call   1050 <sscanf@plt>
movzbl (%r14),%eax
cmp    $0x3b,%rax
ja     11fa <vrna_extract_record_rest_structure+0x9a>
movabs $0x800842800000001,%rcx
bt     %rax,%rcx
jb     11a0 <vrna_extract_record_rest_structure+0x40>
test   %r13d,%r13d
setne  %r15b
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebp,%r13d
add    %eax,%r13d
add    %eax,%ebp
add    $0x1,%ebp
mov    %r12,%rdi
mov    %ebp,%esi
call   1060 <vrna_realloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
mov    %r14,%rdi
call   1030 <free@plt>
cmp    (%rsp),%r13d
mov    (%rsp),%r13d
sete   %al
testb  $0x20,0x4(%rsp)
je     1254 <vrna_extract_record_rest_structure+0xf4>
and    %al,%r15b
je     11ad <vrna_extract_record_rest_structure+0x4d>
jmp    1254 <vrna_extract_record_rest_structure+0xf4>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i8* @vrna_extract_record_rest_structure(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i8* null, i8** %7
%14 = load i8**, i8*** %4
%15 = icmp ne i8** %14, null
br i1 %15, label %16, label %118
16: ; preds = %3
store i32 0, i32* %12
store i32 0, i32* %9
store i32 0, i32* %8
br label %17
17: ; preds = %114, %16
%18 = load i8**, i8*** %4
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %117
24: ; preds = %17
%25 = load i8**, i8*** %4
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i64 @strlen(i8* %29)
%31 = trunc i64 %30 to i32
store i32 %31, i32* %10
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = mul i64 1, %34
%36 = trunc i64 %35 to i32
%37 = call i64 @vrna_alloc(i32 %36)
%38 = inttoptr i64 %37 to i8*
store i8* %38, i8** %13
%39 = load i8**, i8*** %4
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = load i8*, i8** %13
%45 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %44)
%46 = load i8*, i8** %13
%47 = call i64 @strlen(i8* %46)
%48 = trunc i64 %47 to i32
store i32 %48, i32* %11
%49 = load i8*, i8** %13
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 35
br i1 %52, label %78, label %53
53: ; preds = %24
%54 = load i8*, i8** %13
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 37
br i1 %57, label %78, label %58
58: ; preds = %53
%59 = load i8*, i8** %13
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 59
br i1 %62, label %78, label %63
63: ; preds = %58
%64 = load i8*, i8** %13
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 47
br i1 %67, label %78, label %68
68: ; preds = %63
%69 = load i8*, i8** %13
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 42
br i1 %72, label %78, label %73
73: ; preds = %68
%74 = load i8*, i8** %13
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %83
78: ; preds = %73, %68, %63, %58, %53, %24
%79 = load i32, i32* %8
%80 = icmp ne i32 %79, 0
br i1 %80, label %82, label %81
81: ; preds = %78
br label %114
82: ; preds = %78
br label %117
83: ; preds = %73
%84 = load i32, i32* %11
%85 = add nsw i32 %84, 1
%86 = load i32, i32* %8
%87 = add nsw i32 %86, %85
store i32 %87, i32* %8
%88 = load i8*, i8** %7
%89 = load i32, i32* %8
%90 = sext i32 %89 to i64
%91 = mul i64 %90, 1
%92 = trunc i64 %91 to i32
%93 = call i64 @vrna_realloc(i8* %88, i32 %92)
%94 = inttoptr i64 %93 to i8*
store i8* %94, i8** %7
%95 = load i8*, i8** %7
%96 = load i8*, i8** %13
%97 = call i32 @strcat(i8* %95, i8* %96)
%98 = load i8*, i8** %13
%99 = call i32 @free(i8* %98)
%100 = load i32, i32* %5
%101 = icmp ugt i32 %100, 0
br i1 %101, label %102, label %108
102: ; preds = %83
%103 = load i32, i32* %8
%104 = sub nsw i32 %103, 1
%105 = load i32, i32* %5
%106 = icmp eq i32 %104, %105
br i1 %106, label %107, label %108
107: ; preds = %102
br label %117
108: ; preds = %102, %83
%109 = load i32, i32* %6
%110 = and i32 %109, 32
%111 = icmp ne i32 %110, 0
br i1 %111, label %113, label %112
112: ; preds = %108
br label %117
113: ; preds = %108
br label %114
114: ; preds = %113, %81
%115 = load i32, i32* %9
%116 = add nsw i32 %115, 1
store i32 %116, i32* %9
br label %17
117: ; preds = %112, %107, %82, %17
br label %118
118: ; preds = %117, %3
%119 = load i8*, i8** %7
ret i8* %119
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i8* @vrna_extract_record_rest_structure(i8** %0, i32 %1, i32 %2) {
%4 = icmp eq i8** %0, null
br i1 %4, label %49, label %5
5: ; preds = %3
%6 = load i8*, i8** %0
%7 = icmp eq i8* %6, null
br i1 %7, label %49, label %8
8: ; preds = %5
%9 = icmp ne i32 %1, 0
%10 = and i32 %2, 32
%11 = icmp eq i32 %10, 0
br label %12
12: ; preds = %8, %40
%13 = phi i64 [ 0, %8 ], [ %43, %40 ]
%14 = phi i8* [ %6, %8 ], [ %45, %40 ]
%15 = phi i8** [ %0, %8 ], [ %44, %40 ]
%16 = phi i8* [ null, %8 ], [ %42, %40 ]
%17 = phi i32 [ 0, %8 ], [ %41, %40 ]
%18 = tail call i64 @strlen(i8* %14)
%19 = trunc i64 %18 to i32
%20 = add nsw i32 %19, 1
%21 = tail call i64 @vrna_alloc(i32 %20)
%22 = inttoptr i64 %21 to i8*
%23 = load i8*, i8** %15
%24 = tail call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %22)
%25 = load i8, i8* %22
switch i8 %25, label %28 [
i8 35, label %26
i8 37, label %26
i8 59, label %26
i8 47, label %26
i8 42, label %26
i8 0, label %26
]
26: ; preds = %12, %12, %12, %12, %12, %12
%27 = icmp eq i32 %17, 0
br i1 %27, label %40, label %49
28: ; preds = %12
%29 = tail call i64 @strlen(i8* dereferenceable(1) %22)
%30 = trunc i64 %29 to i32
%31 = add i32 %17, %30
%32 = add i32 %31, 1
%33 = tail call i64 @vrna_realloc(i8* %16, i32 %32)
%34 = inttoptr i64 %33 to i8*
%35 = tail call i32 @strcat(i8* %34, i8* %22)
%36 = tail call i32 @free(i8* %22)
%37 = icmp eq i32 %31, %1
%38 = select i1 %9, i1 %37, i1 false
%39 = or i1 %11, %38
br i1 %39, label %47, label %40
40: ; preds = %28, %26
%41 = phi i32 [ 0, %26 ], [ %32, %28 ]
%42 = phi i8* [ %16, %26 ], [ %34, %28 ]
%43 = add nuw i64 %13, 1
%44 = getelementptr inbounds i8*, i8** %0, i64 %43
%45 = load i8*, i8** %44
%46 = icmp eq i8* %45, null
br i1 %46, label %49, label %12
47: ; preds = %28
%48 = inttoptr i64 %33 to i8*
br label %49
49: ; preds = %40, %26, %47, %5, %3
%50 = phi i8* [ null, %3 ], [ null, %5 ], [ %48, %47 ], [ %42, %40 ], [ %16, %26 ]
ret i8* %50
}