#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*/ trimmed_line;
typedef scalar_t__ ssize_t;

/* Variables and functions */
scalar_t__ getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ process_query(char *);
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
int /*<<< orphan*/ trimstr(char *, char *, int);
int main(int argc, char **argv) {
  char *input_line;
  size_t input_len;
  char trimmed_line[1024];
  while (1) {
    printf("%s ", "?");
    ssize_t input_size = getline(&input_line, &input_len, stdin);
    if (input_size <= 0) {
      break;
    }
    trimstr(input_line, trimmed_line, sizeof(trimmed_line));
    if (strlen(trimmed_line) == 0) {
      break;
    }
    process_query(trimmed_line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1040 <printf@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <getline@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
jg     11ac <main+0x5c>
jmp    11ed <main+0x9d>
mov    -0x18(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1060 <trimstr@plt>
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    11dc <main+0x8c>
jmp    11ed <main+0x9d>
lea    -0x420(%rbp),%rdi
call   1050 <process_query@plt>
jmp    1169 <main+0x19>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
lea    0xea8(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1030 <printf@plt>
mov    0x2e7d(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1060 <getline@plt>
test   %rax,%rax
jle    11de <main+0x9e>
lea    0x10(%rsp),%rbx
lea    0xe74(%rip),%r14
lea    0xe71(%rip),%r15
mov    %rsp,%r12
lea    0x8(%rsp),%r13
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1050 <trimstr@plt>
cmpb   $0x0,0x10(%rsp)
je     11de <main+0x9e>
mov    %rbx,%rdi
call   1040 <process_query@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    0x0(%rbp),%edx
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <getline@plt>
test   %rax,%rax
jg     11a0 <main+0x60>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s \00"
@.str.1 = [2 x i8] c"?\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [1024 x i8]
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %10
10: ; preds = %2, %25
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @stdin
%13 = call i64 @getline(i8** %6, i64* %7, i32 %12)
store i64 %13, i64* %9
%14 = load i64, i64* %9
%15 = icmp sle i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
br label %28
17: ; preds = %10
%18 = load i8*, i8** %6
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%20 = call i32 @trimstr(i8* %18, i8* %19, i32 1024)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%22 = call i64 @strlen(i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %17
br label %28
25: ; preds = %17
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%27 = call i32 @process_query(i8* %26)
br label %10
28: ; preds = %24, %16
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s \00"
@.str.1 = [2 x i8] c"?\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [1024 x i8]
%6 = bitcast i8** %3 to i8*
%7 = bitcast i64* %4 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i64 @getline(i8** %3, i64* %4, i32 %10)
%12 = icmp slt i64 %11, 1
br i1 %12, label %24, label %13
13: ; preds = %2, %18
%14 = load i8*, i8** %3
%15 = call i32 @trimstr(i8* %14, i8* %8, i32 1024)
%16 = load i8, i8* %8
%17 = icmp eq i8 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %13
%19 = call i32 @process_query(i8* %8)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @stdin
%22 = call i64 @getline(i8** %3, i64* %4, i32 %21)
%23 = icmp slt i64 %22, 1
br i1 %23, label %24, label %13
24: ; preds = %13, %18, %2
ret i32 0
}