#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*/ printf(char *, char *);
int /*<<< orphan*/ scan_init();
int /*<<< orphan*/ scan_sparql(char *, char **);
int main() {
  char *q[] = {"PREFIX a: <X>",
               "PREFIX : <>",
               "PREFIX q: <qdos>",
               "PREFIX q: <http://qdos.com/schema/>",
               "PREFIX q: <http://qdos.com/§/> Prefix foaf: "
               "<http://xmlns.com/foaf/0.1/> WHERE { a:foo a foaf:name . :a: "
               "a:b a:c . }",
               "{ dbpedia:a rdf:type dbpedia:c . <> a foaf:Document }",
               "{ madeup:foo fdsgsagdsa:fdsf owl:Class }",
               NULL};
  scan_init();
  for (int i = 0; 1; i++) {
    if (!q[i])
      break;
    printf("%s\n", q[i]);
    char *suggest;
    scan_sparql(q[i], &suggest);
    printf("suggest:\n%s", suggest);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0x2c86(%rip),%rsi
mov    $0x40,%edx
call   1060 <memcpy@plt>
mov    $0x0,%al
call   1030 <scan_init@plt>
movl   $0x0,-0x54(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1181 <main+0x41>
jmp    11db <main+0x9b>
movslq -0x54(%rbp),%rax
cmpq   $0x0,-0x50(%rbp,%rax,8)
jne    1196 <main+0x56>
jmp    11db <main+0x9b>
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
lea    0xf7e(%rip),%rdi
call   1040 <printf@plt>
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
lea    -0x60(%rbp),%rsi
call   1050 <scan_sparql@plt>
mov    -0x60(%rbp),%rsi
lea    0xf60(%rip),%rdi
call   1040 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1172 <main+0x32>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <scan_init@plt>
lea    0xfde(%rip),%r14
lea    0xeb3(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rsp,%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scan_sparql@plt>
mov    (%rsp),%rsi
lea    0xfb7(%rip),%r12
mov    %r12,%rdi
call   1040 <printf@plt>
lea    0xe8e(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scan_sparql@plt>
mov    (%rsp),%rsi
mov    %r12,%rdi
call   1040 <printf@plt>
lea    0xe71(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scan_sparql@plt>
mov    (%rsp),%rsi
mov    %r12,%rdi
call   1040 <printf@plt>
lea    0xe59(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scan_sparql@plt>
mov    (%rsp),%rsi
mov    %r12,%rdi
call   1040 <printf@plt>
lea    0xe54(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scan_sparql@plt>
mov    (%rsp),%rsi
mov    %r12,%rdi
call   1040 <printf@plt>
lea    0xea1(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scan_sparql@plt>
mov    (%rsp),%rsi
mov    %r12,%rdi
call   1040 <printf@plt>
lea    0xeae(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scan_sparql@plt>
mov    (%rsp),%rsi
mov    %r12,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"PREFIX a: <X>\00"
@.str.1 = [12 x i8] c"PREFIX : <>\00"
@.str.2 = [17 x i8] c"PREFIX q: <qdos>\00"
@.str.3 = [36 x i8] c"PREFIX q: <http://qdos.com/schema/>\00"
@.str.4 = [118 x i8] c"PREFIX q: <http://qdos.com/\C2\A7/> Prefix foaf: <http://xmlns.com/foaf/0.1/> WHERE { a:foo a foaf:name . :a: a:b a:c . }\00"
@.str.5 = [54 x i8] c"{ dbpedia:a rdf:type dbpedia:c . <> a foaf:Document }\00"
@.str.6 = [41 x i8] c"{ madeup:foo fdsgsagdsa:fdsf owl:Class }\00"
@__const.main.q = [8 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([118 x i8], [118 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i32 0, i32 0), i8* null]
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.8 = [12 x i8] c"suggest:\0A%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8*]
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [8 x i8*]* %2 to i8*
%6 = call i32 (...) @scan_init()
store i32 0, i32* %3
br label %7
7: ; preds = %28, %0
br i1 true, label %8, label %31
8: ; preds = %7
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %10
%12 = load i8*, i8** %11
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %8
br label %31
15: ; preds = %8
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %19)
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [8 x i8*], [8 x i8*]* %2, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @scan_sparql(i8* %24, i8** %4)
%26 = load i8*, i8** %4
%27 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %15
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %7
31: ; preds = %14, %7
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"PREFIX a: <X>\00"
@.str.1 = [12 x i8] c"PREFIX : <>\00"
@.str.2 = [17 x i8] c"PREFIX q: <qdos>\00"
@.str.3 = [36 x i8] c"PREFIX q: <http://qdos.com/schema/>\00"
@.str.4 = [118 x i8] c"PREFIX q: <http://qdos.com/\C2\A7/> Prefix foaf: <http://xmlns.com/foaf/0.1/> WHERE { a:foo a foaf:name . :a: a:b a:c . }\00"
@.str.5 = [54 x i8] c"{ dbpedia:a rdf:type dbpedia:c . <> a foaf:Document }\00"
@.str.6 = [41 x i8] c"{ madeup:foo fdsgsagdsa:fdsf owl:Class }\00"
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.8 = [12 x i8] c"suggest:\0A%s\00"
define i32 @main() {
%1 = alloca i8*
%2 = tail call i32 (...) @scan_init()
%3 = bitcast i8** %1 to i8*
%4 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scan_sparql(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %1)
%6 = load i8*, i8** %1
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scan_sparql(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %1)
%10 = load i8*, i8** %1
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scan_sparql(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %1)
%14 = load i8*, i8** %1
%15 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @scan_sparql(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8** %1)
%18 = load i8*, i8** %1
%19 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([118 x i8], [118 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @scan_sparql(i8* getelementptr inbounds ([118 x i8], [118 x i8]* @.str.4, i64 0, i64 0), i8** %1)
%22 = load i8*, i8** %1
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 @scan_sparql(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i8** %1)
%26 = load i8*, i8** %1
%27 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%29 = call i32 @scan_sparql(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i8** %1)
%30 = load i8*, i8** %1
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %30)
ret i32 0
}