#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 */
struct buffer {
  int dummy;
};

/* Variables and functions */
int EOF;
int /*<<< orphan*/ ISBLANK(int);
int /*<<< orphan*/ add1_buffer(struct buffer *, char);
int add_then_next(struct buffer *, int);
char *ck_strdup(int /*<<< orphan*/);
int /*<<< orphan*/ free_buffer(struct buffer *);
int /*<<< orphan*/ get_buffer(struct buffer *);
int in_nonblank();
struct buffer *init_buffer();
int /*<<< orphan*/ savchar(int);
char *read_label(void) {
  struct buffer *b;
  int ch;
  char *ret;
  b = init_buffer();
  ch = in_nonblank();
  while (ch != EOF && ch != '\n' && !ISBLANK(ch) && ch != ';' && ch != '}' &&
         ch != '#')
    ch = add_then_next(b, ch);
  savchar(ch);
  add1_buffer(b, '\0');
  ret = ck_strdup(get_buffer(b));
  free_buffer(b);
  return ret;
}


x86 assembly (clang, -O0):
<read_label>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1080 <init_buffer@plt>
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   10b0 <in_nonblank@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
mov    0x2e2f(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x19(%rbp)
je     1213 <read_label+0x83>
xor    %eax,%eax
cmpl   $0xa,-0xc(%rbp)
mov    %al,-0x19(%rbp)
je     1213 <read_label+0x83>
mov    -0xc(%rbp),%edi
call   1070 <ISBLANK@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jne    1213 <read_label+0x83>
xor    %eax,%eax
cmpl   $0x3b,-0xc(%rbp)
mov    %al,-0x19(%rbp)
je     1213 <read_label+0x83>
xor    %eax,%eax
cmpl   $0x7d,-0xc(%rbp)
mov    %al,-0x19(%rbp)
je     1213 <read_label+0x83>
cmpl   $0x23,-0xc(%rbp)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1223 <read_label+0x93>
jmp    1237 <read_label+0xa7>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <add_then_next@plt>
mov    %eax,-0xc(%rbp)
jmp    11ad <read_label+0x1d>
mov    -0xc(%rbp),%edi
call   1060 <savchar@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1090 <add1_buffer@plt>
mov    -0x8(%rbp),%rdi
call   10a0 <get_buffer@plt>
mov    %eax,%edi
call   1040 <ck_strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free_buffer@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_label>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1080 <init_buffer@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   10b0 <in_nonblank@plt>
mov    %eax,%ebp
cmp    $0xa,%eax
je     11f0 <read_label+0x60>
mov    0x2e35(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    (%r14),%ebp
je     11f0 <read_label+0x60>
mov    %ebp,%edi
call   1070 <ISBLANK@plt>
test   %eax,%eax
jne    11f0 <read_label+0x60>
cmp    $0x23,%ebp
je     11f0 <read_label+0x60>
cmp    $0x3b,%ebp
je     11f0 <read_label+0x60>
cmp    $0x7d,%ebp
je     11f0 <read_label+0x60>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <add_then_next@plt>
mov    %eax,%ebp
cmp    $0xa,%eax
jne    11c0 <read_label+0x30>
mov    %ebp,%edi
call   1060 <savchar@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <add1_buffer@plt>
mov    %rbx,%rdi
call   10a0 <get_buffer@plt>
mov    %eax,%edi
call   1040 <ck_strdup@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1030 <free_buffer@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.buffer = type { i32 }
@EOF = global i32 0
define i8* @read_label() {
%1 = alloca %struct.buffer*
%2 = alloca i32
%3 = alloca i8*
%4 = call %struct.buffer* (...) @init_buffer()
store %struct.buffer* %4, %struct.buffer** %1
%5 = call i32 (...) @in_nonblank()
store i32 %5, i32* %2
br label %6
6: ; preds = %28, %0
%7 = load i32, i32* %2
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 10
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = load i32, i32* %2
%15 = call i32 @ISBLANK(i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %13
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 59
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* %2
%22 = icmp ne i32 %21, 125
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %2
%25 = icmp ne i32 %24, 35
br label %26
26: ; preds = %23, %20, %17, %13, %10, %6
%27 = phi i1 [ false, %20 ], [ false, %17 ], [ false, %13 ], [ false, %10 ], [ false, %6 ], [ %25, %23 ]
br i1 %27, label %28, label %32
28: ; preds = %26
%29 = load %struct.buffer*, %struct.buffer** %1
%30 = load i32, i32* %2
%31 = call i32 @add_then_next(%struct.buffer* %29, i32 %30)
store i32 %31, i32* %2
br label %6
32: ; preds = %26
%33 = load i32, i32* %2
%34 = call i32 @savchar(i32 %33)
%35 = load %struct.buffer*, %struct.buffer** %1
%36 = call i32 @add1_buffer(%struct.buffer* %35, i8 signext 0)
%37 = load %struct.buffer*, %struct.buffer** %1
%38 = call i32 @get_buffer(%struct.buffer* %37)
%39 = call i8* @ck_strdup(i32 %38)
store i8* %39, i8** %3
%40 = load %struct.buffer*, %struct.buffer** %1
%41 = call i32 @free_buffer(%struct.buffer* %40)
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
%struct.buffer = type { i32 }
@EOF = global i32 0
define i8* @read_label() {
%1 = tail call %struct.buffer* (...) @init_buffer()
%2 = tail call i32 (...) @in_nonblank()
%3 = load i32, i32* @EOF
%4 = icmp ne i32 %2, %3
%5 = icmp ne i32 %2, 10
%6 = and i1 %5, %4
br i1 %6, label %7, label %19
7: ; preds = %0, %13
%8 = phi i32 [ %14, %13 ], [ %2, %0 ]
%9 = tail call i32 @ISBLANK(i32 %8)
%10 = freeze i32 %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %7
switch i32 %8, label %13 [
i32 125, label %19
i32 59, label %19
i32 35, label %19
]
13: ; preds = %12
%14 = tail call i32 @add_then_next(%struct.buffer* %1, i32 %8)
%15 = load i32, i32* @EOF
%16 = icmp ne i32 %14, %15
%17 = icmp ne i32 %14, 10
%18 = and i1 %17, %16
br i1 %18, label %7, label %19
19: ; preds = %13, %7, %12, %12, %12, %0
%20 = phi i32 [ %2, %0 ], [ %8, %12 ], [ %8, %12 ], [ %8, %12 ], [ %8, %7 ], [ %14, %13 ]
%21 = tail call i32 @savchar(i32 %20)
%22 = tail call i32 @add1_buffer(%struct.buffer* %1, i8 signext 0)
%23 = tail call i32 @get_buffer(%struct.buffer* %1)
%24 = tail call i8* @ck_strdup(i32 %23)
%25 = tail call i32 @free_buffer(%struct.buffer* %1)
ret i8* %24
}