#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 EOF;
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
char *realloc(char *, int);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
char *readquotedlabel(FILE *fp) {
  char *answer;
  char *temp;
  int capacity = 32;
  int len = 0;
  int ch;
  answer = malloc(capacity);
  if (!answer)
    return 0;
  ch = fgetc(fp);
  while ((ch = fgetc(fp)) != EOF) {
    if (ch == '\'') {
      ch = fgetc(fp);
      if (ch == '\'')
        answer[len++] = (char)ch;
      else {
        ungetc(ch, fp);
        answer[len] = 0;
        return answer;
      }
    } else
      answer[len++] = (char)ch;
    if (len == capacity - 1) {
      temp = realloc(answer, capacity * 2);
      if (!temp) {
        free(answer);
        return 0;
      }
      answer = temp;
      capacity = capacity * 2;
    }
  }
  answer[len] = 0;
  return answer;
}


x86 assembly (clang, -O0):
<readquotedlabel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x20,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118e <readquotedlabel+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    12a7 <readquotedlabel+0x157>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2e3b(%rip),%rcx
cmp    (%rcx),%eax
je     1293 <readquotedlabel+0x143>
cmpl   $0x27,-0x2c(%rbp)
jne    121e <readquotedlabel+0xce>
mov    -0x10(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x27,-0x2c(%rbp)
jne    11f4 <readquotedlabel+0xa4>
mov    -0x2c(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1219 <readquotedlabel+0xc9>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <ungetc@plt>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12a7 <readquotedlabel+0x157>
jmp    1238 <readquotedlabel+0xe8>
mov    -0x2c(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    128e <readquotedlabel+0x13e>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
shl    $0x1,%esi
call   1070 <realloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    127d <readquotedlabel+0x12d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    12a7 <readquotedlabel+0x157>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119a <readquotedlabel+0x4a>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readquotedlabel>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x20,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1209 <readquotedlabel+0xb9>
mov    %rax,%r15
mov    %r14,%rdi
call   1040 <fgetc@plt>
mov    %r14,%rdi
call   1040 <fgetc@plt>
mov    0x2e5d(%rip),%rbp
cmp    0x0(%rbp),%eax
jne    1197 <readquotedlabel+0x47>
xor    %eax,%eax
jmp    1225 <readquotedlabel+0xd5>
mov    $0x20,%r12d
xor    %r13d,%r13d
jmp    11c3 <readquotedlabel+0x73>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rbx
mov    %r14,%rdi
call   1040 <fgetc@plt>
mov    %rbx,%r15
cmp    0x0(%rbp),%eax
je     120e <readquotedlabel+0xbe>
cmp    $0x27,%eax
jne    11d9 <readquotedlabel+0x89>
mov    %r14,%rdi
call   1040 <fgetc@plt>
mov    %eax,%edi
mov    $0x27,%al
cmp    $0x27,%edi
jne    121a <readquotedlabel+0xca>
mov    %al,(%r15,%r13,1)
add    $0x1,%r13
lea    -0x1(%r12),%eax
cmp    %rax,%r13
jne    11b0 <readquotedlabel+0x60>
add    %r12d,%r12d
mov    %r15,%rdi
mov    %r12d,%esi
call   1070 <realloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11b3 <readquotedlabel+0x63>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %r15d,%r15d
jmp    122a <readquotedlabel+0xda>
mov    %r13d,%eax
mov    %rbx,%r15
movb   $0x0,(%rbx,%rax,1)
jmp    122a <readquotedlabel+0xda>
mov    %r14,%rsi
call   1060 <ungetc@plt>
mov    %r13d,%eax
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i8* @readquotedlabel(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32 32, i32* %6
store i32 0, i32* %7
%9 = load i32, i32* %6
%10 = call i8* @malloc(i32 %9)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %1
store i8* null, i8** %2
br label %82
14: ; preds = %1
%15 = load i32*, i32** %3
%16 = call i32 @fgetc(i32* %15)
store i32 %16, i32* %8
br label %17
17: ; preds = %75, %14
%18 = load i32*, i32** %3
%19 = call i32 @fgetc(i32* %18)
store i32 %19, i32* %8
%20 = load i32, i32* @EOF
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %76
22: ; preds = %17
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, 39
br i1 %24, label %25, label %48
25: ; preds = %22
%26 = load i32*, i32** %3
%27 = call i32 @fgetc(i32* %26)
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = icmp eq i32 %28, 39
br i1 %29, label %30, label %38
30: ; preds = %25
%31 = load i32, i32* %8
%32 = trunc i32 %31 to i8
%33 = load i8*, i8** %4
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
store i8 %32, i8* %37
br label %47
38: ; preds = %25
%39 = load i32, i32* %8
%40 = load i32*, i32** %3
%41 = call i32 @ungetc(i32 %39, i32* %40)
%42 = load i8*, i8** %4
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 0, i8* %45
%46 = load i8*, i8** %4
store i8* %46, i8** %2
br label %82
47: ; preds = %30
br label %56
48: ; preds = %22
%49 = load i32, i32* %8
%50 = trunc i32 %49 to i8
%51 = load i8*, i8** %4
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
%54 = sext i32 %52 to i64
%55 = getelementptr inbounds i8, i8* %51, i64 %54
store i8 %50, i8* %55
br label %56
56: ; preds = %48, %47
%57 = load i32, i32* %7
%58 = load i32, i32* %6
%59 = sub nsw i32 %58, 1
%60 = icmp eq i32 %57, %59
br i1 %60, label %61, label %75
61: ; preds = %56
%62 = load i8*, i8** %4
%63 = load i32, i32* %6
%64 = mul nsw i32 %63, 2
%65 = call i8* @realloc(i8* %62, i32 %64)
store i8* %65, i8** %5
%66 = load i8*, i8** %5
%67 = icmp ne i8* %66, null
br i1 %67, label %71, label %68
68: ; preds = %61
%69 = load i8*, i8** %4
%70 = call i32 @free(i8* %69)
store i8* null, i8** %2
br label %82
71: ; preds = %61
%72 = load i8*, i8** %5
store i8* %72, i8** %4
%73 = load i32, i32* %6
%74 = mul nsw i32 %73, 2
store i32 %74, i32* %6
br label %75
75: ; preds = %71, %56
br label %17
76: ; preds = %17
%77 = load i8*, i8** %4
%78 = load i32, i32* %7
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %77, i64 %79
store i8 0, i8* %80
%81 = load i8*, i8** %4
store i8* %81, i8** %2
br label %82
82: ; preds = %76, %68, %38, %13
%83 = load i8*, i8** %2
ret i8* %83
}

LLVM IR (-O2):
@EOF = global i32 0
define i8* @readquotedlabel(i32* nocapture %0) {
%2 = tail call dereferenceable_or_null(32) i8* @malloc(i32 32)
%3 = icmp eq i8* %2, null
br i1 %3, label %49, label %4
4: ; preds = %1
%5 = tail call i32 @fgetc(i32* %0)
%6 = tail call i32 @fgetc(i32* %0)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %45, label %9
9: ; preds = %4, %37
%10 = phi i64 [ %27, %37 ], [ 0, %4 ]
%11 = phi i32 [ %40, %37 ], [ %6, %4 ]
%12 = phi i32 [ %39, %37 ], [ 32, %4 ]
%13 = phi i8* [ %38, %37 ], [ %2, %4 ]
%14 = icmp eq i32 %11, 39
br i1 %14, label %15, label %22
15: ; preds = %9
%16 = tail call i32 @fgetc(i32* %0)
%17 = icmp eq i32 %16, 39
br i1 %17, label %24, label %18
18: ; preds = %15
%19 = tail call i32 @ungetc(i32 %16, i32* %0)
%20 = and i64 %10, 4294967295
%21 = getelementptr inbounds i8, i8* %13, i64 %20
store i8 0, i8* %21
br label %49
22: ; preds = %9
%23 = trunc i32 %11 to i8
br label %24
24: ; preds = %15, %22
%25 = phi i8 [ %23, %22 ], [ 39, %15 ]
%26 = getelementptr inbounds i8, i8* %13, i64 %10
store i8 %25, i8* %26
%27 = add nuw i64 %10, 1
%28 = add nsw i32 %12, -1
%29 = zext i32 %28 to i64
%30 = icmp eq i64 %27, %29
br i1 %30, label %31, label %37
31: ; preds = %24
%32 = shl nsw i32 %12, 1
%33 = tail call i8* @realloc(i8* %13, i32 %32)
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = tail call i32 @free(i8* %13)
br label %49
37: ; preds = %31, %24
%38 = phi i8* [ %13, %24 ], [ %33, %31 ]
%39 = phi i32 [ %12, %24 ], [ %32, %31 ]
%40 = tail call i32 @fgetc(i32* %0)
%41 = load i32, i32* @EOF
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %9
43: ; preds = %37
%44 = and i64 %27, 4294967295
br label %45
45: ; preds = %43, %4
%46 = phi i8* [ %2, %4 ], [ %38, %43 ]
%47 = phi i64 [ 0, %4 ], [ %44, %43 ]
%48 = getelementptr inbounds i8, i8* %46, i64 %47
store i8 0, i8* %48
br label %49
49: ; preds = %1, %45, %35, %18
%50 = phi i8* [ null, %35 ], [ %13, %18 ], [ %46, %45 ], [ null, %1 ]
ret i8* %50
}