#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 /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int next_block(FILE *dbf, char *buf, int buflen, int limiter) {
  int len;
  char *cp, *bp;
  static char lbuf[256];
  if (limiter == 0) {
    rewind(dbf);
    lbuf[0] = '\0';
    return 1;
  }
  for (len = 0;;) {
    bp = buf + len;
    if ((cp = strchr(lbuf, limiter)) != NULL) {
      *cp = '\0';
      strcpy(bp, lbuf);
      cp++;
      for (; *cp == ' ' || *cp == '\t'; cp++)
        ;
      memmove(lbuf, cp, strlen(cp) + 1);
      return 1;
    }
    if (len + strlen(lbuf) >= 2048) {
      fprintf(stderr, "Too long definition: '%s'\n", buf);
      return 0;
    }
    cp = lbuf;
    for (; *cp == ' ' || *cp == '\t'; cp++)
      ;
    strcpy(bp, cp);
    strcat(bp, " ");
    len += strlen(cp) + 1;
    if (fgets(lbuf, 256, dbf) == NULL)
      return 0;
    if ((cp = strchr(lbuf, '#')) != NULL)
      *cp = '\0';
    else
      lbuf[strlen(lbuf) - 1] = '\0';
  }
}


x86 assembly (clang, -O0):
<next_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11bc <next_block+0x3c>
mov    -0x10(%rbp),%rdi
call   1060 <rewind@plt>
movb   $0x0,0x2ec0(%rip)
movl   $0x1,-0x4(%rbp)
jmp    13d8 <next_block+0x258>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%eax
lea    0x2e94(%rip),%rdi
movsbl %al,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1292 <next_block+0x112>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rdi
lea    0x2e6c(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x39(%rbp)
je     123a <next_block+0xba>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    124a <next_block+0xca>
jmp    1260 <next_block+0xe0>
jmp    124f <next_block+0xcf>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1215 <next_block+0x95>
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
lea    0x2def(%rip),%rdi
call   1090 <memmove@plt>
movl   $0x1,-0x4(%rbp)
jmp    13d8 <next_block+0x258>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4c(%rbp)
lea    0x2dd1(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
add    %ecx,%eax
cmp    $0x800,%eax
jl     12db <next_block+0x15b>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd36(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13d8 <next_block+0x258>
lea    0x2d8e(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x4d(%rbp)
je     130b <next_block+0x18b>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x4d(%rbp)
mov    -0x4d(%rbp),%al
test   $0x1,%al
jne    131b <next_block+0x19b>
jmp    1331 <next_block+0x1b1>
jmp    1320 <next_block+0x1a0>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12e6 <next_block+0x166>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
lea    0xcd2(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdx
lea    0x2d05(%rip),%rdi
mov    $0x100,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    138b <next_block+0x20b>
movl   $0x0,-0x4(%rbp)
jmp    13d8 <next_block+0x258>
lea    0x2cde(%rip),%rdi
mov    $0x23,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     13b6 <next_block+0x236>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
jmp    13d3 <next_block+0x253>
lea    0x2cb3(%rip),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2ca1(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
jmp    11c3 <next_block+0x43>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_block>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbp
test   %ecx,%ecx
je     11fd <next_block+0x7d>
mov    %rsi,%r13
movsbl %cl,%ebx
lea    0x2ed1(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1220 <next_block+0xa0>
mov    %rax,%r12
mov    %r13,%rbx
movb   $0x0,(%r12)
lea    0x2eb0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
movzbl (%r12),%eax
cmp    $0x20,%al
je     11d0 <next_block+0x50>
cmp    $0x9,%al
je     11d0 <next_block+0x50>
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edx
lea    0x2e7d(%rip),%rdi
mov    %r12,%rsi
call   1090 <memmove@plt>
jmp    120c <next_block+0x8c>
mov    %rbp,%rdi
call   1060 <rewind@plt>
movb   $0x0,0x2e64(%rip)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebx,0x4(%rsp)
xor    %r15d,%r15d
mov    %r13,%rbx
jmp    1255 <next_block+0xd5>
nopl   0x0(%rax)
add    %ebx,%r15d
add    $0x1,%r15d
movb   $0x0,(%rax)
movslq %r15d,%rbx
add    %r13,%rbx
mov    %r14,%rdi
mov    0x4(%rsp),%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    12f8 <next_block+0x178>
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %r15d,%eax
cmp    $0x7ff,%eax
jg     1300 <next_block+0x180>
mov    %rbp,%r12
mov    %r14,%rbp
jmp    1284 <next_block+0x104>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
movzbl 0x0(%rbp),%eax
cmp    $0x20,%al
je     1280 <next_block+0x100>
cmp    $0x9,%al
je     1280 <next_block+0x100>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
lea    0xd76(%rip),%rsi
call   10a0 <strcat@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    $0x100,%esi
mov    %r12,%rbp
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1318 <next_block+0x198>
mov    %r14,%rdi
mov    $0x23,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1230 <next_block+0xb0>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
add    %r14,%rax
add    $0xffffffffffffffff,%rax
jmp    1230 <next_block+0xb0>
mov    %rax,%r12
jmp    11b4 <next_block+0x34>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
lea    0xcf0(%rip),%rsi
mov    %r13,%rdx
call   1080 <fprintf@plt>
xor    %eax,%eax
jmp    1211 <next_block+0x91>

LLVM IR (-O0):
@next_block.lbuf = internal global [256 x i8] zeroinitializer
@stderr = global i32 0
@.str = [27 x i8] c"Too long definition: '%s'\0A\00"
@.str.1 = [2 x i8] c" \00"
define i32 @next_block(i32* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i32* %0, i32** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%13 = load i32, i32* %9
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %4
%16 = load i32*, i32** %6
%17 = call i32 @rewind(i32* %16)
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0)
store i32 1, i32* %5
br label %108
18: ; preds = %4
store i32 0, i32* %10
br label %19
19: ; preds = %107, %18
%20 = load i8*, i8** %7
%21 = load i32, i32* %10
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8* %23, i8** %12
%24 = load i32, i32* %9
%25 = trunc i32 %24 to i8
%26 = call i8* @strchr(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), i8 signext %25)
store i8* %26, i8** %11
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %56
28: ; preds = %19
%29 = load i8*, i8** %11
store i8 0, i8* %29
%30 = load i8*, i8** %12
%31 = call i32 @strcpy(i8* %30, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0))
%32 = load i8*, i8** %11
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %11
br label %34
34: ; preds = %47, %28
%35 = load i8*, i8** %11
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 32
br i1 %38, label %44, label %39
39: ; preds = %34
%40 = load i8*, i8** %11
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 9
br label %44
44: ; preds = %39, %34
%45 = phi i1 [ true, %34 ], [ %43, %39 ]
br i1 %45, label %46, label %50
46: ; preds = %44
br label %47
47: ; preds = %46
%48 = load i8*, i8** %11
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %11
br label %34
50: ; preds = %44
%51 = load i8*, i8** %11
%52 = load i8*, i8** %11
%53 = call i32 @strlen(i8* %52)
%54 = add nsw i32 %53, 1
%55 = call i32 @memmove(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), i8* %51, i32 %54)
store i32 1, i32* %5
br label %108
56: ; preds = %19
%57 = load i32, i32* %10
%58 = call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0))
%59 = add nsw i32 %57, %58
%60 = icmp sge i32 %59, 2048
br i1 %60, label %61, label %65
61: ; preds = %56
%62 = load i32, i32* @stderr
%63 = load i8*, i8** %7
%64 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %63)
store i32 0, i32* %5
br label %108
65: ; preds = %56
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), i8** %11
br label %66
66: ; preds = %79, %65
%67 = load i8*, i8** %11
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 32
br i1 %70, label %76, label %71
71: ; preds = %66
%72 = load i8*, i8** %11
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 9
br label %76
76: ; preds = %71, %66
%77 = phi i1 [ true, %66 ], [ %75, %71 ]
br i1 %77, label %78, label %82
78: ; preds = %76
br label %79
79: ; preds = %78
%80 = load i8*, i8** %11
%81 = getelementptr inbounds i8, i8* %80, i32 1
store i8* %81, i8** %11
br label %66
82: ; preds = %76
%83 = load i8*, i8** %12
%84 = load i8*, i8** %11
%85 = call i32 @strcpy(i8* %83, i8* %84)
%86 = load i8*, i8** %12
%87 = call i32 @strcat(i8* %86, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%88 = load i8*, i8** %11
%89 = call i32 @strlen(i8* %88)
%90 = add nsw i32 %89, 1
%91 = load i32, i32* %10
%92 = add nsw i32 %91, %90
store i32 %92, i32* %10
%93 = load i32*, i32** %6
%94 = call i32* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), i32 256, i32* %93)
%95 = icmp eq i32* %94, null
br i1 %95, label %96, label %97
96: ; preds = %82
store i32 0, i32* %5
br label %108
97: ; preds = %82
%98 = call i8* @strchr(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), i8 signext 35)
store i8* %98, i8** %11
%99 = icmp ne i8* %98, null
br i1 %99, label %100, label %102
100: ; preds = %97
%101 = load i8*, i8** %11
store i8 0, i8* %101
br label %107
102: ; preds = %97
%103 = call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0))
%104 = sub nsw i32 %103, 1
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 %105
store i8 0, i8* %106
br label %107
107: ; preds = %102, %100
br label %19
108: ; preds = %96, %61, %50, %15
%109 = load i32, i32* %5
ret i32 %109
}

