#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*/ assert(int);
char *fgets(char *, int, int /*<<< orphan*/);
scalar_t__ isspace(char);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
scalar_t__ strncmp(char *, char *, int);
char *nextline(void) {
  static char buf[8192];
  char *p, *semicolon, *eol;
read:
  p = fgets(buf, sizeof buf, stdin);
  if (p == NULL)
    return NULL;
  while (isspace(*p))
    p++;
  if (*p == '\0' || strncmp(p, "XXX", 3) == 0)
    goto read;
  assert(strchr(p, '\n') != NULL);
  assert(strncmp(p, "ASSERT", 6) == 0 || strncmp(p, "QUERY", 5) == 0 ||
         strchr(p, ':') != NULL);
  semicolon = strchr(p, ';');
  assert(semicolon != NULL);
  for (eol = semicolon + 1; isspace(*eol); eol++)
    ;
  assert(eol[0] == '\0');
  semicolon[1] = '\0';
  return p;
}


x86 assembly (clang, -O0):
<nextline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
lea    0x2ef8(%rip),%rdi
mov    $0x2000,%esi
call   1060 <fgets@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118e <nextline+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    1303 <nextline+0x1b3>
jmp    1193 <nextline+0x43>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11ba <nextline+0x6a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1193 <nextline+0x43>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e9 <nextline+0x99>
mov    -0x10(%rbp),%rdi
lea    0xe2b(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11ee <nextline+0x9e>
jmp    1158 <nextline+0x8>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    0xdec(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
je     1273 <nextline+0x123>
mov    -0x10(%rbp),%rdi
lea    0xdcc(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
je     1273 <nextline+0x123>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     12dc <nextline+0x18c>
jmp    12cb <nextline+0x17b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    12b0 <nextline+0x160>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextline>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e8a(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x2ef8(%rip),%rdi
mov    $0x2000,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1297 <nextline+0x147>
lea    0x2ede(%rip),%r14
lea    0xe77(%rip),%r15
jmp    11a9 <nextline+0x59>
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%edx
mov    %r14,%rdi
mov    $0x2000,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1297 <nextline+0x147>
mov    %rax,%rbx
movsbl (%rax),%edi
call   1050 <isspace@plt>
mov    %rax,%rcx
lea    0x1(%rbx),%rax
test   %rcx,%rcx
jne    11a9 <nextline+0x59>
cmpb   $0x0,(%rbx)
je     1190 <nextline+0x40>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1190 <nextline+0x40>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <strchr@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1070 <assert@plt>
lea    0xe08(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1242 <nextline+0xf2>
lea    0xdf1(%rip),%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1242 <nextline+0xf2>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%edi
call   1070 <assert@plt>
mov    %rbx,%rdi
mov    $0x3b,%esi
call   1040 <strchr@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1070 <assert@plt>
add    $0x1,%r14
mov    %r14,%rbp
xchg   %ax,%ax
movsbl 0x0(%rbp),%edi
call   1050 <isspace@plt>
add    $0x1,%rbp
test   %rax,%rax
jne    1270 <nextline+0x120>
xor    %edi,%edi
cmpb   $0x0,-0x1(%rbp)
sete   %dil
call   1070 <assert@plt>
movb   $0x0,(%r14)
jmp    1299 <nextline+0x149>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@nextline.buf = internal global [8192 x i8] zeroinitializer
@stdin = global i32 0
@.str = [4 x i8] c"XXX\00"
@.str.1 = [7 x i8] c"ASSERT\00"
@.str.2 = [6 x i8] c"QUERY\00"
define i8* @nextline() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
br label %5
5: ; preds = %29, %0
%6 = load i32, i32* @stdin
%7 = call i8* @fgets(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @nextline.buf, i64 0, i64 0), i32 8192, i32 %6)
store i8* %7, i8** %2
%8 = load i8*, i8** %2
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %5
store i8* null, i8** %1
br label %79
11: ; preds = %5
br label %12
12: ; preds = %17, %11
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = call i64 @isspace(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %2
br label %12
20: ; preds = %12
%21 = load i8*, i8** %2
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %20
%26 = load i8*, i8** %2
%27 = call i64 @strncmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25, %20
br label %5
30: ; preds = %25
%31 = load i8*, i8** %2
%32 = call i8* @strchr(i8* %31, i8 signext 10)
%33 = icmp ne i8* %32, null
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i8*, i8** %2
%37 = call i64 @strncmp(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%38 = icmp eq i64 %37, 0
br i1 %38, label %47, label %39
39: ; preds = %30
%40 = load i8*, i8** %2
%41 = call i64 @strncmp(i8* %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%42 = icmp eq i64 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = load i8*, i8** %2
%45 = call i8* @strchr(i8* %44, i8 signext 58)
%46 = icmp ne i8* %45, null
br label %47
47: ; preds = %43, %39, %30
%48 = phi i1 [ true, %39 ], [ true, %30 ], [ %46, %43 ]
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = load i8*, i8** %2
%52 = call i8* @strchr(i8* %51, i8 signext 59)
store i8* %52, i8** %3
%53 = load i8*, i8** %3
%54 = icmp ne i8* %53, null
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = load i8*, i8** %3
%58 = getelementptr inbounds i8, i8* %57, i64 1
store i8* %58, i8** %4
br label %59
59: ; preds = %65, %47
%60 = load i8*, i8** %4
%61 = load i8, i8* %60
%62 = call i64 @isspace(i8 signext %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %59
br label %65
65: ; preds = %64
%66 = load i8*, i8** %4
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %4
br label %59
68: ; preds = %59
%69 = load i8*, i8** %4
%70 = getelementptr inbounds i8, i8* %69, i64 0
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 0
%74 = zext i1 %73 to i32
%75 = call i32 @assert(i32 %74)
%76 = load i8*, i8** %3
%77 = getelementptr inbounds i8, i8* %76, i64 1
store i8 0, i8* %77
%78 = load i8*, i8** %2
store i8* %78, i8** %1
br label %79
79: ; preds = %68, %10
%80 = load i8*, i8** %1
ret i8* %80
}

LLVM IR (-O2):
@nextline.buf = internal global [8192 x i8] zeroinitializer
@stdin = global i32 0
@.str = [4 x i8] c"XXX\00"
@.str.1 = [7 x i8] c"ASSERT\00"
@.str.2 = [6 x i8] c"QUERY\00"
define i8* @nextline() {
%1 = load i32, i32* @stdin
%2 = tail call i8* @fgets(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @nextline.buf, i64 0, i64 0), i32 8192, i32 %1)
%3 = icmp eq i8* %2, null
br i1 %3, label %55, label %4
4: ; preds = %0, %10
%5 = phi i8* [ %11, %10 ], [ %2, %0 ]
%6 = load i8, i8* %5
%7 = tail call i64 @isspace(i8 signext %6)
%8 = icmp eq i64 %7, 0
%9 = getelementptr inbounds i8, i8* %5, i64 1
br i1 %8, label %12, label %10
10: ; preds = %4, %18
%11 = phi i8* [ %9, %4 ], [ %20, %18 ]
br label %4
12: ; preds = %4
%13 = load i8, i8* %5
%14 = icmp eq i8 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15, %12
%19 = load i32, i32* @stdin
%20 = tail call i8* @fgets(i8* getelementptr inbounds ([8192 x i8], [8192 x i8]* @nextline.buf, i64 0, i64 0), i32 8192, i32 %19)
%21 = icmp eq i8* %20, null
br i1 %21, label %55, label %10
22: ; preds = %15
%23 = tail call i8* @strchr(i8* %5, i8 signext 10)
%24 = icmp ne i8* %23, null
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = tail call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%28 = icmp eq i64 %27, 0
br i1 %28, label %36, label %29
29: ; preds = %22
%30 = tail call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%31 = icmp eq i64 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %29
%33 = tail call i8* @strchr(i8* %5, i8 signext 58)
%34 = icmp ne i8* %33, null
%35 = zext i1 %34 to i32
br label %36
36: ; preds = %32, %29, %22
%37 = phi i32 [ 1, %29 ], [ 1, %22 ], [ %35, %32 ]
%38 = tail call i32 @assert(i32 %37)
%39 = tail call i8* @strchr(i8* %5, i8 signext 59)
%40 = icmp ne i8* %39, null
%41 = zext i1 %40 to i32
%42 = tail call i32 @assert(i32 %41)
%43 = getelementptr inbounds i8, i8* %39, i64 1
br label %44
44: ; preds = %44, %36
%45 = phi i8* [ %43, %36 ], [ %49, %44 ]
%46 = load i8, i8* %45
%47 = tail call i64 @isspace(i8 signext %46)
%48 = icmp eq i64 %47, 0
%49 = getelementptr inbounds i8, i8* %45, i64 1
br i1 %48, label %50, label %44
50: ; preds = %44
%51 = load i8, i8* %45
%52 = icmp eq i8 %51, 0
%53 = zext i1 %52 to i32
%54 = tail call i32 @assert(i32 %53)
store i8 0, i8* %43
br label %55
55: ; preds = %18, %0, %50
%56 = phi i8* [ %5, %50 ], [ null, %0 ], [ null, %18 ]
ret i8* %56
}