#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 EOF;
int /*<<< orphan*/ lexAppendc(int);
int /*<<< orphan*/ lexClearToken();
int lexLookahead();
int /*<<< orphan*/ lexSkipLookahead();
char *lexStr();
int /*<<< orphan*/ strchr(char *, int);
char *lexGetStrUntil(char *termset) {
  int c = lexLookahead();
  lexClearToken();
  while (c != EOF && !strchr(termset, c)) {
    lexAppendc(c);
    lexSkipLookahead();
    c = lexLookahead();
  }
  lexAppendc(0);
  return c == EOF ? 0 : lexStr();
}


x86 assembly (clang, -O0):
<lexGetStrUntil>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1080 <lexLookahead@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1050 <lexClearToken@plt>
mov    -0xc(%rbp),%ecx
xor    %eax,%eax
mov    0x2e5f(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0xd(%rbp)
je     11ab <lexGetStrUntil+0x4b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <strchr@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11bb <lexGetStrUntil+0x5b>
jmp    11d9 <lexGetStrUntil+0x79>
mov    -0xc(%rbp),%edi
call   1070 <lexAppendc@plt>
mov    $0x0,%al
call   1060 <lexSkipLookahead@plt>
mov    $0x0,%al
call   1080 <lexLookahead@plt>
mov    %eax,-0xc(%rbp)
jmp    117d <lexGetStrUntil+0x1d>
xor    %edi,%edi
call   1070 <lexAppendc@plt>
mov    -0xc(%rbp),%eax
mov    0x2dfe(%rip),%rcx
cmp    (%rcx),%eax
jne    11fd <lexGetStrUntil+0x9d>
xor    %eax,%eax
mov    %rax,-0x18(%rbp)
jmp    1208 <lexGetStrUntil+0xa8>
mov    $0x0,%al
call   1030 <lexStr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lexGetStrUntil>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1080 <lexLookahead@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1050 <lexClearToken@plt>
mov    0x2e6a(%rip),%r14
cmp    (%r14),%ebp
je     11ba <lexGetStrUntil+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <strchr@plt>
test   %eax,%eax
jne    11ba <lexGetStrUntil+0x5a>
mov    %ebp,%edi
call   1070 <lexAppendc@plt>
xor    %eax,%eax
call   1060 <lexSkipLookahead@plt>
xor    %eax,%eax
call   1080 <lexLookahead@plt>
mov    %eax,%ebp
cmp    (%r14),%eax
jne    1190 <lexGetStrUntil+0x30>
xor    %edi,%edi
call   1070 <lexAppendc@plt>
cmp    (%r14),%ebp
jne    11cd <lexGetStrUntil+0x6d>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <lexStr@plt>

LLVM IR (-O0):
@EOF = global i32 0
define i8* @lexGetStrUntil(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 (...) @lexLookahead()
store i32 %4, i32* %3
%5 = call i32 (...) @lexClearToken()
br label %6
6: ; preds = %18, %1
%7 = load i32, i32* %3
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = load i32, i32* %3
%13 = call i32 @strchr(i8* %11, i32 %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br label %16
16: ; preds = %10, %6
%17 = phi i1 [ false, %6 ], [ %15, %10 ]
br i1 %17, label %18, label %23
18: ; preds = %16
%19 = load i32, i32* %3
%20 = call i32 @lexAppendc(i32 %19)
%21 = call i32 (...) @lexSkipLookahead()
%22 = call i32 (...) @lexLookahead()
store i32 %22, i32* %3
br label %6
23: ; preds = %16
%24 = call i32 @lexAppendc(i32 0)
%25 = load i32, i32* %3
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %23
br label %31
29: ; preds = %23
%30 = call i8* (...) @lexStr()
br label %31
31: ; preds = %29, %28
%32 = phi i8* [ null, %28 ], [ %30, %29 ]
ret i8* %32
}

LLVM IR (-O2):
@EOF = global i32 0
define i8* @lexGetStrUntil(i8* %0) {
%2 = tail call i32 (...) @lexLookahead()
%3 = tail call i32 (...) @lexClearToken()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %2, %4
br i1 %5, label %16, label %6
6: ; preds = %1, %10
%7 = phi i32 [ %13, %10 ], [ %2, %1 ]
%8 = tail call i32 @strchr(i8* %0, i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = tail call i32 @lexAppendc(i32 %7)
%12 = tail call i32 (...) @lexSkipLookahead()
%13 = tail call i32 (...) @lexLookahead()
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %6
16: ; preds = %6, %10, %1
%17 = phi i32 [ %2, %1 ], [ %13, %10 ], [ %7, %6 ]
%18 = tail call i32 @lexAppendc(i32 0)
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %17, %19
br i1 %20, label %23, label %21
21: ; preds = %16
%22 = tail call i8* (...) @lexStr()
br label %23
23: ; preds = %16, %21
%24 = phi i8* [ %22, %21 ], [ null, %16 ]
ret i8* %24
}