Files
c3c/test/test_suite/functions/test_regression.c3t

754 lines
24 KiB
C

// #target: x64-darwin
module test;
import test2;
import std::array::list;
import std::array::linkedlist;
import hello_world;
extern func int printf(char *, ...);
func void helloWorld()
{
printf("helloWorld!\n");
}
func int test_static()
{
static int x = 1;
x++;
printf("Test static %d\n", x);
return x;
}
struct Bobo { short b; float c; short d; short e; float f; short g; }
struct Blob { int z; int f; }
union Foor
{
long a;
char[12] b;
}
func int helo(double d, Bobo b)
{
int[3] de = { 1, 2, 3 };
Bobo c = b;
helo(1.0, c);
return 1;
}
func int test1(int a, int b)
{
a = a >> b;
if (b > 128) return -1;
return a;
}
struct Foo2
{
int x;
}
func void Foo2.printme(Foo2 *foo)
{
printf("Foo is: %d\n", foo.x);
}
func int Foo2.mutate(Foo2 *foo)
{
printf("Mutating");
return ++foo.x;
}
extern func void test_virtual3(virtual* y);
interface Baz
{
func void open();
func int close();
}
extern func void test_virtual2(virtual Baz* z);
define oopsInt = test2::argh<int>;
define oopsDouble = test2::argh<int>;
define Argh = func int(double, Bobo);
define Argh2 = func int(double, Bobo);
func int sum_us(int... x)
{
int sum = 0;
if (x.len == 0) return 0;
sum += x[0] + sum_us(...x[1..^1]);
return sum;
}
define Frob = long;
func int sumd(int[] x)
{
int sum = 0;
for (int i = 0; i < x.len; i++) sum += x[i];
return sum;
}
struct Foo
{
int a;
int b;
}
define getValueInt = test2::getValue<int>;
define getValueDouble = test2::getValue<double>;
define IntBlob = test2::Blob<int>;
define DoubleBlob = Blob<double>;
define getMultInt = getMult<int>;
define getMultDouble = getMult<double>;
define IntArray = List<int>;
define IntList = LinkedList<int>;
enum MyEnum : int
{
HELO = 12,
WORLD = 14,
BYE = -5
}
func void main()
{
test_static();
test_static();
test_static();
hello_world::hello();
IntList list;
list.push(10);
list.push(15);
list.push(30);
for (int i = 0; i < (int)(list.len()); i++)
{
printf("Element[%d]: %d\n", i, list.get(i));
}
list.free();
printf("Min %d Max %d Elements: %d\n", MyEnum.min, MyEnum.max, (int)(MyEnum.elements));
int max = MyEnum.max;
int min = MyEnum.min;
int elements = MyEnum.elements;
printf("Hello\n");
IntArray array;
array.append(100);
array.append(200);
array.append(400);
array.push(600);
array.insertAt(2, 300);
for (int i = 0; i < (int)(array.len()); i++)
{
printf("Element[%d]: %d\n", i, array.get(i));
}
array.free();
IntBlob a = { 42 };
DoubleBlob b = { 33.3 };
printf("a was %d\n", getValueInt(a));
printf("b was %f\n", getValueDouble(b));
printf("Mult int was %d\n", getMultInt(25));
printf("Mult double was %f\n", getMultDouble(3.3));
helloWorld();
Foo ddx;
int fro = 3;
int[4] x = { 1, 2, 3, 3 };
fro += printf("1Vararg4unsplatA: %d\n", sum_us(...x));
printf("%d\n", fro);
int[] z = &x;
int[3] de = { 1, 2, 3 };
printf("Vararg4unsplatB: %d\n", sum_us(...&x));
printf("Vararg4unsplatC: %d\n", sum_us(...z));
printf("Vararg4: %d\n", sum_us(1, 2, 4, 5));
printf("Vararg1: %d\n", sum_us(1));
printf("Vararg0: %d\n", sum_us());
Argh a1;
Argh2 b2;
}
module hello_world;
import foo;
extern func int printf(char *, ...);
define doubleMult = check<double>;
func void hello()
{
printf("Hello baby\n");
printf("Mult %f\n", doubleMult(11.1));
}
module foo <Type>;
func Type check(Type i)
{
return i * i;
}
module test2 <Type>;
struct Blob
{
Type a;
}
func Type getMult(Type a)
{
return a * a;
}
Type argh = 234;
errtype MyErr
{
X,
Y
}
enum Hello : int
{
FOO = 3,
BAR = 4,
}
macro Hello wut()
{
return Hello.FOO;
}
define Bye = Hello;
define wat = wut;
define byebye = hello;
func int hello()
{
return 1;
}
func Type getValue(Blob blob)
{
return blob.a;
}
/* #expect: test.ll
%Blob = type { i32 }
%Blob.0 = type { double }
%List = type { i64, i64, i32* }
%LinkedList = type { i64, %Node*, %Node* }
%Node = type { %Node*, %Node*, i32 }
%Foo2 = type { i32 }
%Bobo = type { i16, float, i16, i16, float, i16 }
%"int[]" = type { i32*, i64 }
%Foo = type { i32, i32 }
define void @test.Foo2__printme(%Foo2* %0) #0 {
entry:
%foo = alloca %Foo2*, align 8
store %Foo2* %0, %Foo2** %foo, align 8
%1 = load %Foo2*, %Foo2** %foo, align 8
%2 = getelementptr inbounds %Foo2, %Foo2* %1, i32 0, i32 0
%3 = load i32, i32* %2, align 8
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.21, i32 0, i32 0), i32 %3)
ret void
}
; Function Attrs: nounwind
define i32 @test.Foo2__mutate(%Foo2* %0) #0 {
entry:
%foo = alloca %Foo2*, align 8
store %Foo2* %0, %Foo2** %foo, align 8
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.22, i32 0, i32 0))
%2 = load %Foo2*, %Foo2** %foo, align 8
%3 = getelementptr inbounds %Foo2, %Foo2* %2, i32 0, i32 0
%4 = load i32, i32* %3, align 8
%add = add i32 %4, 1
store i32 %add, i32* %3, align 8
ret i32 %add
}
; Function Attrs: nounwind
declare i32 @printf(i8*, ...) #0
; Function Attrs: nounwind
define void @test.helloWorld() #0 {
entry:
%0 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0))
ret void
}
; Function Attrs: nounwind
define i32 @test.test_static() #0 {
entry:
%0 = load i32, i32* @test_static.x, align 4
%add = add i32 %0, 1
store i32 %add, i32* @test_static.x, align 4
%1 = load i32, i32* @test_static.x, align 4
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i32 0, i32 0), i32 %1)
%3 = load i32, i32* @test_static.x, align 4
ret i32 %3
}
; Function Attrs: nounwind
define i32 @test.helo(double %0, %Bobo* byval(%Bobo) align 8 %1) #0 {
entry:
%d = alloca double, align 8
%b = alloca %Bobo, align 4
%de = alloca [3 x i32], align 4
%c = alloca %Bobo, align 4
%indirectarg = alloca %Bobo, align 8
store double %0, double* %d, align 8
%2 = bitcast %Bobo* %b to i8*
%3 = bitcast %Bobo* %1 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %2, i8* align 8 %3, i32 20, i1 false)
%4 = bitcast [3 x i32]* %de to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %4, i8* align 4 bitcast ([3 x i32]* @.__const to i8*), i32 12, i1 false)
%5 = bitcast %Bobo* %c to i8*
%6 = bitcast %Bobo* %b to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %5, i8* align 4 %6, i32 20, i1 false)
%7 = bitcast %Bobo* %indirectarg to i8*
%8 = bitcast %Bobo* %c to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %7, i8* align 4 %8, i32 20, i1 false)
%9 = call i32 @test.helo(double 1.000000e+00, %Bobo* byval(%Bobo) align 8 %indirectarg)
ret i32 1
}
; Function Attrs: nounwind
define i32 @test.test1(i32 %0, i32 %1) #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
store i32 %0, i32* %a, align 4
store i32 %1, i32* %b, align 4
%2 = load i32, i32* %a, align 4
%3 = load i32, i32* %b, align 4
%ashr = ashr i32 %2, %3
%4 = freeze i32 %ashr
store i32 %4, i32* %a, align 4
%5 = load i32, i32* %b, align 4
%gt = icmp sgt i32 %5, 128
br i1 %gt, label %if.then, label %if.exit
if.then: ; preds = %entry
ret i32 -1
if.exit: ; preds = %entry
%6 = load i32, i32* %a, align 4
ret i32 %6
}
; Function Attrs: nounwind
declare void @test_virtual3(i64, i8*) #0
; Function Attrs: nounwind
declare void @test_virtual2(i8*, i8*) #0
; Function Attrs: nounwind
define i32 @test.sum_us(i8* %0, i64 %1) #0 {
entry:
%x = alloca %"int[]", align 8
%sum = alloca i32, align 4
%vararg = alloca %"int[]", align 8
%taddr = alloca %"int[]", align 8
%pair = bitcast %"int[]"* %x 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
store i32 0, i32* %sum, align 4
%4 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 1
%5 = load i64, i64* %4, align 8
%eq = icmp eq i64 0, %5
br i1 %eq, label %if.then, label %if.exit
if.then: ; preds = %entry
ret i32 0
if.exit: ; preds = %entry
%6 = load i32, i32* %sum, align 4
%7 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 0
%8 = load i32*, i32** %7, align 8
%ptroffset = getelementptr inbounds i32, i32* %8, i64 0
%9 = load i32, i32* %ptroffset, align 4
%10 = load %"int[]", %"int[]"* %x, align 8
%11 = extractvalue %"int[]" %10, 0
%12 = extractvalue %"int[]" %10, 1
%sub = sub i64 %12, 1
%13 = add i64 %sub, 1
%size = sub i64 %13, 1
%ptroffset1 = getelementptr inbounds i32, i32* %11, i64 1
%14 = insertvalue %"int[]" undef, i32* %ptroffset1, 0
%15 = insertvalue %"int[]" %14, i64 %size, 1
%16 = getelementptr inbounds %"int[]", %"int[]"* %vararg, i32 0, i32 1
%17 = getelementptr inbounds %"int[]", %"int[]"* %vararg, i32 0, i32 0
store %"int[]" %15, %"int[]"* %taddr, align 8
%18 = bitcast %"int[]"* %taddr to { i8*, i64 }*
%19 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %18, i32 0, i32 0
%lo = load i8*, i8** %19, align 8
%20 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %18, i32 0, i32 1
%hi = load i64, i64* %20, align 8
%21 = call i32 @test.sum_us(i8* %lo, i64 %hi)
%add = add i32 %9, %21
%add2 = add i32 %6, %add
store i32 %add2, i32* %sum, align 4
%22 = load i32, i32* %sum, align 4
ret i32 %22
}
; Function Attrs: nounwind
define i32 @test.sumd(i8* %0, i64 %1) #0 {
entry:
%x = alloca %"int[]", align 8
%sum = alloca i32, align 4
%i = alloca i32, align 4
%pair = bitcast %"int[]"* %x 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
store i32 0, i32* %sum, align 4
store i32 0, i32* %i, align 4
br label %for.cond
for.cond: ; preds = %for.inc, %entry
%4 = load i32, i32* %i, align 4
%sisiext = sext i32 %4 to i64
%5 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 1
%6 = load i64, i64* %5, align 8
%lt = icmp slt i64 %sisiext, %6
%check = icmp slt i64 %6, 0
%siui-lt = or i1 %check, %lt
br i1 %siui-lt, label %for.body, label %for.exit
for.body: ; preds = %for.cond
%7 = load i32, i32* %sum, align 4
%8 = getelementptr inbounds %"int[]", %"int[]"* %x, i32 0, i32 0
%9 = load i32*, i32** %8, align 8
%10 = load i32, i32* %i, align 4
%sisiext1 = sext i32 %10 to i64
%ptroffset = getelementptr inbounds i32, i32* %9, i64 %sisiext1
%11 = load i32, i32* %ptroffset, align 4
%add = add i32 %7, %11
store i32 %add, i32* %sum, align 4
br label %for.inc
for.inc: ; preds = %for.body
%12 = load i32, i32* %i, align 4
%add2 = add i32 %12, 1
store i32 %add2, i32* %i, align 4
br label %for.cond
for.exit: ; preds = %for.cond
%13 = load i32, i32* %sum, align 4
ret i32 %13
}
; Function Attrs: nounwind
define void @main() #0 {
entry:
%list = alloca %LinkedList, align 8
%i = alloca i32, align 4
%max = alloca i32, align 4
%min = alloca i32, align 4
%elements = alloca i32, align 4
%array = alloca %List, align 8
%i1 = alloca i32, align 4
%a = alloca %Blob, align 4
%b = alloca %Blob.0, align 8
%tempcoerce = alloca double, align 8
%ddx = alloca %Foo, align 4
%fro = alloca i32, align 4
%x = alloca [4 x i32], align 16
%vararg = alloca %"int[]", align 8
%z = alloca %"int[]", align 8
%de = alloca [3 x i32], align 4
%vararg11 = alloca %"int[]", align 8
%vararg14 = alloca %"int[]", align 8
%vararg17 = alloca %"int[]", align 8
%varargslots = alloca [4 x i32], align 16
%vararg20 = alloca %"int[]", align 8
%varargslots21 = alloca [1 x i32], align 4
%vararg24 = alloca %"int[]", align 8
%a1 = alloca i32 (double, %Bobo*)*, align 8
%b2 = alloca i32 (double, %Bobo*)*, align 8
%0 = call i32 @test.test_static()
%1 = call i32 @test.test_static()
%2 = call i32 @test.test_static()
call void @hello_world.hello()
%3 = bitcast %LinkedList* %list to i8*
call void @llvm.memset.p0i8.i64(i8* align 8 %3, i8 0, i64 24, i1 false)
call void @"std::array::linkedlist.int.LinkedList__push"(%LinkedList* %list, i32 10)
call void @"std::array::linkedlist.int.LinkedList__push"(%LinkedList* %list, i32 15)
call void @"std::array::linkedlist.int.LinkedList__push"(%LinkedList* %list, i32 30)
store i32 0, i32* %i, align 4
br label %for.cond
for.cond: ; preds = %for.inc, %entry
%4 = load i32, i32* %i, align 4
%5 = call i64 @"std::array::linkedlist.int.LinkedList__len"(%LinkedList* %list) #3
%uisitrunc = trunc i64 %5 to i32
%lt = icmp slt i32 %4, %uisitrunc
br i1 %lt, label %for.body, label %for.exit
for.body: ; preds = %for.cond
%6 = load i32, i32* %i, align 4
%7 = load i32, i32* %i, align 4
%siuiext = zext i32 %7 to i64
%8 = call i32 @"std::array::linkedlist.int.LinkedList__get"(%LinkedList* %list, i64 %siuiext)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i32 0, i32 0), i32 %6, i32 %8)
br label %for.inc
for.inc: ; preds = %for.body
%10 = load i32, i32* %i, align 4
%add = add i32 %10, 1
store i32 %add, i32* %i, align 4
br label %for.cond
for.exit: ; preds = %for.cond
call void @"std::array::linkedlist.int.LinkedList__free"(%LinkedList* %list)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i32 0, i32 0), i32 -5, i32 14, i32 3)
store i32 14, i32* %max, align 4
store i32 -5, i32* %min, align 4
store i32 3, i32* %elements, align 4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0))
%13 = bitcast %List* %array to i8*
call void @llvm.memset.p0i8.i64(i8* align 8 %13, i8 0, i64 24, i1 false)
call void @"std::array::list.int.List__append"(%List* %array, i32 100)
call void @"std::array::list.int.List__append"(%List* %array, i32 200)
call void @"std::array::list.int.List__append"(%List* %array, i32 400)
call void @"std::array::list.int.List__push"(%List* %array, i32 600) #3
call void @"std::array::list.int.List__insertAt"(%List* %array, i64 2, i32 300)
store i32 0, i32* %i1, align 4
br label %for.cond2
for.cond2: ; preds = %for.inc7, %for.exit
%14 = load i32, i32* %i1, align 4
%15 = call i64 @"std::array::list.int.List__len"(%List* %array)
%uisitrunc3 = trunc i64 %15 to i32
%lt4 = icmp slt i32 %14, %uisitrunc3
br i1 %lt4, label %for.body5, label %for.exit9
for.body5: ; preds = %for.cond2
%16 = load i32, i32* %i1, align 4
%17 = load i32, i32* %i1, align 4
%siuiext6 = zext i32 %17 to i64
%18 = call i32 @"std::array::list.int.List__get"(%List* %array, i64 %siuiext6)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i32 0, i32 0), i32 %16, i32 %18)
br label %for.inc7
for.inc7: ; preds = %for.body5
%20 = load i32, i32* %i1, align 4
%add8 = add i32 %20, 1
store i32 %add8, i32* %i1, align 4
br label %for.cond2
for.exit9: ; preds = %for.cond2
call void @"std::array::list.int.List__free"(%List* %array)
%21 = bitcast %Blob* %a to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %21, i8* align 4 bitcast (%Blob* @.__const.6 to i8*), i32 4, i1 false)
%22 = bitcast %Blob.0* %b to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %22, i8* align 8 bitcast (%Blob.0* @.__const.7 to i8*), i32 8, i1 false)
%23 = getelementptr inbounds %Blob, %Blob* %a, i32 0, i32 0
%24 = load i32, i32* %23, align 4
%25 = call i32 @test2.int.getValue(i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i32 0, i32 0), i32 %25)
%27 = getelementptr inbounds %Blob.0, %Blob.0* %b, i32 0, i32 0
%28 = bitcast double* %tempcoerce to i8*
%29 = bitcast double* %27 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %28, i8* align 8 %29, i32 8, i1 false)
%30 = load double, double* %tempcoerce, align 8
%31 = call double @test2.double.getValue(double %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i32 0, i32 0), double %31)
%33 = call i32 @test2.int.getMult(i32 25)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i32 0, i32 0), i32 %33)
%35 = call double @test2.double.getMult(double 3.300000e+00)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i32 0, i32 0), double %35)
call void @test.helloWorld()
%37 = bitcast %Foo* %ddx to i8*
call void @llvm.memset.p0i8.i64(i8* align 4 %37, i8 0, i64 8, i1 false)
store i32 3, i32* %fro, align 4
%38 = bitcast [4 x i32]* %x to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 16 %38, i8* align 16 bitcast ([4 x i32]* @.__const.12 to i8*), i32 16, i1 false)
%39 = load i32, i32* %fro, align 4
%40 = getelementptr inbounds %"int[]", %"int[]"* %vararg, i32 0, i32 1
%41 = getelementptr inbounds %"int[]", %"int[]"* %vararg, i32 0, i32 0
store i64 4, i64* %40, align 8
%42 = bitcast [4 x i32]* %x to i32*
store i32* %42, i32** %41, align 8
%43 = bitcast %"int[]"* %vararg to { i8*, i64 }*
%44 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %43, i32 0, i32 0
%lo = load i8*, i8** %44, align 8
%45 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %43, i32 0, i32 1
%hi = load i64, i64* %45, align 8
%46 = call i32 @test.sum_us(i8* %lo, i64 %hi)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i32 0, i32 0), i32 %46)
%add10 = add i32 %39, %47
store i32 %add10, i32* %fro, align 4
%48 = load i32, i32* %fro, align 4
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i32 0, i32 0), i32 %48)
%50 = bitcast [4 x i32]* %x to i32*
%51 = insertvalue %"int[]" undef, i32* %50, 0
%52 = insertvalue %"int[]" %51, i64 4, 1
store %"int[]" %52, %"int[]"* %z, align 8
%53 = bitcast [3 x i32]* %de to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %53, i8* align 4 bitcast ([3 x i32]* @.__const.15 to i8*), i32 12, i1 false)
%54 = getelementptr inbounds %"int[]", %"int[]"* %vararg11, i32 0, i32 1
%55 = getelementptr inbounds %"int[]", %"int[]"* %vararg11, i32 0, i32 0
store i64 4, i64* %54, align 8
%56 = bitcast [4 x i32]* %x to i32*
store i32* %56, i32** %55, align 8
%57 = bitcast %"int[]"* %vararg11 to { i8*, i64 }*
%58 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %57, i32 0, i32 0
%lo12 = load i8*, i8** %58, align 8
%59 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %57, i32 0, i32 1
%hi13 = load i64, i64* %59, align 8
%60 = call i32 @test.sum_us(i8* %lo12, i64 %hi13)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i32 0, i32 0), i32 %60)
%62 = getelementptr inbounds %"int[]", %"int[]"* %vararg14, i32 0, i32 1
%63 = getelementptr inbounds %"int[]", %"int[]"* %vararg14, i32 0, i32 0
%64 = bitcast %"int[]"* %z to { i8*, i64 }*
%65 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %64, i32 0, i32 0
%lo15 = load i8*, i8** %65, align 8
%66 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %64, i32 0, i32 1
%hi16 = load i64, i64* %66, align 8
%67 = call i32 @test.sum_us(i8* %lo15, i64 %hi16)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.17, i32 0, i32 0), i32 %67)
%69 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 0
store i32 1, i32* %69, align 4
%70 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 1
store i32 2, i32* %70, align 4
%71 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 2
store i32 4, i32* %71, align 4
%72 = getelementptr inbounds [4 x i32], [4 x i32]* %varargslots, i64 0, i64 3
store i32 5, i32* %72, align 4
%73 = getelementptr inbounds %"int[]", %"int[]"* %vararg17, i32 0, i32 1
store i64 4, i64* %73, align 8
%74 = getelementptr inbounds %"int[]", %"int[]"* %vararg17, i32 0, i32 0
%75 = bitcast [4 x i32]* %varargslots to i32*
store i32* %75, i32** %74, align 8
%76 = bitcast %"int[]"* %vararg17 to { i8*, i64 }*
%77 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %76, i32 0, i32 0
%lo18 = load i8*, i8** %77, align 8
%78 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %76, i32 0, i32 1
%hi19 = load i64, i64* %78, align 8
%79 = call i32 @test.sum_us(i8* %lo18, i64 %hi19)
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.18, i32 0, i32 0), i32 %79)
%81 = getelementptr inbounds [1 x i32], [1 x i32]* %varargslots21, i64 0, i64 0
store i32 1, i32* %81, align 4
%82 = getelementptr inbounds %"int[]", %"int[]"* %vararg20, i32 0, i32 1
store i64 1, i64* %82, align 8
%83 = getelementptr inbounds %"int[]", %"int[]"* %vararg20, i32 0, i32 0
%84 = bitcast [1 x i32]* %varargslots21 to i32*
store i32* %84, i32** %83, align 8
%85 = bitcast %"int[]"* %vararg20 to { i8*, i64 }*
%86 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %85, i32 0, i32 0
%lo22 = load i8*, i8** %86, align 8
%87 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %85, i32 0, i32 1
%hi23 = load i64, i64* %87, align 8
%88 = call i32 @test.sum_us(i8* %lo22, i64 %hi23)
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.19, i32 0, i32 0), i32 %88)
%90 = getelementptr inbounds %"int[]", %"int[]"* %vararg24, i32 0, i32 1
store i64 0, i64* %90, align 8
%91 = bitcast %"int[]"* %vararg24 to { i8*, i64 }*
%92 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %91, i32 0, i32 0
%lo25 = load i8*, i8** %92, align 8
%93 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %91, i32 0, i32 1
%hi26 = load i64, i64* %93, align 8
%94 = call i32 @test.sum_us(i8* %lo25, i64 %hi26)
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i32 0, i32 0), i32 %94)
store i32 (double, %Bobo*)* null, i32 (double, %Bobo*)** %a1, align 8
store i32 (double, %Bobo*)* null, i32 (double, %Bobo*)** %b2, align 8
ret void
}
// #expect: hello_world.ll
define void @hello_world.hello()
entry:
%0 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0))
%1 = call double @foo.double.check(double 1.110000e+01)
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), double %1)
ret void
// #expect: foo.double.ll
define double @foo.double.check(double %0)
entry:
%i = alloca double, align 8
store double %0, double* %i, align 8
%1 = load double, double* %i, align 8
%2 = load double, double* %i, align 8
%fmul = fmul double %1, %2
ret double %fmul
// #expect: test2.int.ll
%Blob = type { i32 }
@test2.int.argh = global i32 234, align 4
define i32 @test2.int.getMult(i32 %0)
entry:
%a = alloca i32, align 4
store i32 %0, i32* %a, align 4
%1 = load i32, i32* %a, align 4
%2 = load i32, i32* %a, align 4
%mul = mul i32 %1, %2
ret i32 %mul
define i32 @test2.int.hello()
entry:
ret i32 1
}
define i32 @test2.int.getValue(i32 %0)
entry:
%blob = alloca %Blob, align 4
%1 = getelementptr inbounds %Blob, %Blob* %blob, i32 0, i32 0
store i32 %0, i32* %1, align 4
%2 = getelementptr inbounds %Blob, %Blob* %blob, i32 0, i32 0
%3 = load i32, i32* %2, align 4
ret i32 %3
// #expect: test2.double.ll
%Blob = type { double }
@test2.double.argh = global double 2.340000e+02, align 8
define double @test2.double.getMult(double %0)
entry:
%a = alloca double, align 8
store double %0, double* %a, align 8
%1 = load double, double* %a, align 8
%2 = load double, double* %a, align 8
%fmul = fmul double %1, %2
ret double %fmul
define i32 @test2.double.hello()
entry:
ret i32 1
define double @test2.double.getValue(double %0)
entry:
%blob = alloca %Blob, align 8
%1 = getelementptr inbounds %Blob, %Blob* %blob, i32 0, i32 0
store double %0, double* %1, align 8
%2 = getelementptr inbounds %Blob, %Blob* %blob, i32 0, i32 0
%3 = load double, double* %2, align 8
ret double %3