LLVM IR (-O2):
@next_block.lbuf = internal global [256 x i8] zeroinitializer
@stderr = global i32 0
@.str = [27 x i8] c"Too long definition: '%s'\0A\00"
@.str.1 = [2 x i8] c" \00"
define i32 @next_block(i32* nocapture %0, i8* %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %10, label %6
6: ; preds = %4
%7 = trunc i32 %3 to i8
%8 = tail call i8* @strchr(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), i8 signext %7)
%9 = icmp eq i8* %8, null
br i1 %9, label %25, label %12
10: ; preds = %4
%11 = tail call i32 @rewind(i32* %0)
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0)
br label %61
12: ; preds = %55, %6
%13 = phi i8* [ %1, %6 ], [ %58, %55 ]
%14 = phi i8* [ %8, %6 ], [ %59, %55 ]
store i8 0, i8* %14
%15 = tail call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0))
br label %16
16: ; preds = %20, %12
%17 = phi i8* [ %14, %12 ], [ %18, %20 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
switch i8 %19, label %21 [
i8 32, label %20
i8 9, label %20
]
20: ; preds = %16, %16
br label %16
21: ; preds = %16
%22 = tail call i32 @strlen(i8* %18)
%23 = add nsw i32 %22, 1
%24 = tail call i32 @memmove(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), i8* %18, i32 %23)
br label %61
25: ; preds = %6, %55
%26 = phi i8* [ %58, %55 ], [ %1, %6 ]
%27 = phi i32 [ %44, %55 ], [ 0, %6 ]
%28 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0))
%29 = add nsw i32 %28, %27
%30 = icmp sgt i32 %29, 2047
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i32, i32* @stderr
%33 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %61
34: ; preds = %25, %37
%35 = phi i8* [ %38, %37 ], [ getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), %25 ]
%36 = load i8, i8* %35
switch i8 %36, label %39 [
i8 32, label %37
i8 9, label %37
]
37: ; preds = %34, %34
%38 = getelementptr inbounds i8, i8* %35, i64 1
br label %34
39: ; preds = %34
%40 = tail call i32 @strcpy(i8* %26, i8* %35)
%41 = tail call i32 @strcat(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%42 = tail call i32 @strlen(i8* %35)
%43 = add i32 %27, 1
%44 = add i32 %43, %42
%45 = tail call i32* @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), i32 256, i32* %0)
%46 = icmp eq i32* %45, null
br i1 %46, label %61, label %47
47: ; preds = %39
%48 = tail call i8* @strchr(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), i8 signext 35)
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %55
50: ; preds = %47
%51 = tail call i32 @strlen(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0))
%52 = add nsw i32 %51, -1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 %53
br label %55
55: ; preds = %47, %50
%56 = phi i8* [ %54, %50 ], [ %48, %47 ]
store i8 0, i8* %56
%57 = sext i32 %44 to i64
%58 = getelementptr inbounds i8, i8* %1, i64 %57
%59 = tail call i8* @strchr(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @next_block.lbuf, i64 0, i64 0), i8 signext %7)
%60 = icmp eq i8* %59, null
br i1 %60, label %25, label %12
61: ; preds = %39, %31, %21, %10
%62 = phi i32 [ 1, %10 ], [ 1, %21 ], [ 0, %31 ], [ 0, %39 ]
ret i32 %62
}