mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
918 lines
38 KiB
C
918 lines
38 KiB
C
// #target: macos-x64
|
|
module test;
|
|
import std;
|
|
import libc;
|
|
|
|
struct Doc { Head *head; }
|
|
struct Head { char[]* title; }
|
|
|
|
struct Summary
|
|
{
|
|
char[]* title;
|
|
bool ok;
|
|
}
|
|
|
|
fn void Summary.print(Summary *s, CFile out)
|
|
{
|
|
// We don't have a native printf in C3 yet, so use libc,
|
|
// which is not all that nice for the strings but...
|
|
char[] title = s.title ? *s.title : "missing";
|
|
libc::fprintf(out, "Summary({ .title = %.*s, .ok = %s})", (int)title.len, title.ptr, s.ok ? (char*)"true" : (char*)"false");
|
|
}
|
|
|
|
fn bool contains(char[] haystack, char[] needle)
|
|
{
|
|
usz len = haystack.len;
|
|
usz needle_len = needle.len;
|
|
if (len < needle_len) return false;
|
|
if (!needle_len) return true;
|
|
len -= needle_len - 1;
|
|
for (usz i = 0; i < len; i++)
|
|
{
|
|
if (libc::memcmp(&haystack[i], needle.ptr, needle_len) == 0)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
macro dupe(value)
|
|
{
|
|
$typeof(&value) temp = malloc($sizeof(value));
|
|
if (!temp) return ReadError.OUT_OF_MEMORY!;
|
|
*temp = value;
|
|
return temp;
|
|
}
|
|
|
|
fault ReadError
|
|
{
|
|
BAD_READ,
|
|
OUT_OF_MEMORY
|
|
}
|
|
|
|
fn Doc! readDoc(char[] url)
|
|
{
|
|
if (contains(url, "fail")) return ReadError.BAD_READ!;
|
|
if (contains(url, "head-missing")) return { .head = null };
|
|
if (contains(url, "title-missing")) return { dupe(Head { .title = null })? };
|
|
if (contains(url, "title-empty")) return { dupe(Head { .title = dupe((char[])"")? })? };
|
|
// Not particularly elegant due to missing string functions.
|
|
int len = libc::snprintf(null, 0, "Title of %.*s", (int)url.len, url.ptr);
|
|
char* str = malloc(len + 1);
|
|
if (!str) return ReadError.OUT_OF_MEMORY!;
|
|
libc::snprintf(str, len + 1, "Title of %.*s", (int)url.len, url.ptr);
|
|
return { dupe(Head { .title = dupe(str[..len - 1])? })? };
|
|
}
|
|
|
|
fn Summary buildSummary(Doc doc)
|
|
{
|
|
return Summary {
|
|
.title = doc.head ? doc.head.title : null,
|
|
.ok = true,
|
|
};
|
|
}
|
|
|
|
fn Summary readAndBuildSummary(char[] url)
|
|
{
|
|
return buildSummary(readDoc(url)) ?? Summary { .title = null, .ok = false };
|
|
/*
|
|
// or
|
|
Summary summary = buildSummary(readDoc(url));
|
|
if (catch summary) return Summary { .title = null, .ok = false };
|
|
return summary;
|
|
// or
|
|
Summary summary = buildSummary(readDoc(url));
|
|
if (try summary) return summary;
|
|
return Summary { .title = null, .ok = false };
|
|
*/
|
|
}
|
|
|
|
|
|
fault TitleResult
|
|
{
|
|
TITLE_MISSING
|
|
}
|
|
|
|
fn bool! isTitleNonEmpty(Doc doc)
|
|
{
|
|
if (!doc.head) return TitleResult.TITLE_MISSING!;
|
|
char[]* head = doc.head.title;
|
|
if (!head) return TitleResult.TITLE_MISSING!;
|
|
return (*head).len > 0;
|
|
}
|
|
|
|
|
|
fn bool! readWhetherTitleNonEmpty(char[] url)
|
|
{
|
|
return isTitleNonEmpty(readDoc(url));
|
|
}
|
|
|
|
fn char* bool_to_string(bool b)
|
|
{
|
|
return b ? "true" : "false";
|
|
}
|
|
fn char* nameFromError(anyerr e)
|
|
{
|
|
switch (e)
|
|
{
|
|
case TitleResult.TITLE_MISSING:
|
|
return "no title";
|
|
case ReadError.BAD_READ:
|
|
return "bad read";
|
|
case ReadError.OUT_OF_MEMORY:
|
|
return "out of memory";
|
|
default:
|
|
return "unknown error";
|
|
}
|
|
}
|
|
|
|
|
|
fn void main()
|
|
{
|
|
const char[][] URLS = { "good", "title-empty", "title-missing", "head-missing", "fail" };
|
|
foreach (char[] url : URLS)
|
|
{
|
|
// Yes, it's pretty onerous to print strings for the moment in C3
|
|
libc::printf(`Checking "https://%.*s/":` "\n", (int)url.len, url.ptr);
|
|
Summary summary = readAndBuildSummary(url);
|
|
libc::printf(" Summary: ");
|
|
summary.print(libc::stdout());
|
|
libc::printf("\n");
|
|
char[] title_sure = summary.title ? *summary.title : "";
|
|
libc::printf(" Title: %.*s\n", (int)title_sure.len, title_sure.ptr);
|
|
bool! has_title = readWhetherTitleNonEmpty(url);
|
|
// This looks a bit less than elegant, but as you see it's mostly due to having to
|
|
// use printf here.
|
|
libc::printf(" Has title: %s vs %s\n", bool_to_string(has_title) ?? nameFromError(catch(has_title)), (has_title ?? false) ? (char*)"true" : (char*)"false");
|
|
}
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
define void @test_Summary_print(%Summary* %0, i8* %1) #0 {
|
|
entry:
|
|
%title = alloca %"char[]", align 8
|
|
%2 = getelementptr inbounds %Summary, %Summary* %0, i32 0, i32 0
|
|
%3 = load %"char[]"*, %"char[]"** %2, align 8
|
|
%ptrbool = icmp ne %"char[]"* %3, null
|
|
br i1 %ptrbool, label %cond.lhs, label %cond.rhs
|
|
|
|
cond.lhs: ; preds = %entry
|
|
%4 = getelementptr inbounds %Summary, %Summary* %0, i32 0, i32 0
|
|
%5 = load %"char[]"*, %"char[]"** %4, align 8
|
|
%6 = load %"char[]", %"char[]"* %5, align 8
|
|
br label %cond.phi
|
|
|
|
cond.rhs: ; preds = %entry
|
|
br label %cond.phi
|
|
|
|
cond.phi: ; preds = %cond.rhs, %cond.lhs
|
|
%val = phi %"char[]" [ %6, %cond.lhs ], [ { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.28, i32 0, i32 0), i64 7 }, %cond.rhs ]
|
|
store %"char[]" %val, %"char[]"* %title, align 8
|
|
%7 = getelementptr inbounds %"char[]", %"char[]"* %title, i32 0, i32 1
|
|
%8 = load i64, i64* %7, align 8
|
|
%uisitrunc = trunc i64 %8 to i32
|
|
%9 = getelementptr inbounds %"char[]", %"char[]"* %title, i32 0, i32 0
|
|
%10 = load i8*, i8** %9, align 8
|
|
%11 = getelementptr inbounds %Summary, %Summary* %0, i32 0, i32 1
|
|
%12 = load i8, i8* %11, align 8
|
|
%13 = trunc i8 %12 to i1
|
|
%ternary = select i1 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.31, i32 0, i32 0)
|
|
%14 = call i32 (i8*, i8*, ...) @fprintf(i8* %1, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.29, i32 0, i32 0), i32 %uisitrunc, i8* %10, i8* %ternary)
|
|
ret void
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define zeroext i8 @test_contains(i8* %0, i64 %1, i8* %2, i64 %3) #0 {
|
|
entry:
|
|
%haystack = alloca %"char[]", align 8
|
|
%needle = alloca %"char[]", align 8
|
|
%len = alloca i64, align 8
|
|
%needle_len = alloca i64, align 8
|
|
%i = alloca i64, align 8
|
|
%pair = bitcast %"char[]"* %haystack to { i8*, i64 }*
|
|
%4 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0
|
|
store i8* %0, i8** %4, align 8
|
|
%5 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1
|
|
store i64 %1, i64* %5, align 8
|
|
%pair1 = bitcast %"char[]"* %needle to { i8*, i64 }*
|
|
%6 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair1, i32 0, i32 0
|
|
store i8* %2, i8** %6, align 8
|
|
%7 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair1, i32 0, i32 1
|
|
store i64 %3, i64* %7, align 8
|
|
%8 = getelementptr inbounds %"char[]", %"char[]"* %haystack, i32 0, i32 1
|
|
%9 = load i64, i64* %8, align 8
|
|
store i64 %9, i64* %len, align 8
|
|
%10 = getelementptr inbounds %"char[]", %"char[]"* %needle, i32 0, i32 1
|
|
%11 = load i64, i64* %10, align 8
|
|
store i64 %11, i64* %needle_len, align 8
|
|
%12 = load i64, i64* %len, align 8
|
|
%13 = load i64, i64* %needle_len, align 8
|
|
%lt = icmp ult i64 %12, %13
|
|
br i1 %lt, label %if.then, label %if.exit
|
|
|
|
if.then: ; preds = %entry
|
|
ret i8 0
|
|
|
|
if.exit: ; preds = %entry
|
|
%14 = load i64, i64* %needle_len, align 8
|
|
%not = icmp eq i64 %14, 0
|
|
br i1 %not, label %if.then2, label %if.exit3
|
|
|
|
if.then2: ; preds = %if.exit
|
|
ret i8 1
|
|
|
|
if.exit3: ; preds = %if.exit
|
|
%15 = load i64, i64* %len, align 8
|
|
%16 = load i64, i64* %needle_len, align 8
|
|
%sub = sub i64 %16, 1
|
|
%sub4 = sub i64 %15, %sub
|
|
store i64 %sub4, i64* %len, align 8
|
|
store i64 0, i64* %i, align 8
|
|
br label %loop.cond
|
|
|
|
loop.cond: ; preds = %if.exit7, %if.exit3
|
|
%17 = load i64, i64* %i, align 8
|
|
%18 = load i64, i64* %len, align 8
|
|
%lt5 = icmp ult i64 %17, %18
|
|
br i1 %lt5, label %loop.body, label %loop.exit
|
|
|
|
loop.body: ; preds = %loop.cond
|
|
%19 = getelementptr inbounds %"char[]", %"char[]"* %haystack, i32 0, i32 0
|
|
%20 = load i8*, i8** %19, align 8
|
|
%21 = load i64, i64* %i, align 8
|
|
%ptroffset = getelementptr inbounds i8, i8* %20, i64 %21
|
|
%22 = getelementptr inbounds %"char[]", %"char[]"* %needle, i32 0, i32 0
|
|
%23 = load i8*, i8** %22, align 8
|
|
%24 = load i64, i64* %needle_len, align 8
|
|
%25 = call i32 @memcmp(i8* %ptroffset, i8* %23, i64 %24)
|
|
%eq = icmp eq i32 %25, 0
|
|
br i1 %eq, label %if.then6, label %if.exit7
|
|
|
|
if.then6: ; preds = %loop.body
|
|
ret i8 1
|
|
|
|
if.exit7: ; preds = %loop.body
|
|
%26 = load i64, i64* %i, align 8
|
|
%add = add i64 %26, 1
|
|
store i64 %add, i64* %i, align 8
|
|
br label %loop.cond
|
|
|
|
loop.exit: ; preds = %loop.cond
|
|
ret i8 0
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i64 @test_readDoc(%Doc* %0, i8* %1, i64 %2) #0 {
|
|
entry:
|
|
%url = alloca %"char[]", align 8
|
|
%reterr = alloca i64, align 8
|
|
%literal = alloca %Doc, align 8
|
|
%reterr8 = alloca i64, align 8
|
|
%literal9 = alloca %Doc, align 8
|
|
%error_var = alloca i64, align 8
|
|
%value = alloca %Head, align 8
|
|
%literal10 = alloca %Head, align 8
|
|
%temp = alloca %Head*, align 8
|
|
%reterr17 = alloca i64, align 8
|
|
%literal18 = alloca %Doc, align 8
|
|
%error_var19 = alloca i64, align 8
|
|
%value20 = alloca %Head, align 8
|
|
%literal21 = alloca %Head, align 8
|
|
%error_var22 = alloca i64, align 8
|
|
%value23 = alloca %"char[]", align 8
|
|
%temp24 = alloca %"char[]"*, align 8
|
|
%temp31 = alloca %Head*, align 8
|
|
%len = alloca i32, align 4
|
|
%str = alloca i8*, align 8
|
|
%reterr45 = alloca i64, align 8
|
|
%literal46 = alloca %Doc, align 8
|
|
%error_var47 = alloca i64, align 8
|
|
%value48 = alloca %Head, align 8
|
|
%literal49 = alloca %Head, align 8
|
|
%error_var50 = alloca i64, align 8
|
|
%value51 = alloca %"char[]", align 8
|
|
%temp52 = alloca %"char[]"*, align 8
|
|
%temp59 = alloca %Head*, align 8
|
|
%pair = bitcast %"char[]"* %url to { i8*, i64 }*
|
|
%3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0
|
|
store i8* %1, i8** %3, align 8
|
|
%4 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1
|
|
store i64 %2, i64* %4, align 8
|
|
%5 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%lo = load i8*, i8** %5, align 8
|
|
%6 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%hi = load i64, i64* %6, align 8
|
|
%7 = call i8 @test_contains(i8* %lo, i64 %hi, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i64 4)
|
|
%8 = trunc i8 %7 to i1
|
|
br i1 %8, label %if.then, label %if.exit
|
|
|
|
if.then: ; preds = %entry
|
|
ret i64 ptrtoint (%.fault* @"test_ReadError$BAD_READ" to i64)
|
|
|
|
if.exit: ; preds = %entry
|
|
%9 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%lo1 = load i8*, i8** %9, align 8
|
|
%10 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%hi2 = load i64, i64* %10, align 8
|
|
%11 = call i8 @test_contains(i8* %lo1, i64 %hi2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i32 0, i32 0), i64 12)
|
|
%12 = trunc i8 %11 to i1
|
|
br i1 %12, label %if.then3, label %if.exit4
|
|
|
|
if.then3: ; preds = %if.exit
|
|
%13 = getelementptr inbounds %Doc, %Doc* %literal, i32 0, i32 0
|
|
store %Head* null, %Head** %13, align 8
|
|
%14 = bitcast %Doc* %0 to i8*
|
|
%15 = bitcast %Doc* %literal to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %14, i8* align 8 %15, i32 8, i1 false)
|
|
ret i64 0
|
|
|
|
if.exit4: ; preds = %if.exit
|
|
%16 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%lo5 = load i8*, i8** %16, align 8
|
|
%17 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%hi6 = load i64, i64* %17, align 8
|
|
%18 = call i8 @test_contains(i8* %lo5, i64 %hi6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0), i64 13)
|
|
%19 = trunc i8 %18 to i1
|
|
br i1 %19, label %if.then7, label %if.exit13
|
|
|
|
if.then7: ; preds = %if.exit4
|
|
%20 = getelementptr inbounds %Doc, %Doc* %literal9, i32 0, i32 0
|
|
%21 = getelementptr inbounds %Head, %Head* %literal10, i32 0, i32 0
|
|
store %"char[]"* null, %"char[]"** %21, align 8
|
|
%22 = bitcast %Head* %value to i8*
|
|
%23 = bitcast %Head* %literal10 to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %22, i8* align 8 %23, i32 8, i1 false)
|
|
%24 = call i8* @std_core_mem_malloc(i64 8) #2
|
|
%ptrptr = bitcast i8* %24 to %Head*
|
|
store %Head* %ptrptr, %Head** %temp, align 8
|
|
%25 = load %Head*, %Head** %temp, align 8
|
|
%not = icmp eq %Head* %25, null
|
|
br i1 %not, label %if.then11, label %if.exit12
|
|
|
|
if.then11: ; preds = %if.then7
|
|
store i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), i64* %error_var, align 8
|
|
br label %guard_block
|
|
|
|
if.exit12: ; preds = %if.then7
|
|
%26 = load %Head*, %Head** %temp, align 8
|
|
%27 = bitcast %Head* %26 to i8*
|
|
%28 = bitcast %Head* %value to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %27, i8* align 8 %28, i32 8, i1 false)
|
|
br label %noerr_block
|
|
|
|
guard_block: ; preds = %if.then11
|
|
%29 = load i64, i64* %error_var, align 8
|
|
ret i64 %29
|
|
|
|
noerr_block: ; preds = %if.exit12
|
|
%30 = load %Head*, %Head** %temp, align 8
|
|
store %Head* %30, %Head** %20, align 8
|
|
%31 = bitcast %Doc* %0 to i8*
|
|
%32 = bitcast %Doc* %literal9 to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %31, i8* align 8 %32, i32 8, i1 false)
|
|
ret i64 0
|
|
|
|
if.exit13: ; preds = %if.exit4
|
|
%33 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%lo14 = load i8*, i8** %33, align 8
|
|
%34 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%hi15 = load i64, i64* %34, align 8
|
|
%35 = call i8 @test_contains(i8* %lo14, i64 %hi15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i32 0, i32 0), i64 11)
|
|
%36 = trunc i8 %35 to i1
|
|
br i1 %36, label %if.then16, label %if.exit38
|
|
|
|
if.then16: ; preds = %if.exit13
|
|
%37 = getelementptr inbounds %Doc, %Doc* %literal18, i32 0, i32 0
|
|
%38 = bitcast %Head* %literal21 to %"char[]"**
|
|
store %"char[]"* null, %"char[]"** %38, align 8
|
|
%39 = getelementptr inbounds %Head, %Head* %literal21, i32 0, i32 0
|
|
store %"char[]" zeroinitializer, %"char[]"* %value23, align 8
|
|
%40 = call i8* @std_core_mem_malloc(i64 16) #2
|
|
%ptrptr25 = bitcast i8* %40 to %"char[]"*
|
|
store %"char[]"* %ptrptr25, %"char[]"** %temp24, align 8
|
|
%41 = load %"char[]"*, %"char[]"** %temp24, align 8
|
|
%not26 = icmp eq %"char[]"* %41, null
|
|
br i1 %not26, label %if.then27, label %if.exit28
|
|
|
|
if.then27: ; preds = %if.then16
|
|
store i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), i64* %error_var22, align 8
|
|
br label %guard_block29
|
|
|
|
if.exit28: ; preds = %if.then16
|
|
%42 = load %"char[]"*, %"char[]"** %temp24, align 8
|
|
%43 = bitcast %"char[]"* %42 to i8*
|
|
%44 = bitcast %"char[]"* %value23 to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %43, i8* align 8 %44, i32 16, i1 false)
|
|
br label %noerr_block30
|
|
|
|
guard_block29: ; preds = %if.then27
|
|
%45 = load i64, i64* %error_var22, align 8
|
|
ret i64 %45
|
|
|
|
noerr_block30: ; preds = %if.exit28
|
|
%46 = load %"char[]"*, %"char[]"** %temp24, align 8
|
|
store %"char[]"* %46, %"char[]"** %39, align 8
|
|
%47 = bitcast %Head* %value20 to i8*
|
|
%48 = bitcast %Head* %literal21 to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %47, i8* align 8 %48, i32 8, i1 false)
|
|
%49 = call i8* @std_core_mem_malloc(i64 8) #2
|
|
%ptrptr32 = bitcast i8* %49 to %Head*
|
|
store %Head* %ptrptr32, %Head** %temp31, align 8
|
|
%50 = load %Head*, %Head** %temp31, align 8
|
|
%not33 = icmp eq %Head* %50, null
|
|
br i1 %not33, label %if.then34, label %if.exit35
|
|
|
|
if.then34: ; preds = %noerr_block30
|
|
store i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), i64* %error_var19, align 8
|
|
br label %guard_block36
|
|
|
|
if.exit35: ; preds = %noerr_block30
|
|
%51 = load %Head*, %Head** %temp31, align 8
|
|
%52 = bitcast %Head* %51 to i8*
|
|
%53 = bitcast %Head* %value20 to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %52, i8* align 8 %53, i32 8, i1 false)
|
|
br label %noerr_block37
|
|
|
|
guard_block36: ; preds = %if.then34
|
|
%54 = load i64, i64* %error_var19, align 8
|
|
ret i64 %54
|
|
|
|
noerr_block37: ; preds = %if.exit35
|
|
%55 = load %Head*, %Head** %temp31, align 8
|
|
store %Head* %55, %Head** %37, align 8
|
|
%56 = bitcast %Doc* %0 to i8*
|
|
%57 = bitcast %Doc* %literal18 to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %56, i8* align 8 %57, i32 8, i1 false)
|
|
ret i64 0
|
|
|
|
if.exit38: ; preds = %if.exit13
|
|
%58 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%59 = load i64, i64* %58, align 8
|
|
%uisitrunc = trunc i64 %59 to i32
|
|
%60 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%61 = load i8*, i8** %60, align 8
|
|
%62 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* null, i64 0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i32 0, i32 0), i32 %uisitrunc, i8* %61)
|
|
store i32 %62, i32* %len, align 4
|
|
%63 = load i32, i32* %len, align 4
|
|
%siuiext = sext i32 %63 to i64
|
|
%add = add i64 %siuiext, 1
|
|
%64 = call i8* @std_core_mem_malloc(i64 %add) #2
|
|
store i8* %64, i8** %str, align 8
|
|
%65 = load i8*, i8** %str, align 8
|
|
%not39 = icmp eq i8* %65, null
|
|
br i1 %not39, label %if.then40, label %if.exit41
|
|
|
|
if.then40: ; preds = %if.exit38
|
|
ret i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64)
|
|
|
|
if.exit41: ; preds = %if.exit38
|
|
%66 = load i8*, i8** %str, align 8
|
|
%67 = load i32, i32* %len, align 4
|
|
%siuiext42 = sext i32 %67 to i64
|
|
%add43 = add i64 %siuiext42, 1
|
|
%68 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%69 = load i64, i64* %68, align 8
|
|
%uisitrunc44 = trunc i64 %69 to i32
|
|
%70 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%71 = load i8*, i8** %70, align 8
|
|
%72 = call i32 (i8*, i64, i8*, ...) @snprintf(i8* %66, i64 %add43, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i32 0, i32 0), i32 %uisitrunc44, i8* %71)
|
|
%73 = getelementptr inbounds %Doc, %Doc* %literal46, i32 0, i32 0
|
|
%74 = bitcast %Head* %literal49 to %"char[]"**
|
|
store %"char[]"* null, %"char[]"** %74, align 8
|
|
%75 = getelementptr inbounds %Head, %Head* %literal49, i32 0, i32 0
|
|
%76 = load i8*, i8** %str, align 8
|
|
%77 = load i32, i32* %len, align 4
|
|
%sub = sub i32 %77, 1
|
|
%sisiext = sext i32 %sub to i64
|
|
%78 = add i64 %sisiext, 1
|
|
%size = sub i64 %78, 0
|
|
%ptroffset = getelementptr inbounds i8, i8* %76, i64 0
|
|
%79 = insertvalue %"char[]" undef, i8* %ptroffset, 0
|
|
%80 = insertvalue %"char[]" %79, i64 %size, 1
|
|
store %"char[]" %80, %"char[]"* %value51, align 8
|
|
%81 = call i8* @std_core_mem_malloc(i64 16) #2
|
|
%ptrptr53 = bitcast i8* %81 to %"char[]"*
|
|
store %"char[]"* %ptrptr53, %"char[]"** %temp52, align 8
|
|
%82 = load %"char[]"*, %"char[]"** %temp52, align 8
|
|
%not54 = icmp eq %"char[]"* %82, null
|
|
br i1 %not54, label %if.then55, label %if.exit56
|
|
|
|
if.then55: ; preds = %if.exit41
|
|
store i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), i64* %error_var50, align 8
|
|
br label %guard_block57
|
|
|
|
if.exit56: ; preds = %if.exit41
|
|
%83 = load %"char[]"*, %"char[]"** %temp52, align 8
|
|
%84 = bitcast %"char[]"* %83 to i8*
|
|
%85 = bitcast %"char[]"* %value51 to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %84, i8* align 8 %85, i32 16, i1 false)
|
|
br label %noerr_block58
|
|
|
|
guard_block57: ; preds = %if.then55
|
|
%86 = load i64, i64* %error_var50, align 8
|
|
ret i64 %86
|
|
|
|
noerr_block58: ; preds = %if.exit56
|
|
%87 = load %"char[]"*, %"char[]"** %temp52, align 8
|
|
store %"char[]"* %87, %"char[]"** %75, align 8
|
|
%88 = bitcast %Head* %value48 to i8*
|
|
%89 = bitcast %Head* %literal49 to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %88, i8* align 8 %89, i32 8, i1 false)
|
|
%90 = call i8* @std_core_mem_malloc(i64 8) #2
|
|
%ptrptr60 = bitcast i8* %90 to %Head*
|
|
store %Head* %ptrptr60, %Head** %temp59, align 8
|
|
%91 = load %Head*, %Head** %temp59, align 8
|
|
%not61 = icmp eq %Head* %91, null
|
|
br i1 %not61, label %if.then62, label %if.exit63
|
|
|
|
if.then62: ; preds = %noerr_block58
|
|
store i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), i64* %error_var47, align 8
|
|
br label %guard_block64
|
|
|
|
if.exit63: ; preds = %noerr_block58
|
|
%92 = load %Head*, %Head** %temp59, align 8
|
|
%93 = bitcast %Head* %92 to i8*
|
|
%94 = bitcast %Head* %value48 to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %93, i8* align 8 %94, i32 8, i1 false)
|
|
br label %noerr_block65
|
|
|
|
guard_block64: ; preds = %if.then62
|
|
%95 = load i64, i64* %error_var47, align 8
|
|
ret i64 %95
|
|
|
|
noerr_block65: ; preds = %if.exit63
|
|
%96 = load %Head*, %Head** %temp59, align 8
|
|
store %Head* %96, %Head** %73, align 8
|
|
%97 = bitcast %Doc* %0 to i8*
|
|
%98 = bitcast %Doc* %literal46 to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %97, i8* align 8 %98, i32 8, i1 false)
|
|
ret i64 0
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define { %"char[]"*, i8 } @test_buildSummary(%Head* %0) #0 {
|
|
entry:
|
|
%doc = alloca %Doc, align 8
|
|
%literal = alloca %Summary, align 8
|
|
%1 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0
|
|
store %Head* %0, %Head** %1, align 8
|
|
%2 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 0
|
|
store %"char[]"* null, %"char[]"** %2, align 8
|
|
%3 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 1
|
|
store i8 0, i8* %3, align 8
|
|
%4 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 0
|
|
%5 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0
|
|
%6 = load %Head*, %Head** %5, align 8
|
|
%ptrbool = icmp ne %Head* %6, null
|
|
br i1 %ptrbool, label %cond.lhs, label %cond.rhs
|
|
|
|
cond.lhs: ; preds = %entry
|
|
%7 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0
|
|
%8 = load %Head*, %Head** %7, align 8
|
|
%9 = getelementptr inbounds %Head, %Head* %8, i32 0, i32 0
|
|
%10 = load %"char[]"*, %"char[]"** %9, align 8
|
|
%ptrptr = bitcast %"char[]"* %10 to i8*
|
|
br label %cond.phi
|
|
|
|
cond.rhs: ; preds = %entry
|
|
br label %cond.phi
|
|
|
|
cond.phi: ; preds = %cond.rhs, %cond.lhs
|
|
%val = phi i8* [ %ptrptr, %cond.lhs ], [ null, %cond.rhs ]
|
|
%ptrptr1 = bitcast i8* %val to %"char[]"*
|
|
store %"char[]"* %ptrptr1, %"char[]"** %4, align 8
|
|
%11 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 1
|
|
store i8 1, i8* %11, align 8
|
|
%12 = bitcast %Summary* %literal to { %"char[]"*, i8 }*
|
|
%13 = load { %"char[]"*, i8 }, { %"char[]"*, i8 }* %12, align 8
|
|
ret { %"char[]"*, i8 } %13
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define { %"char[]"*, i8 } @test_readAndBuildSummary(i8* %0, i64 %1) #0 {
|
|
entry:
|
|
%url = alloca %"char[]", align 8
|
|
%retparam = alloca %Doc, align 8
|
|
%result = alloca %Summary, align 8
|
|
%literal = alloca %Summary, align 8
|
|
%taddr = alloca %Summary, align 8
|
|
%pair = bitcast %"char[]"* %url to { i8*, i64 }*
|
|
%2 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0
|
|
store i8* %0, i8** %2, align 8
|
|
%3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1
|
|
store i64 %1, i64* %3, align 8
|
|
%4 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%lo = load i8*, i8** %4, align 8
|
|
%5 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%hi = load i64, i64* %5, align 8
|
|
%6 = call i64 @test_readDoc(%Doc* %retparam, i8* %lo, i64 %hi)
|
|
%not_err = icmp eq i64 %6, 0
|
|
br i1 %not_err, label %after_check, label %else_block
|
|
|
|
after_check: ; preds = %entry
|
|
%7 = getelementptr inbounds %Doc, %Doc* %retparam, i32 0, i32 0
|
|
%8 = load %Head*, %Head** %7, align 8
|
|
%9 = call { %"char[]"*, i8 } @test_buildSummary(%Head* %8)
|
|
%10 = bitcast %Summary* %result to { %"char[]"*, i8 }*
|
|
store { %"char[]"*, i8 } %9, { %"char[]"*, i8 }* %10, align 8
|
|
%11 = load %Summary, %Summary* %result, align 8
|
|
br label %phi_block
|
|
|
|
else_block: ; preds = %entry
|
|
%12 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 0
|
|
store %"char[]"* null, %"char[]"** %12, align 8
|
|
%13 = getelementptr inbounds %Summary, %Summary* %literal, i32 0, i32 1
|
|
store i8 0, i8* %13, align 8
|
|
%14 = load %Summary, %Summary* %literal, align 8
|
|
br label %phi_block
|
|
|
|
phi_block: ; preds = %else_block, %after_check
|
|
%val = phi %Summary [ %11, %after_check ], [ %14, %else_block ]
|
|
store %Summary %val, %Summary* %taddr, align 8
|
|
%15 = bitcast %Summary* %taddr to { %"char[]"*, i8 }*
|
|
%16 = load { %"char[]"*, i8 }, { %"char[]"*, i8 }* %15, align 8
|
|
ret { %"char[]"*, i8 } %16
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i64 @test_isTitleNonEmpty(i8* %0, %Head* %1) #0 {
|
|
entry:
|
|
%doc = alloca %Doc, align 8
|
|
%head = alloca %"char[]"*, align 8
|
|
%reterr = alloca i64, align 8
|
|
%2 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0
|
|
store %Head* %1, %Head** %2, align 8
|
|
%3 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0
|
|
%4 = load %Head*, %Head** %3, align 8
|
|
%not = icmp eq %Head* %4, null
|
|
br i1 %not, label %if.then, label %if.exit
|
|
|
|
if.then: ; preds = %entry
|
|
ret i64 ptrtoint (%.fault* @"test_TitleResult$TITLE_MISSING" to i64)
|
|
|
|
if.exit: ; preds = %entry
|
|
%5 = getelementptr inbounds %Doc, %Doc* %doc, i32 0, i32 0
|
|
%6 = load %Head*, %Head** %5, align 8
|
|
%7 = getelementptr inbounds %Head, %Head* %6, i32 0, i32 0
|
|
%8 = load %"char[]"*, %"char[]"** %7, align 8
|
|
store %"char[]"* %8, %"char[]"** %head, align 8
|
|
%9 = load %"char[]"*, %"char[]"** %head, align 8
|
|
%not1 = icmp eq %"char[]"* %9, null
|
|
br i1 %not1, label %if.then2, label %if.exit3
|
|
|
|
if.then2: ; preds = %if.exit
|
|
ret i64 ptrtoint (%.fault* @"test_TitleResult$TITLE_MISSING" to i64)
|
|
|
|
if.exit3: ; preds = %if.exit
|
|
%10 = load %"char[]"*, %"char[]"** %head, align 8
|
|
%11 = getelementptr inbounds %"char[]", %"char[]"* %10, i32 0, i32 1
|
|
%12 = load i64, i64* %11, align 8
|
|
%lt = icmp ult i64 0, %12
|
|
%13 = zext i1 %lt to i8
|
|
store i8 %13, i8* %0, align 1
|
|
ret i64 0
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i64 @test_readWhetherTitleNonEmpty(i8* %0, i8* %1, i64 %2) #0 {
|
|
entry:
|
|
%url = alloca %"char[]", align 8
|
|
%reterr = alloca i64, align 8
|
|
%retparam = alloca i8, align 1
|
|
%retparam1 = alloca %Doc, align 8
|
|
%pair = bitcast %"char[]"* %url to { i8*, i64 }*
|
|
%3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 0
|
|
store i8* %1, i8** %3, align 8
|
|
%4 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %pair, i32 0, i32 1
|
|
store i64 %2, i64* %4, align 8
|
|
%5 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%lo = load i8*, i8** %5, align 8
|
|
%6 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%hi = load i64, i64* %6, align 8
|
|
%7 = call i64 @test_readDoc(%Doc* %retparam1, i8* %lo, i64 %hi)
|
|
%not_err = icmp eq i64 %7, 0
|
|
br i1 %not_err, label %after_check, label %assign_optional
|
|
|
|
assign_optional: ; preds = %entry
|
|
store i64 %7, i64* %reterr, align 8
|
|
br label %err_retblock
|
|
|
|
after_check: ; preds = %entry
|
|
%8 = getelementptr inbounds %Doc, %Doc* %retparam1, i32 0, i32 0
|
|
%9 = load %Head*, %Head** %8, align 8
|
|
%10 = call i64 @test_isTitleNonEmpty(i8* %retparam, %Head* %9)
|
|
%not_err2 = icmp eq i64 %10, 0
|
|
br i1 %not_err2, label %after_check4, label %assign_optional3
|
|
|
|
assign_optional3: ; preds = %after_check
|
|
store i64 %10, i64* %reterr, align 8
|
|
br label %err_retblock
|
|
|
|
after_check4: ; preds = %after_check
|
|
%11 = load i8, i8* %retparam, align 1
|
|
store i8 %11, i8* %0, align 1
|
|
ret i64 0
|
|
|
|
err_retblock: ; preds = %assign_optional3, %assign_optional
|
|
%12 = load i64, i64* %reterr, align 8
|
|
ret i64 %12
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i8* @test_bool_to_string(i8 zeroext %0) #0 {
|
|
entry:
|
|
%1 = trunc i8 %0 to i1
|
|
%ternary = select i1 %1, %"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i64 4 }, %"char[]" { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i32 0, i32 0), i64 5 }
|
|
%2 = extractvalue %"char[]" %ternary, 0
|
|
ret i8* %2
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define i8* @test_nameFromError(i64 %0) #0 {
|
|
entry:
|
|
%switch = alloca i64, align 8
|
|
store i64 %0, i64* %switch, align 8
|
|
br label %switch.entry
|
|
|
|
switch.entry: ; preds = %entry
|
|
%1 = load i64, i64* %switch, align 8
|
|
%eq = icmp eq i64 ptrtoint (%.fault* @"test_TitleResult$TITLE_MISSING" to i64), %1
|
|
br i1 %eq, label %switch.case, label %next_if
|
|
|
|
switch.case: ; preds = %switch.entry
|
|
ret i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i32 0, i32 0)
|
|
|
|
next_if: ; preds = %switch.entry
|
|
%eq1 = icmp eq i64 ptrtoint (%.fault* @"test_ReadError$BAD_READ" to i64), %1
|
|
br i1 %eq1, label %switch.case2, label %next_if3
|
|
|
|
switch.case2: ; preds = %next_if
|
|
ret i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i32 0, i32 0)
|
|
|
|
next_if3: ; preds = %next_if
|
|
%eq4 = icmp eq i64 ptrtoint (%.fault* @"test_ReadError$OUT_OF_MEMORY" to i64), %1
|
|
br i1 %eq4, label %switch.case5, label %next_if6
|
|
|
|
switch.case5: ; preds = %next_if3
|
|
ret i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i32 0, i32 0)
|
|
|
|
next_if6: ; preds = %next_if3
|
|
br label %switch.default
|
|
|
|
switch.default: ; preds = %next_if6
|
|
ret i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i32 0, i32 0)
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define void @test_main() #0 {
|
|
entry:
|
|
%URLS = alloca %"char[][]", align 8
|
|
%literal = alloca [5 x %"char[]"], align 16
|
|
%.anon = alloca i64, align 8
|
|
%.anon1 = alloca i64, align 8
|
|
%url = alloca %"char[]", align 8
|
|
%summary = alloca %Summary, align 8
|
|
%result = alloca %Summary, align 8
|
|
%title_sure = alloca %"char[]", align 8
|
|
%has_title = alloca i8, align 1
|
|
%has_title.f = alloca i64, align 8
|
|
%retparam = alloca i8, align 1
|
|
%0 = getelementptr inbounds [5 x %"char[]"], [5 x %"char[]"]* %literal, i64 0, i64 0
|
|
store %"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.15, i32 0, i32 0), i64 4 }, %"char[]"* %0, align 8
|
|
%1 = getelementptr inbounds [5 x %"char[]"], [5 x %"char[]"]* %literal, i64 0, i64 1
|
|
store %"char[]" { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i32 0, i32 0), i64 11 }, %"char[]"* %1, align 8
|
|
%2 = getelementptr inbounds [5 x %"char[]"], [5 x %"char[]"]* %literal, i64 0, i64 2
|
|
store %"char[]" { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i32 0, i32 0), i64 13 }, %"char[]"* %2, align 8
|
|
%3 = getelementptr inbounds [5 x %"char[]"], [5 x %"char[]"]* %literal, i64 0, i64 3
|
|
store %"char[]" { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i32 0, i32 0), i64 12 }, %"char[]"* %3, align 8
|
|
%4 = getelementptr inbounds [5 x %"char[]"], [5 x %"char[]"]* %literal, i64 0, i64 4
|
|
store %"char[]" { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i32 0, i32 0), i64 4 }, %"char[]"* %4, align 8
|
|
%5 = bitcast [5 x %"char[]"]* %literal to %"char[]"*
|
|
%6 = insertvalue %"char[][]" undef, %"char[]"* %5, 0
|
|
%7 = insertvalue %"char[][]" %6, i64 5, 1
|
|
store %"char[][]" %7, %"char[][]"* %URLS, align 8
|
|
%8 = getelementptr inbounds %"char[][]", %"char[][]"* %URLS, i32 0, i32 1
|
|
%9 = load i64, i64* %8, align 8
|
|
store i64 %9, i64* %.anon, align 8
|
|
store i64 0, i64* %.anon1, align 8
|
|
br label %loop.cond
|
|
|
|
loop.cond: ; preds = %phi_block12, %entry
|
|
%10 = load i64, i64* %.anon1, align 8
|
|
%11 = load i64, i64* %.anon, align 8
|
|
%lt = icmp ult i64 %10, %11
|
|
br i1 %lt, label %loop.body, label %loop.exit
|
|
|
|
loop.body: ; preds = %loop.cond
|
|
%12 = getelementptr inbounds %"char[][]", %"char[][]"* %URLS, i32 0, i32 0
|
|
%13 = load %"char[]"*, %"char[]"** %12, align 8
|
|
%14 = load i64, i64* %.anon1, align 8
|
|
%ptroffset = getelementptr inbounds %"char[]", %"char[]"* %13, i64 %14
|
|
%15 = bitcast %"char[]"* %url to i8*
|
|
%16 = bitcast %"char[]"* %ptroffset to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %15, i8* align 8 %16, i32 16, i1 false)
|
|
%17 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%18 = load i64, i64* %17, align 8
|
|
%uisitrunc = trunc i64 %18 to i32
|
|
%19 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%20 = load i8*, i8** %19, align 8
|
|
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.20, i32 0, i32 0), i32 %uisitrunc, i8* %20)
|
|
%22 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%lo = load i8*, i8** %22, align 8
|
|
%23 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%hi = load i64, i64* %23, align 8
|
|
%24 = call { %"char[]"*, i8 } @test_readAndBuildSummary(i8* %lo, i64 %hi)
|
|
%25 = bitcast %Summary* %result to { %"char[]"*, i8 }*
|
|
store { %"char[]"*, i8 } %24, { %"char[]"*, i8 }* %25, align 8
|
|
%26 = bitcast %Summary* %summary to i8*
|
|
%27 = bitcast %Summary* %result to i8*
|
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %26, i8* align 8 %27, i32 16, i1 false)
|
|
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.21, i32 0, i32 0))
|
|
%29 = load i8*, i8** @__stdoutp, align 8
|
|
call void @test_Summary_print(%Summary* %summary, i8* %29)
|
|
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.22, i32 0, i32 0))
|
|
%31 = getelementptr inbounds %Summary, %Summary* %summary, i32 0, i32 0
|
|
%32 = load %"char[]"*, %"char[]"** %31, align 8
|
|
%ptrbool = icmp ne %"char[]"* %32, null
|
|
br i1 %ptrbool, label %cond.lhs, label %cond.rhs
|
|
|
|
cond.lhs: ; preds = %loop.body
|
|
%33 = getelementptr inbounds %Summary, %Summary* %summary, i32 0, i32 0
|
|
%34 = load %"char[]"*, %"char[]"** %33, align 8
|
|
%35 = load %"char[]", %"char[]"* %34, align 8
|
|
br label %cond.phi
|
|
|
|
cond.rhs: ; preds = %loop.body
|
|
br label %cond.phi
|
|
|
|
cond.phi: ; preds = %cond.rhs, %cond.lhs
|
|
%val = phi %"char[]" [ %35, %cond.lhs ], [ zeroinitializer, %cond.rhs ]
|
|
store %"char[]" %val, %"char[]"* %title_sure, align 8
|
|
%36 = getelementptr inbounds %"char[]", %"char[]"* %title_sure, i32 0, i32 1
|
|
%37 = load i64, i64* %36, align 8
|
|
%uisitrunc2 = trunc i64 %37 to i32
|
|
%38 = getelementptr inbounds %"char[]", %"char[]"* %title_sure, i32 0, i32 0
|
|
%39 = load i8*, i8** %38, align 8
|
|
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.24, i32 0, i32 0), i32 %uisitrunc2, i8* %39)
|
|
%41 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 0
|
|
%lo3 = load i8*, i8** %41, align 8
|
|
%42 = getelementptr inbounds %"char[]", %"char[]"* %url, i32 0, i32 1
|
|
%hi4 = load i64, i64* %42, align 8
|
|
%43 = call i64 @test_readWhetherTitleNonEmpty(i8* %retparam, i8* %lo3, i64 %hi4)
|
|
%not_err = icmp eq i64 %43, 0
|
|
br i1 %not_err, label %after_check, label %assign_optional
|
|
|
|
assign_optional: ; preds = %cond.phi
|
|
store i64 %43, i64* %has_title.f, align 8
|
|
br label %after_assign
|
|
|
|
after_check: ; preds = %cond.phi
|
|
%44 = load i8, i8* %retparam, align 1
|
|
store i8 %44, i8* %has_title, align 1
|
|
store i64 0, i64* %has_title.f, align 8
|
|
br label %after_assign
|
|
|
|
after_assign: ; preds = %after_check, %assign_optional
|
|
%optval = load i64, i64* %has_title.f, align 8
|
|
%not_err5 = icmp eq i64 %optval, 0
|
|
br i1 %not_err5, label %after_check6, label %else_block
|
|
|
|
after_check6: ; preds = %after_assign
|
|
%45 = load i8, i8* %has_title, align 1
|
|
%46 = call i8* @test_bool_to_string(i8 %45)
|
|
br label %phi_block
|
|
|
|
else_block: ; preds = %after_assign
|
|
%47 = load i64, i64* %has_title.f, align 8
|
|
%48 = call i8* @test_nameFromError(i64 %47)
|
|
br label %phi_block
|
|
|
|
phi_block: ; preds = %else_block, %after_check6
|
|
%val7 = phi i8* [ %46, %after_check6 ], [ %48, %else_block ]
|
|
%optval8 = load i64, i64* %has_title.f, align 8
|
|
%not_err9 = icmp eq i64 %optval8, 0
|
|
br i1 %not_err9, label %after_check10, label %else_block11
|
|
|
|
after_check10: ; preds = %phi_block
|
|
%49 = load i8, i8* %has_title, align 1
|
|
%50 = trunc i8 %49 to i1
|
|
br label %phi_block12
|
|
|
|
else_block11: ; preds = %phi_block
|
|
br label %phi_block12
|
|
|
|
phi_block12: ; preds = %else_block11, %after_check10
|
|
%val13 = phi i1 [ %50, %after_check10 ], [ false, %else_block11 ]
|
|
%ternary = select i1 %val13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.27, i32 0, i32 0)
|
|
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.25, i32 0, i32 0), i8* %val7, i8* %ternary)
|
|
%52 = load i64, i64* %.anon1, align 8
|
|
%add = add i64 %52, 1
|
|
store i64 %add, i64* %.anon1, align 8
|
|
br label %loop.cond
|
|
|
|
loop.exit: ; preds = %loop.cond
|
|
ret void
|
|
}
|