Skip to content

Instantly share code, notes, and snippets.

@yhara
Last active May 1, 2020 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yhara/3ac6b67b56a3cf5447a4e641a36ed0b2 to your computer and use it in GitHub Desktop.
Save yhara/3ac6b67b56a3cf5447a4e641a36ed0b2 to your computer and use it in GitHub Desktop.
/Users/yhara/Dropbox/proj/shiika/examples % lldb -c /cores/core.67850
(lldb) target create --core "/cores/core.67850"
warning: (x86_64) /cores/core.67850 load command 433 LC_SEGMENT_64 has a fileoff + filesize (0x2f51e000) that extends beyond the end of the file (0x2f51d000), the segment will be truncated to match
warning: (x86_64) /cores/core.67850 load command 434 LC_SEGMENT_64 has a fileoff (0x2f51e000) that extends beyond the end of the file (0x2f51d000), ignoring this section
Core file '/cores/core.67850' (x86_64) was loaded.
(lldb) bt
* thread #1, stop reason = signal SIGSTOP
* frame #0: 0x000000010cf21e0d libgc.1.dylib`GC_clear_stack_inner + 46
frame #1: 0x000000010cf21e27 libgc.1.dylib`GC_clear_stack_inner + 72
frame #2: 0x000000010cf21e27 libgc.1.dylib`GC_clear_stack_inner + 72
frame #3: 0x000000010cf21e27 libgc.1.dylib`GC_clear_stack_inner + 72
frame #4: 0x000000010cf21e27 libgc.1.dylib`GC_clear_stack_inner + 72
frame #5: 0x000000010cf21e27 libgc.1.dylib`GC_clear_stack_inner + 72
frame #6: 0x000000010cf21e27 libgc.1.dylib`GC_clear_stack_inner + 72
frame #7: 0x000000010cf21e27 libgc.1.dylib`GC_clear_stack_inner + 72
frame #8: 0x000000010cf21e27 libgc.1.dylib`GC_clear_stack_inner + 72
frame #9: 0x000000010cf1f3f4 libgc.1.dylib`GC_generic_malloc_many + 1103
frame #10: 0x000000010cf297c1 libgc.1.dylib`GC_malloc_kind + 211
frame #11: 0x000000010cf08db1 a.out`Meta:Vec#new + 33
frame #12: 0x000000010cf0ac19 a.out`user_main + 1353
frame #13: 0x000000010cf0aee0 a.out`main + 16
frame #14: 0x00007fffb4e2d235 libdyld.dylib`start + 1
frame #15: 0x00007fffb4e2d235 libdyld.dylib`start + 1
(lldb) disassemble
libgc.1.dylib`GC_clear_stack_inner:
0x10cf21ddf <+0>: pushq %rbp
0x10cf21de0 <+1>: movq %rsp, %rbp
0x10cf21de3 <+4>: pushq %r14
0x10cf21de5 <+6>: pushq %rbx
0x10cf21de6 <+7>: subq $0x6b0, %rsp ; imm = 0x6B0
0x10cf21ded <+14>: movq %rsi, %rbx
0x10cf21df0 <+17>: movq %rdi, %r14
0x10cf21df3 <+20>: movq 0xb216(%rip), %rax ; (void *)0x00007fffbdd40070: __stack_chk_guard
0x10cf21dfa <+27>: movq (%rax), %rax
0x10cf21dfd <+30>: movq %rax, -0x18(%rbp)
0x10cf21e01 <+34>: leaq -0x6c0(%rbp), %rdi
0x10cf21e08 <+41>: movl $0x6a8, %esi ; imm = 0x6A8
-> 0x10cf21e0d <+46>: callq 0x10cf29b6a ; symbol stub for: __bzero
0x10cf21e12 <+51>: callq 0x10cf21985 ; GC_approx_sp
0x10cf21e17 <+56>: cmpq %rbx, %rax
0x10cf21e1a <+59>: jbe 0x10cf21e27 ; <+72>
0x10cf21e1c <+61>: movq %r14, %rdi
0x10cf21e1f <+64>: movq %rbx, %rsi
0x10cf21e22 <+67>: callq 0x10cf21ddf ; <+0>
0x10cf21e27 <+72>: leaq -0x6c0(%rbp), %rdi
0x10cf21e2e <+79>: callq 0x10cf1f65e ; GC_noop1
0x10cf21e33 <+84>: movq 0xb1d6(%rip), %rax ; (void *)0x00007fffbdd40070: __stack_chk_guard
0x10cf21e3a <+91>: movq (%rax), %rax
0x10cf21e3d <+94>: cmpq -0x18(%rbp), %rax
0x10cf21e41 <+98>: jne 0x10cf21e52 ; <+115>
0x10cf21e43 <+100>: movq %r14, %rax
0x10cf21e46 <+103>: addq $0x6b0, %rsp ; imm = 0x6B0
0x10cf21e4d <+110>: popq %rbx
0x10cf21e4e <+111>: popq %r14
0x10cf21e50 <+113>: popq %rbp
0x10cf21e51 <+114>: retq
0x10cf21e52 <+115>: callq 0x10cf29b7c ; symbol stub for: __stack_chk_fail
(lldb)
; ModuleID = 'main'
source_filename = "main"
%"Meta:Ray" = type { %String* }
%String = type { i8*, i32 }
%"Meta:Sphere" = type { %String* }
%"Meta:Isect" = type { %String* }
%"Meta:MutableString" = type { %String* }
%Plane = type { %Vec*, %Vec*, %Vec* }
%Vec = type { double, double, double }
%"Meta:Bool" = type { %String* }
%"Meta:Int" = type { %String* }
%"Meta:Object" = type { %String* }
%Sphere = type { double, %Vec*, %Vec* }
%"Meta:Util" = type { %String* }
%"Meta:Shiika" = type { %String* }
%"Meta:Shiika::Internal" = type { %String* }
%"Meta:Vec" = type { %String* }
%"Meta:Never" = type { %String* }
%"Meta:Class" = type { %String* }
%"Meta:Math" = type { %String* }
%"Meta:String" = type { %String* }
%"Meta:Shiika::Internal::Ptr" = type { %String* }
%Void = type {}
%"Meta:Shiika::Internal::Memory" = type { %String* }
%"Meta:Void" = type { %String* }
%"Meta:Plane" = type { %String* }
%"Meta:Float" = type { %String* }
%Isect = type { i32, %Vec*, %Vec*, %Vec*, double, %Vec* }
%MutableString = type { i8*, i32, i32 }
%Ray = type { %Vec*, %Vec* }
%Class = type { %String* }
%Object = type {}
@putd_tmpl = internal constant [3 x i8] c"%d\00"
@putf_tmpl = internal constant [3 x i8] c"%f\00"
@str_0 = internal global [6 x i8] c"Isect\00"
@str_1 = internal global [4 x i8] c"Vec\00"
@str_2 = internal global [6 x i8] c"Plane\00"
@str_3 = internal global [4 x i8] c"Int\00"
@str_4 = internal global [6 x i8] c"Class\00"
@str_5 = internal global [17 x i8] c"Shiika::Internal\00"
@str_6 = internal global [22 x i8] c"Shiika::Internal::Ptr\00"
@str_7 = internal global [6 x i8] c"Float\00"
@str_8 = internal global [7 x i8] c"Object\00"
@str_9 = internal global [25 x i8] c"Shiika::Internal::Memory\00"
@str_10 = internal global [14 x i8] c"MutableString\00"
@str_11 = internal global [5 x i8] c"Math\00"
@str_12 = internal global [6 x i8] c"Never\00"
@str_13 = internal global [7 x i8] c"Sphere\00"
@str_14 = internal global [5 x i8] c"Void\00"
@str_15 = internal global [5 x i8] c"Util\00"
@str_16 = internal global [4 x i8] c"Ray\00"
@str_17 = internal global [7 x i8] c"Shiika\00"
@str_18 = internal global [5 x i8] c"Bool\00"
@str_19 = internal global [7 x i8] c"String\00"
@str_20 = internal global [3 x i8] c"P3\00"
@str_21 = internal global [2 x i8] c" \00"
@str_22 = internal global [1 x i8] zeroinitializer
@str_23 = internal global [4 x i8] c"255\00"
@str_24 = internal global [13 x i8] c"#<Something>\00"
@"::Ray" = internal global %"Meta:Ray"* null
@"::Sphere" = internal global %"Meta:Sphere"* null
@"::IMAGE_WIDTH" = internal global i32 0
@"::EPS" = internal global double 0.000000e+00
@"::Isect" = internal global %"Meta:Isect"* null
@"::MAX_REF" = internal global i32 0
@"::MutableString" = internal global %"Meta:MutableString"* null
@"::IMAGE_HEIGHT" = internal global i32 0
@"::PLANE" = internal global %Plane* null
@"::T" = internal global double 0.000000e+00
@"::Bool" = internal global %"Meta:Bool"* null
@"::LIGHT" = internal global %Vec* null
@"::Int" = internal global %"Meta:Int"* null
@"::Object" = internal global %"Meta:Object"* null
@"::SPHERE1" = internal global %Sphere* null
@"::Util" = internal global %"Meta:Util"* null
@"::Shiika" = internal global %"Meta:Shiika"* null
@"::Shiika::Internal" = internal global %"Meta:Shiika::Internal"* null
@"::Vec" = internal global %"Meta:Vec"* null
@"::Never" = internal global %"Meta:Never"* null
@"::IMAGE_DEPTH" = internal global i32 0
@"::Class" = internal global %"Meta:Class"* null
@"::Math" = internal global %"Meta:Math"* null
@"::SPHERE2" = internal global %Sphere* null
@"::String" = internal global %"Meta:String"* null
@"::Shiika::Internal::Ptr" = internal global %"Meta:Shiika::Internal::Ptr"* null
@"::void" = internal global %Void* null
@"::Shiika::Internal::Memory" = internal global %"Meta:Shiika::Internal::Memory"* null
@"::Void" = internal global %"Meta:Void"* null
@"::Plane" = internal global %"Meta:Plane"* null
@"::SPHERE3" = internal global %Sphere* null
@"::Float" = internal global %"Meta:Float"* null
declare i32 @putchar(i32)
declare i32 @printf(i8*, ...)
declare i32 @puts(i8*)
declare void @GC_init()
declare i8* @GC_malloc(i64)
declare i8* @GC_realloc(i8*, i64)
; Function Attrs: argmemonly nounwind
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #0
declare double @sin(double)
declare double @cos(double)
declare double @sqrt(double)
declare double @fabs(double)
declare double @floor(double)
define void @"Isect#initialize"(%Isect* %self, i32 %hit, %Vec* %hit_point, %Vec* %normal, %Vec* %color, double %distance, %Vec* %ray_dir) {
%"@hit" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 0
store i32 %hit, i32* %"@hit"
%"@hit_point" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 1
store %Vec* %hit_point, %Vec** %"@hit_point"
%"@normal" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 2
store %Vec* %normal, %Vec** %"@normal"
%"@color" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 3
store %Vec* %color, %Vec** %"@color"
%"@distance" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 4
store double %distance, double* %"@distance"
%"@ray_dir" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 5
store %Vec* %ray_dir, %Vec** %"@ray_dir"
ret void
}
define i32 @"Isect#hit"(%Isect* %self) {
%"addr_@hit" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 0
%"@hit" = load i32, i32* %"addr_@hit"
ret i32 %"@hit"
}
define void @"Isect#hit="(%Isect* %self, i32 %v) {
%"@hit" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 0
store i32 %v, i32* %"@hit"
ret void
}
define %Vec* @"Isect#hit_point"(%Isect* %self) {
%"addr_@hit_point" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 1
%"@hit_point" = load %Vec*, %Vec** %"addr_@hit_point"
ret %Vec* %"@hit_point"
}
define void @"Isect#hit_point="(%Isect* %self, %Vec* %v) {
%"@hit_point" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 1
store %Vec* %v, %Vec** %"@hit_point"
ret void
}
define %Vec* @"Isect#normal"(%Isect* %self) {
%"addr_@normal" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 2
%"@normal" = load %Vec*, %Vec** %"addr_@normal"
ret %Vec* %"@normal"
}
define void @"Isect#normal="(%Isect* %self, %Vec* %v) {
%"@normal" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 2
store %Vec* %v, %Vec** %"@normal"
ret void
}
define %Vec* @"Isect#color"(%Isect* %self) {
%"addr_@color" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 3
%"@color" = load %Vec*, %Vec** %"addr_@color"
ret %Vec* %"@color"
}
define void @"Isect#color="(%Isect* %self, %Vec* %v) {
%"@color" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 3
store %Vec* %v, %Vec** %"@color"
ret void
}
define double @"Isect#distance"(%Isect* %self) {
%"addr_@distance" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 4
%"@distance" = load double, double* %"addr_@distance"
ret double %"@distance"
}
define void @"Isect#distance="(%Isect* %self, double %v) {
%"@distance" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 4
store double %v, double* %"@distance"
ret void
}
define %Vec* @"Isect#ray_dir"(%Isect* %self) {
%"addr_@ray_dir" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 5
%"@ray_dir" = load %Vec*, %Vec** %"addr_@ray_dir"
ret %Vec* %"@ray_dir"
}
define void @"Isect#ray_dir="(%Isect* %self, %Vec* %v) {
%"@ray_dir" = getelementptr inbounds %Isect, %Isect* %self, i32 0, i32 5
store %Vec* %v, %Vec** %"@ray_dir"
ret void
}
define void @"MutableString#initialize"(%MutableString* %self, i32 %capa) {
%"::Shiika::Internal::Memory" = load %"Meta:Shiika::Internal::Memory"*, %"Meta:Shiika::Internal::Memory"** @"::Shiika::Internal::Memory"
%result = call i32 @"Int#+"(i32 %capa, i32 1)
%result1 = call i8* @"Meta:Shiika::Internal::Memory#gc_malloc"(%"Meta:Shiika::Internal::Memory"* %"::Shiika::Internal::Memory", i32 %result)
%"@ptr" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 0
store i8* %result1, i8** %"@ptr"
%"@capa" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 1
store i32 %capa, i32* %"@capa"
%"@bytesize" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 2
store i32 0, i32* %"@bytesize"
ret void
}
define i8* @"MutableString#ptr"(%MutableString* %self) {
%"addr_@ptr" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 0
%"@ptr" = load i8*, i8** %"addr_@ptr"
ret i8* %"@ptr"
}
define i32 @"MutableString#bytesize"(%MutableString* %self) {
%"addr_@bytesize" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 2
%"@bytesize" = load i32, i32* %"addr_@bytesize"
ret i32 %"@bytesize"
}
define void @"MutableString#append"(%MutableString* %self, %String* %other) {
%"addr_@bytesize" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 2
%"@bytesize" = load i32, i32* %"addr_@bytesize"
%result = call i32 @"String#bytesize"(%String* %other)
%result1 = call i32 @"Int#+"(i32 %"@bytesize", i32 %result)
%new_bytesize = alloca i32
store i32 %result1, i32* %new_bytesize
%"addr_@capa" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 1
%"@capa" = load i32, i32* %"addr_@capa"
%new_bytesize2 = load i32, i32* %new_bytesize
%result3 = call i1 @"Int#<"(i32 %"@capa", i32 %new_bytesize2)
br i1 %result3, label %IfThen, label %IfEnd
IfThen: ; preds = %0
%"::Shiika::Internal::Memory" = load %"Meta:Shiika::Internal::Memory"*, %"Meta:Shiika::Internal::Memory"** @"::Shiika::Internal::Memory"
%"addr_@ptr" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 0
%"@ptr" = load i8*, i8** %"addr_@ptr"
%new_bytesize4 = load i32, i32* %new_bytesize
%result5 = call i32 @"Int#+"(i32 %new_bytesize4, i32 1)
%result6 = call i8* @"Meta:Shiika::Internal::Memory#gc_realloc"(%"Meta:Shiika::Internal::Memory"* %"::Shiika::Internal::Memory", i8* %"@ptr", i32 %result5)
%"@ptr7" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 0
store i8* %result6, i8** %"@ptr7"
%new_bytesize8 = load i32, i32* %new_bytesize
%"@capa9" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 1
store i32 %new_bytesize8, i32* %"@capa9"
br label %IfEnd
IfEnd: ; preds = %IfThen, %0
%"::Shiika::Internal::Memory10" = load %"Meta:Shiika::Internal::Memory"*, %"Meta:Shiika::Internal::Memory"** @"::Shiika::Internal::Memory"
%"addr_@ptr11" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 0
%"@ptr12" = load i8*, i8** %"addr_@ptr11"
%"addr_@bytesize13" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 2
%"@bytesize14" = load i32, i32* %"addr_@bytesize13"
%result15 = call i8* @"Shiika::Internal::Ptr#+"(i8* %"@ptr12", i32 %"@bytesize14")
%result16 = call i8* @"String#ptr"(%String* %other)
%result17 = call i32 @"String#bytesize"(%String* %other)
call void @"Meta:Shiika::Internal::Memory#memcpy"(%"Meta:Shiika::Internal::Memory"* %"::Shiika::Internal::Memory10", i8* %result15, i8* %result16, i32 %result17)
%"::void" = load %Void*, %Void** @"::void"
%new_bytesize18 = load i32, i32* %new_bytesize
%"@bytesize19" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 2
store i32 %new_bytesize18, i32* %"@bytesize19"
ret void
}
define %String* @"MutableString#to_s"(%MutableString* %self) {
%"::Shiika::Internal::Memory" = load %"Meta:Shiika::Internal::Memory"*, %"Meta:Shiika::Internal::Memory"** @"::Shiika::Internal::Memory"
%"addr_@bytesize" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 2
%"@bytesize" = load i32, i32* %"addr_@bytesize"
%result = call i32 @"Int#+"(i32 %"@bytesize", i32 1)
%result1 = call i8* @"Meta:Shiika::Internal::Memory#gc_malloc"(%"Meta:Shiika::Internal::Memory"* %"::Shiika::Internal::Memory", i32 %result)
%newptr = alloca i8*
store i8* %result1, i8** %newptr
%"::Shiika::Internal::Memory2" = load %"Meta:Shiika::Internal::Memory"*, %"Meta:Shiika::Internal::Memory"** @"::Shiika::Internal::Memory"
%newptr3 = load i8*, i8** %newptr
%"addr_@ptr" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 0
%"@ptr" = load i8*, i8** %"addr_@ptr"
%"addr_@bytesize4" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 2
%"@bytesize5" = load i32, i32* %"addr_@bytesize4"
call void @"Meta:Shiika::Internal::Memory#memcpy"(%"Meta:Shiika::Internal::Memory"* %"::Shiika::Internal::Memory2", i8* %newptr3, i8* %"@ptr", i32 %"@bytesize5")
%"::void" = load %Void*, %Void** @"::void"
%"::String" = load %"Meta:String"*, %"Meta:String"** @"::String"
%newptr6 = load i8*, i8** %newptr
%"addr_@bytesize7" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 2
%"@bytesize8" = load i32, i32* %"addr_@bytesize7"
%result9 = call %String* @"Meta:String#new"(%"Meta:String"* %"::String", i8* %newptr6, i32 %"@bytesize8")
ret %String* %result9
}
define %String* @"MutableString#_unsafe_to_s"(%MutableString* %self) {
%"::String" = load %"Meta:String"*, %"Meta:String"** @"::String"
%"addr_@ptr" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 0
%"@ptr" = load i8*, i8** %"addr_@ptr"
%"addr_@bytesize" = getelementptr inbounds %MutableString, %MutableString* %self, i32 0, i32 2
%"@bytesize" = load i32, i32* %"addr_@bytesize"
%result = call %String* @"Meta:String#new"(%"Meta:String"* %"::String", i8* %"@ptr", i32 %"@bytesize")
ret %String* %result
}
define i32 @"Int#%"(i32 %self, i32 %other) {
br label %IfBegin
IfBegin: ; preds = %0
%result = call i32 @"Int#^"(i32 %self, i32 %other)
%result1 = call i1 @"Int#<="(i32 %result, i32 0)
br i1 %result1, label %IfThen, label %IfElse
IfThen: ; preds = %IfBegin
%result2 = call i32 @"Int#reminder"(i32 %self, i32 %other)
br label %IfEnd
IfElse: ; preds = %IfBegin
%result3 = call i32 @"Int#reminder"(i32 %self, i32 %other)
%me = alloca i32
store i32 %result3, i32* %me
br label %IfBegin4
IfEnd: ; preds = %IfEnd7, %IfThen
%ifResult13 = phi i32 [ %result2, %IfThen ], [ %ifResult, %IfEnd7 ]
ret i32 %ifResult13
IfBegin4: ; preds = %IfElse
%me8 = load i32, i32* %me
%result9 = call i1 @"Int#=="(i32 %me8, i32 0)
br i1 %result9, label %IfThen5, label %IfElse6
IfThen5: ; preds = %IfBegin4
%me10 = load i32, i32* %me
br label %IfEnd7
IfElse6: ; preds = %IfBegin4
%me11 = load i32, i32* %me
%result12 = call i32 @"Int#+"(i32 %me11, i32 %other)
br label %IfEnd7
IfEnd7: ; preds = %IfElse6, %IfThen5
%ifResult = phi i32 [ %me10, %IfThen5 ], [ %result12, %IfElse6 ]
br label %IfEnd
}
define i32 @"Int#to_i"(i32 %self) {
ret i32 %self
}
define i1 @"Int#=="(i32 %self, i32 %other) {
%eq = icmp eq i32 %self, %other
ret i1 %eq
}
define i1 @"Int#!="(i32 %self, i32 %other) {
%neq = icmp ne i32 %self, %other
ret i1 %neq
}
define i1 @"Int#<"(i32 %self, i32 %other) {
%lt = icmp slt i32 %self, %other
ret i1 %lt
}
define i1 @"Int#>"(i32 %self, i32 %other) {
%gt = icmp sgt i32 %self, %other
ret i1 %gt
}
define i1 @"Int#<="(i32 %self, i32 %other) {
%leq = icmp sle i32 %self, %other
ret i1 %leq
}
define i1 @"Int#>="(i32 %self, i32 %other) {
%geq = icmp sge i32 %self, %other
ret i1 %geq
}
define i32 @"Int#+"(i32 %self, i32 %other) {
%add = add i32 %self, %other
ret i32 %add
}
define i32 @"Int#-"(i32 %self, i32 %other) {
%sub = sub i32 %self, %other
ret i32 %sub
}
define i32 @"Int#*"(i32 %self, i32 %other) {
%mul = mul i32 %self, %other
ret i32 %mul
}
define i32 @"Int#/"(i32 %self, i32 %other) {
%div = sdiv i32 %self, %other
ret i32 %div
; No predecessors!
%div1 = sdiv i32 %self, %other
ret i32 %div1
}
declare i32 @"Int#/.1"(i32, i32)
define i32 @"Int#reminder"(i32 %self, i32 %other) {
%rem = srem i32 %self, %other
ret i32 %rem
}
define i32 @"Int#&"(i32 %self, i32 %other) {
%and = and i32 %self, %other
ret i32 %and
}
define i32 @"Int#|"(i32 %self, i32 %other) {
%or = or i32 %self, %other
ret i32 %or
}
define i32 @"Int#^"(i32 %self, i32 %other) {
%xor = xor i32 %self, %other
ret i32 %xor
}
define i32 @"Int#<<"(i32 %self, i32 %other) {
%lshift = shl i32 %self, %other
ret i32 %lshift
}
define i32 @"Int#>>"(i32 %self, i32 %other) {
%rshift = ashr i32 %self, %other
ret i32 %rshift
}
define double @"Int#to_f"(i32 %self) {
%float = sitofp i32 %self to double
ret double %float
}
define i32 @"Int#-@"(i32 %self) {
%result = sub i32 0, %self
ret i32 %result
}
define void @"Ray#initialize"(%Ray* %self, %Vec* %origin, %Vec* %dir) {
%"@origin" = getelementptr inbounds %Ray, %Ray* %self, i32 0, i32 0
store %Vec* %origin, %Vec** %"@origin"
%"@dir" = getelementptr inbounds %Ray, %Ray* %self, i32 0, i32 1
store %Vec* %dir, %Vec** %"@dir"
ret void
}
define %Vec* @"Ray#origin"(%Ray* %self) {
%"addr_@origin" = getelementptr inbounds %Ray, %Ray* %self, i32 0, i32 0
%"@origin" = load %Vec*, %Vec** %"addr_@origin"
ret %Vec* %"@origin"
}
define %Vec* @"Ray#dir"(%Ray* %self) {
%"addr_@dir" = getelementptr inbounds %Ray, %Ray* %self, i32 0, i32 1
%"@dir" = load %Vec*, %Vec** %"addr_@dir"
ret %Vec* %"@dir"
}
define %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %self, double %x, double %y, double %z) {
%mem = call i8* @GC_malloc(i64 mul nuw (i64 ptrtoint (double* getelementptr (double, double* null, i32 1) to i64), i64 3))
%addr = bitcast i8* %mem to %Vec*
call void @"Vec#initialize"(%Vec* %addr, double %x, double %y, double %z)
ret %Vec* %addr
}
define void @"Plane#initialize"(%Plane* %self, %Vec* %position, %Vec* %normal, %Vec* %color) {
%"@position" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 0
store %Vec* %position, %Vec** %"@position"
%"@normal" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 1
store %Vec* %normal, %Vec** %"@normal"
%"@color" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 2
store %Vec* %color, %Vec** %"@color"
ret void
}
define %Vec* @"Plane#position"(%Plane* %self) {
%"addr_@position" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 0
%"@position" = load %Vec*, %Vec** %"addr_@position"
ret %Vec* %"@position"
}
define %Vec* @"Plane#normal"(%Plane* %self) {
%"addr_@normal" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 1
%"@normal" = load %Vec*, %Vec** %"addr_@normal"
ret %Vec* %"@normal"
}
define %Vec* @"Plane#color"(%Plane* %self) {
%"addr_@color" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 2
%"@color" = load %Vec*, %Vec** %"addr_@color"
ret %Vec* %"@color"
}
define void @"Plane#intersect"(%Plane* %self, %Ray* %ray, %Isect* %isect) {
%"addr_@position" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 0
%"@position" = load %Vec*, %Vec** %"addr_@position"
%"addr_@normal" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 1
%"@normal" = load %Vec*, %Vec** %"addr_@normal"
%result = call double @"Vec#dot"(%Vec* %"@position", %Vec* %"@normal")
%result1 = call double @"Float#-@"(double %result)
%d = alloca double
store double %result1, double* %d
%result2 = call %Vec* @"Ray#dir"(%Ray* %ray)
%"addr_@normal3" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 1
%"@normal4" = load %Vec*, %Vec** %"addr_@normal3"
%result5 = call double @"Vec#dot"(%Vec* %result2, %Vec* %"@normal4")
%v = alloca double
store double %result5, double* %v
%result6 = call %Vec* @"Ray#origin"(%Ray* %ray)
%"addr_@normal7" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 1
%"@normal8" = load %Vec*, %Vec** %"addr_@normal7"
%result9 = call double @"Vec#dot"(%Vec* %result6, %Vec* %"@normal8")
%d10 = load double, double* %d
%result11 = call double @"Float#+"(double %result9, double %d10)
%result12 = call double @"Float#-@"(double %result11)
%v13 = load double, double* %v
%result14 = call double @"Float#/"(double %result12, double %v13)
%t = alloca double
store double %result14, double* %t
br label %AndBegin
AndBegin: ; preds = %0
%t15 = load double, double* %t
%"::EPS" = load double, double* @"::EPS"
%result16 = call i1 @"Float#>"(double %t15, double %"::EPS")
br i1 %result16, label %AndMore, label %AndEnd
AndMore: ; preds = %AndBegin
%t17 = load double, double* %t
%result18 = call double @"Isect#distance"(%Isect* %isect)
%result19 = call i1 @"Float#<"(double %t17, double %result18)
br label %AndEnd
AndEnd: ; preds = %AndMore, %AndBegin
%AndResult = phi i1 [ %result16, %AndBegin ], [ %result19, %AndMore ]
br i1 %AndResult, label %IfThen, label %IfEnd
IfThen: ; preds = %AndEnd
%result20 = call %Vec* @"Ray#origin"(%Ray* %ray)
%result21 = call %Vec* @"Ray#dir"(%Ray* %ray)
%t22 = load double, double* %t
%result23 = call %Vec* @"Vec#mul"(%Vec* %result21, double %t22)
%result24 = call %Vec* @"Vec#add"(%Vec* %result20, %Vec* %result23)
call void @"Isect#hit_point="(%Isect* %isect, %Vec* %result24)
%"::void" = load %Void*, %Void** @"::void"
%"addr_@normal25" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 1
%"@normal26" = load %Vec*, %Vec** %"addr_@normal25"
call void @"Isect#normal="(%Isect* %isect, %Vec* %"@normal26")
%"::void27" = load %Void*, %Void** @"::void"
%"::Util" = load %"Meta:Util"*, %"Meta:Util"** @"::Util"
%"::LIGHT" = load %Vec*, %Vec** @"::LIGHT"
%result28 = call %Vec* @"Isect#normal"(%Isect* %isect)
%result29 = call double @"Vec#dot"(%Vec* %"::LIGHT", %Vec* %result28)
%result30 = call double @"Meta:Util#clamp"(%"Meta:Util"* %"::Util", double %result29, double 1.000000e-01, double 1.000000e+00)
%d2 = alloca double
store double %result30, double* %d2
%result31 = call %Vec* @"Isect#hit_point"(%Isect* %isect)
%result32 = call double @"Vec#x"(%Vec* %result31)
%result33 = call double @"Float#%"(double %result32, i32 2)
%m = alloca double
store double %result33, double* %m
%result34 = call %Vec* @"Isect#hit_point"(%Isect* %isect)
%result35 = call double @"Vec#z"(%Vec* %result34)
%result36 = call double @"Float#%"(double %result35, i32 2)
%n = alloca double
store double %result36, double* %n
br label %IfBegin
IfEnd: ; preds = %IfEnd64, %AndEnd
ret void
IfBegin: ; preds = %IfThen
br label %OrBegin
IfThen37: ; preds = %OrEnd
%d255 = load double, double* %d2
%result56 = call double @"Float#*"(double %d255, double 5.000000e-01)
br label %IfEnd38
IfElse: ; preds = %OrEnd
%d257 = load double, double* %d2
br label %IfEnd38
IfEnd38: ; preds = %IfElse, %IfThen37
%ifResult = phi double [ %result56, %IfThen37 ], [ %d257, %IfElse ]
%d3 = alloca double
store double %ifResult, double* %d3
%result58 = call %Vec* @"Isect#hit_point"(%Isect* %isect)
%result59 = call double @"Vec#z"(%Vec* %result58)
%result60 = call double @"Float#abs"(double %result59)
%abs = alloca double
store double %result60, double* %abs
br label %IfBegin61
OrBegin: ; preds = %IfBegin
br label %AndBegin39
OrElse: ; preds = %AndEnd41
br label %AndBegin47
OrEnd: ; preds = %AndEnd49, %AndEnd41
%OrResult = phi i1 [ %AndResult46, %AndEnd41 ], [ %AndResult54, %AndEnd49 ]
br i1 %OrResult, label %IfThen37, label %IfElse
AndBegin39: ; preds = %OrBegin
%m42 = load double, double* %m
%result43 = call i1 @"Float#>"(double %m42, double 1.000000e+00)
br i1 %result43, label %AndMore40, label %AndEnd41
AndMore40: ; preds = %AndBegin39
%n44 = load double, double* %n
%result45 = call i1 @"Float#>"(double %n44, double 1.000000e+00)
br label %AndEnd41
AndEnd41: ; preds = %AndMore40, %AndBegin39
%AndResult46 = phi i1 [ %result43, %AndBegin39 ], [ %result45, %AndMore40 ]
br i1 %AndResult46, label %OrEnd, label %OrElse
AndBegin47: ; preds = %OrElse
%m50 = load double, double* %m
%result51 = call i1 @"Float#<"(double %m50, double 1.000000e+00)
br i1 %result51, label %AndMore48, label %AndEnd49
AndMore48: ; preds = %AndBegin47
%n52 = load double, double* %n
%result53 = call i1 @"Float#<"(double %n52, double 1.000000e+00)
br label %AndEnd49
AndEnd49: ; preds = %AndMore48, %AndBegin47
%AndResult54 = phi i1 [ %result51, %AndBegin47 ], [ %result53, %AndMore48 ]
br label %OrEnd
IfBegin61: ; preds = %IfEnd38
%abs65 = load double, double* %abs
%result66 = call i1 @"Float#<"(double %abs65, double 2.500000e+01)
br i1 %result66, label %IfThen62, label %IfElse63
IfThen62: ; preds = %IfBegin61
%abs67 = load double, double* %abs
br label %IfEnd64
IfElse63: ; preds = %IfBegin61
br label %IfEnd64
IfEnd64: ; preds = %IfElse63, %IfThen62
%ifResult68 = phi double [ %abs67, %IfThen62 ], [ 2.500000e+01, %IfElse63 ]
%result69 = call double @"Float#*"(double %ifResult68, double 4.000000e-02)
%result70 = call double @"Float#-"(double 1.000000e+00, double %result69)
%f = alloca double
store double %result70, double* %f
%"addr_@color" = getelementptr inbounds %Plane, %Plane* %self, i32 0, i32 2
%"@color" = load %Vec*, %Vec** %"addr_@color"
%d371 = load double, double* %d3
%f72 = load double, double* %f
%result73 = call double @"Float#*"(double %d371, double %f72)
%result74 = call %Vec* @"Vec#mul"(%Vec* %"@color", double %result73)
call void @"Isect#color="(%Isect* %isect, %Vec* %result74)
%"::void75" = load %Void*, %Void** @"::void"
%t76 = load double, double* %t
call void @"Isect#distance="(%Isect* %isect, double %t76)
%"::void77" = load %Void*, %Void** @"::void"
%result78 = call i32 @"Isect#hit"(%Isect* %isect)
%result79 = call i32 @"Int#+"(i32 %result78, i32 1)
call void @"Isect#hit="(%Isect* %isect, i32 %result79)
%"::void80" = load %Void*, %Void** @"::void"
%result81 = call %Vec* @"Ray#dir"(%Ray* %ray)
call void @"Isect#ray_dir="(%Isect* %isect, %Vec* %result81)
%"::void82" = load %Void*, %Void** @"::void"
br label %IfEnd
}
define %Class* @"Meta:Class#new"(%"Meta:Class"* %self, %String* %name) {
%mem = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%addr = bitcast i8* %mem to %Class*
call void @"Class#initialize"(%Class* %addr, %String* %name)
ret %Class* %addr
}
define i8* @"Meta:Shiika::Internal::Memory#gc_malloc"(%"Meta:Shiika::Internal::Memory"* %self, i32 %n_bytes) {
%n_bytes_64 = zext i32 %n_bytes to i64
%mem = call i8* @GC_malloc(i64 %n_bytes_64)
ret i8* %mem
}
define i8* @"Meta:Shiika::Internal::Memory#gc_realloc"(%"Meta:Shiika::Internal::Memory"* %self, i8* %ptr, i32 %n_bytes) {
%n_bytes_64 = zext i32 %n_bytes to i64
%mem = call i8* @GC_realloc(i8* %ptr, i64 %n_bytes_64)
ret i8* %mem
}
define void @"Meta:Shiika::Internal::Memory#memcpy"(%"Meta:Shiika::Internal::Memory"* %self, i8* %dst, i8* %src, i32 %n_bytes) {
%n_bytes_64 = zext i32 %n_bytes to i64
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 %n_bytes_64, i32 0, i1 false)
ret void
}
define %String* @"Object#inspect"(%Object* %self) {
%mem = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str = bitcast i8* %mem to %String*
%"addr_@ptr" = getelementptr inbounds %String, %String* %str, i32 0, i32 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str_24, i32 0, i32 0), i8** %"addr_@ptr"
%"addr_@bytesize" = getelementptr inbounds %String, %String* %str, i32 0, i32 1
store i32 12, i32* %"addr_@bytesize"
ret %String* %str
}
define void @"Object#initialize"(%Object* %self) {
ret void
}
define void @"Object#putchar"(%Object* %self, i32 %ord) {
%1 = call i32 @putchar(i32 %ord)
ret void
}
define void @"Object#putd"(%Object* %self, i32 %n) {
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @putd_tmpl, i32 0, i32 0), i32 %n)
ret void
}
define void @"Object#putf"(%Object* %self, double %n) {
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @putf_tmpl, i32 0, i32 0), double %n)
ret void
}
define void @"Object#puts"(%Object* %self, %String* %s) {
%1 = getelementptr inbounds %String, %String* %s, i32 0, i32 0
%2 = load i8*, i8** %1
%3 = call i32 @puts(i8* %2)
ret void
}
define void @"Vec#initialize"(%Vec* %self, double %x, double %y, double %z) {
%"@x" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
store double %x, double* %"@x"
%"@y" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
store double %y, double* %"@y"
%"@z" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
store double %z, double* %"@z"
ret void
}
define double @"Vec#x"(%Vec* %self) {
%"addr_@x" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x" = load double, double* %"addr_@x"
ret double %"@x"
}
define double @"Vec#y"(%Vec* %self) {
%"addr_@y" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y" = load double, double* %"addr_@y"
ret double %"@y"
}
define double @"Vec#z"(%Vec* %self) {
%"addr_@z" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z" = load double, double* %"addr_@z"
ret double %"@z"
}
define %Vec* @"Vec#add"(%Vec* %self, %Vec* %b) {
%"::Vec" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%"addr_@x" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x" = load double, double* %"addr_@x"
%result = call double @"Vec#x"(%Vec* %b)
%result1 = call double @"Float#+"(double %"@x", double %result)
%"addr_@y" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y" = load double, double* %"addr_@y"
%result2 = call double @"Vec#y"(%Vec* %b)
%result3 = call double @"Float#+"(double %"@y", double %result2)
%"addr_@z" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z" = load double, double* %"addr_@z"
%result4 = call double @"Vec#z"(%Vec* %b)
%result5 = call double @"Float#+"(double %"@z", double %result4)
%result6 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec", double %result1, double %result3, double %result5)
ret %Vec* %result6
}
define %Vec* @"Vec#sub"(%Vec* %self, %Vec* %b) {
%"::Vec" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%"addr_@x" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x" = load double, double* %"addr_@x"
%result = call double @"Vec#x"(%Vec* %b)
%result1 = call double @"Float#-"(double %"@x", double %result)
%"addr_@y" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y" = load double, double* %"addr_@y"
%result2 = call double @"Vec#y"(%Vec* %b)
%result3 = call double @"Float#-"(double %"@y", double %result2)
%"addr_@z" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z" = load double, double* %"addr_@z"
%result4 = call double @"Vec#z"(%Vec* %b)
%result5 = call double @"Float#-"(double %"@z", double %result4)
%result6 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec", double %result1, double %result3, double %result5)
ret %Vec* %result6
}
define %Vec* @"Vec#mul"(%Vec* %self, double %t) {
%"::Vec" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%"addr_@x" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x" = load double, double* %"addr_@x"
%result = call double @"Float#*"(double %"@x", double %t)
%"addr_@y" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y" = load double, double* %"addr_@y"
%result1 = call double @"Float#*"(double %"@y", double %t)
%"addr_@z" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z" = load double, double* %"addr_@z"
%result2 = call double @"Float#*"(double %"@z", double %t)
%result3 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec", double %result, double %result1, double %result2)
ret %Vec* %result3
}
define %Vec* @"Vec#multi"(%Vec* %self, %Vec* %b) {
%"::Vec" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%"addr_@x" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x" = load double, double* %"addr_@x"
%result = call double @"Vec#x"(%Vec* %b)
%result1 = call double @"Float#*"(double %"@x", double %result)
%"addr_@y" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y" = load double, double* %"addr_@y"
%result2 = call double @"Vec#y"(%Vec* %b)
%result3 = call double @"Float#*"(double %"@y", double %result2)
%"addr_@z" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z" = load double, double* %"addr_@z"
%result4 = call double @"Vec#z"(%Vec* %b)
%result5 = call double @"Float#*"(double %"@z", double %result4)
%result6 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec", double %result1, double %result3, double %result5)
ret %Vec* %result6
}
define double @"Vec#dot"(%Vec* %self, %Vec* %b) {
%"addr_@x" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x" = load double, double* %"addr_@x"
%result = call double @"Vec#x"(%Vec* %b)
%result1 = call double @"Float#*"(double %"@x", double %result)
%"addr_@y" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y" = load double, double* %"addr_@y"
%result2 = call double @"Vec#y"(%Vec* %b)
%result3 = call double @"Float#*"(double %"@y", double %result2)
%result4 = call double @"Float#+"(double %result1, double %result3)
%"addr_@z" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z" = load double, double* %"addr_@z"
%result5 = call double @"Vec#z"(%Vec* %b)
%result6 = call double @"Float#*"(double %"@z", double %result5)
%result7 = call double @"Float#+"(double %result4, double %result6)
ret double %result7
}
define %Vec* @"Vec#cross"(%Vec* %self, %Vec* %b) {
%"::Vec" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%"addr_@y" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y" = load double, double* %"addr_@y"
%result = call double @"Vec#z"(%Vec* %b)
%result1 = call double @"Float#*"(double %"@y", double %result)
%"addr_@z" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z" = load double, double* %"addr_@z"
%result2 = call double @"Vec#y"(%Vec* %b)
%result3 = call double @"Float#*"(double %"@z", double %result2)
%result4 = call double @"Float#-"(double %result1, double %result3)
%"addr_@z5" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z6" = load double, double* %"addr_@z5"
%result7 = call double @"Vec#x"(%Vec* %b)
%result8 = call double @"Float#*"(double %"@z6", double %result7)
%"addr_@x" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x" = load double, double* %"addr_@x"
%result9 = call double @"Vec#z"(%Vec* %b)
%result10 = call double @"Float#*"(double %"@x", double %result9)
%result11 = call double @"Float#-"(double %result8, double %result10)
%"addr_@x12" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x13" = load double, double* %"addr_@x12"
%result14 = call double @"Vec#y"(%Vec* %b)
%result15 = call double @"Float#*"(double %"@x13", double %result14)
%"addr_@y16" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y17" = load double, double* %"addr_@y16"
%result18 = call double @"Vec#x"(%Vec* %b)
%result19 = call double @"Float#*"(double %"@y17", double %result18)
%result20 = call double @"Float#-"(double %result15, double %result19)
%result21 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec", double %result4, double %result11, double %result20)
ret %Vec* %result21
}
define double @"Vec#length"(%Vec* %self) {
%"::Math" = load %"Meta:Math"*, %"Meta:Math"** @"::Math"
%"addr_@x" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x" = load double, double* %"addr_@x"
%"addr_@x1" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x2" = load double, double* %"addr_@x1"
%result = call double @"Float#*"(double %"@x", double %"@x2")
%"addr_@y" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y" = load double, double* %"addr_@y"
%"addr_@y3" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y4" = load double, double* %"addr_@y3"
%result5 = call double @"Float#*"(double %"@y", double %"@y4")
%result6 = call double @"Float#+"(double %result, double %result5)
%"addr_@z" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z" = load double, double* %"addr_@z"
%"addr_@z7" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z8" = load double, double* %"addr_@z7"
%result9 = call double @"Float#*"(double %"@z", double %"@z8")
%result10 = call double @"Float#+"(double %result6, double %result9)
%result11 = call double @"Meta:Math#sqrt"(%"Meta:Math"* %"::Math", double %result10)
ret double %result11
}
define %Vec* @"Vec#normalize"(%Vec* %self) {
%result = call double @"Vec#length"(%Vec* %self)
%len = alloca double
store double %result, double* %len
%len1 = load double, double* %len
%result2 = call i1 @"Float#>"(double %len1, double 1.000000e-17)
br i1 %result2, label %IfThen, label %IfEnd
IfThen: ; preds = %0
%len3 = load double, double* %len
%result4 = call double @"Float#/"(double 1.000000e+00, double %len3)
%r_len = alloca double
store double %result4, double* %r_len
%"addr_@x" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
%"@x" = load double, double* %"addr_@x"
%r_len5 = load double, double* %r_len
%result6 = call double @"Float#*"(double %"@x", double %r_len5)
%"@x7" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 0
store double %result6, double* %"@x7"
%"addr_@y" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
%"@y" = load double, double* %"addr_@y"
%r_len8 = load double, double* %r_len
%result9 = call double @"Float#*"(double %"@y", double %r_len8)
%"@y10" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 1
store double %result9, double* %"@y10"
%"addr_@z" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
%"@z" = load double, double* %"addr_@z"
%r_len11 = load double, double* %r_len
%result12 = call double @"Float#*"(double %"@z", double %r_len11)
%"@z13" = getelementptr inbounds %Vec, %Vec* %self, i32 0, i32 2
store double %result12, double* %"@z13"
br label %IfEnd
IfEnd: ; preds = %IfThen, %0
ret %Vec* %self
}
define %Vec* @"Vec#reflect"(%Vec* %self, %Vec* %normal) {
%result = call double @"Float#-@"(double 2.000000e+00)
%result1 = call double @"Vec#dot"(%Vec* %normal, %Vec* %self)
%result2 = call double @"Float#*"(double %result, double %result1)
%result3 = call %Vec* @"Vec#mul"(%Vec* %normal, double %result2)
%result4 = call %Vec* @"Vec#add"(%Vec* %self, %Vec* %result3)
ret %Vec* %result4
}
define %Plane* @"Meta:Plane#new"(%"Meta:Plane"* %self, %Vec* %position, %Vec* %normal, %Vec* %color) {
%mem = call i8* @GC_malloc(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 3))
%addr = bitcast i8* %mem to %Plane*
call void @"Plane#initialize"(%Plane* %addr, %Vec* %position, %Vec* %normal, %Vec* %color)
ret %Plane* %addr
}
define void @"Class#initialize"(%Class* %self, %String* %name) {
%"@name" = getelementptr inbounds %Class, %Class* %self, i32 0, i32 0
store %String* %name, %String** %"@name"
ret void
}
define %String* @"Class#name"(%Class* %self) {
%"addr_@name" = getelementptr inbounds %Class, %Class* %self, i32 0, i32 0
%"@name" = load %String*, %String** %"addr_@name"
ret %String* %"@name"
}
define double @"Float#%"(double %self, i32 %other) {
%result = call double @"Int#to_f"(i32 %other)
%result1 = call double @"Int#to_f"(i32 %other)
%result2 = call double @"Float#/"(double %self, double %result1)
%result3 = call double @"Float#floor"(double %result2)
%result4 = call double @"Float#*"(double %result, double %result3)
%result5 = call double @"Float#-"(double %self, double %result4)
ret double %result5
}
define i1 @"Float#=="(double %self, double %other) {
%eq = fcmp oeq double %self, %other
ret i1 %eq
}
define i1 @"Float#!="(double %self, double %other) {
%neq = fcmp une double %self, %other
ret i1 %neq
}
define i1 @"Float#<"(double %self, double %other) {
%lt = fcmp olt double %self, %other
ret i1 %lt
}
define i1 @"Float#>"(double %self, double %other) {
%gt = fcmp ogt double %self, %other
ret i1 %gt
}
define i1 @"Float#<="(double %self, double %other) {
%leq = fcmp ole double %self, %other
ret i1 %leq
}
define i1 @"Float#>="(double %self, double %other) {
%geq = fcmp oge double %self, %other
ret i1 %geq
}
define double @"Float#+"(double %self, double %other) {
%add = fadd double %self, %other
ret double %add
}
define double @"Float#-"(double %self, double %other) {
%sub = fsub double %self, %other
ret double %sub
}
define double @"Float#*"(double %self, double %other) {
%mul = fmul double %self, %other
ret double %mul
}
define double @"Float#/"(double %self, double %other) {
%div = fdiv double %self, %other
ret double %div
}
define double @"Float#abs"(double %self) {
%result = call double @fabs(double %self)
ret double %result
}
define double @"Float#floor"(double %self) {
%result = call double @floor(double %self)
ret double %result
}
define i32 @"Float#to_i"(double %self) {
%int = fptosi double %self to i32
ret i32 %int
}
define double @"Float#-@"(double %self) {
%result = fsub double 0.000000e+00, %self
ret double %result
}
define i8* @"Shiika::Internal::Ptr#+"(i8* %self, i32 %n_bytes) {
%newptr = getelementptr i8, i8* %self, i32 %n_bytes
ret i8* %newptr
}
define double @"Meta:Math#sin"(%"Meta:Math"* %self, double %x) {
%result = call double @sin(double %x)
ret double %result
}
define double @"Meta:Math#cos"(%"Meta:Math"* %self, double %x) {
%result = call double @cos(double %x)
ret double %result
}
define double @"Meta:Math#sqrt"(%"Meta:Math"* %self, double %x) {
%result = call double @sqrt(double %x)
ret double %result
}
define %Isect* @"Meta:Isect#new"(%"Meta:Isect"* %self, i32 %hit, %Vec* %hit_point, %Vec* %normal, %Vec* %color, double %distance, %Vec* %ray_dir) {
%mem = call i8* @GC_malloc(i64 ptrtoint (%Isect* getelementptr (%Isect, %Isect* null, i32 1) to i64))
%addr = bitcast i8* %mem to %Isect*
call void @"Isect#initialize"(%Isect* %addr, i32 %hit, %Vec* %hit_point, %Vec* %normal, %Vec* %color, double %distance, %Vec* %ray_dir)
ret %Isect* %addr
}
define void @"String#initialize"(%String* %self, i8* %ptr, i32 %bytesize) {
%"@ptr" = getelementptr inbounds %String, %String* %self, i32 0, i32 0
store i8* %ptr, i8** %"@ptr"
%"@bytesize" = getelementptr inbounds %String, %String* %self, i32 0, i32 1
store i32 %bytesize, i32* %"@bytesize"
ret void
}
define i8* @"String#ptr"(%String* %self) {
%"addr_@ptr" = getelementptr inbounds %String, %String* %self, i32 0, i32 0
%"@ptr" = load i8*, i8** %"addr_@ptr"
ret i8* %"@ptr"
}
define i32 @"String#bytesize"(%String* %self) {
%"addr_@bytesize" = getelementptr inbounds %String, %String* %self, i32 0, i32 1
%"@bytesize" = load i32, i32* %"addr_@bytesize"
ret i32 %"@bytesize"
}
define %String* @"String#+"(%String* %self, %String* %other) {
%"::MutableString" = load %"Meta:MutableString"*, %"Meta:MutableString"** @"::MutableString"
%result = call i32 @"String#bytesize"(%String* %self)
%result1 = call i32 @"String#bytesize"(%String* %other)
%result2 = call i32 @"Int#+"(i32 %result, i32 %result1)
%result3 = call %MutableString* @"Meta:MutableString#new"(%"Meta:MutableString"* %"::MutableString", i32 %result2)
%ret = alloca %MutableString*
store %MutableString* %result3, %MutableString** %ret
%ret4 = load %MutableString*, %MutableString** %ret
call void @"MutableString#append"(%MutableString* %ret4, %String* %self)
%"::void" = load %Void*, %Void** @"::void"
%ret5 = load %MutableString*, %MutableString** %ret
call void @"MutableString#append"(%MutableString* %ret5, %String* %other)
%"::void6" = load %Void*, %Void** @"::void"
%ret7 = load %MutableString*, %MutableString** %ret
%result8 = call %String* @"MutableString#_unsafe_to_s"(%MutableString* %ret7)
ret %String* %result8
}
define %String* @"String#to_s"(%String* %self) {
ret %String* %self
}
define %Ray* @"Meta:Ray#new"(%"Meta:Ray"* %self, %Vec* %origin, %Vec* %dir) {
%mem = call i8* @GC_malloc(i64 mul nuw (i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64), i64 2))
%addr = bitcast i8* %mem to %Ray*
call void @"Ray#initialize"(%Ray* %addr, %Vec* %origin, %Vec* %dir)
ret %Ray* %addr
}
define %String* @"Meta:String#new"(%"Meta:String"* %self, i8* %ptr, i32 %bytesize) {
%mem = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%addr = bitcast i8* %mem to %String*
call void @"String#initialize"(%String* %addr, i8* %ptr, i32 %bytesize)
ret %String* %addr
}
define %MutableString* @"Meta:MutableString#new"(%"Meta:MutableString"* %self, i32 %capa) {
%mem = call i8* @GC_malloc(i64 ptrtoint (%MutableString* getelementptr (%MutableString, %MutableString* null, i32 1) to i64))
%addr = bitcast i8* %mem to %MutableString*
call void @"MutableString#initialize"(%MutableString* %addr, i32 %capa)
ret %MutableString* %addr
}
define %Sphere* @"Meta:Sphere#new"(%"Meta:Sphere"* %self, double %radius, %Vec* %position, %Vec* %color) {
%mem = call i8* @GC_malloc(i64 ptrtoint (%Sphere* getelementptr (%Sphere, %Sphere* null, i32 1) to i64))
%addr = bitcast i8* %mem to %Sphere*
call void @"Sphere#initialize"(%Sphere* %addr, double %radius, %Vec* %position, %Vec* %color)
ret %Sphere* %addr
}
define void @"Sphere#initialize"(%Sphere* %self, double %radius, %Vec* %position, %Vec* %color) {
%"@radius" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 0
store double %radius, double* %"@radius"
%"@position" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 1
store %Vec* %position, %Vec** %"@position"
%"@color" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 2
store %Vec* %color, %Vec** %"@color"
ret void
}
define double @"Sphere#radius"(%Sphere* %self) {
%"addr_@radius" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 0
%"@radius" = load double, double* %"addr_@radius"
ret double %"@radius"
}
define %Vec* @"Sphere#position"(%Sphere* %self) {
%"addr_@position" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 1
%"@position" = load %Vec*, %Vec** %"addr_@position"
ret %Vec* %"@position"
}
define %Vec* @"Sphere#color"(%Sphere* %self) {
%"addr_@color" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 2
%"@color" = load %Vec*, %Vec** %"addr_@color"
ret %Vec* %"@color"
}
define void @"Sphere#intersect"(%Sphere* %self, %Ray* %ray, %Isect* %isect) {
%result = call %Vec* @"Ray#origin"(%Ray* %ray)
%"addr_@position" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 1
%"@position" = load %Vec*, %Vec** %"addr_@position"
%result1 = call %Vec* @"Vec#sub"(%Vec* %result, %Vec* %"@position")
%rs = alloca %Vec*
store %Vec* %result1, %Vec** %rs
%rs2 = load %Vec*, %Vec** %rs
%result3 = call %Vec* @"Ray#dir"(%Ray* %ray)
%result4 = call double @"Vec#dot"(%Vec* %rs2, %Vec* %result3)
%b = alloca double
store double %result4, double* %b
%rs5 = load %Vec*, %Vec** %rs
%rs6 = load %Vec*, %Vec** %rs
%result7 = call double @"Vec#dot"(%Vec* %rs5, %Vec* %rs6)
%"addr_@radius" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 0
%"@radius" = load double, double* %"addr_@radius"
%"addr_@radius8" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 0
%"@radius9" = load double, double* %"addr_@radius8"
%result10 = call double @"Float#*"(double %"@radius", double %"@radius9")
%result11 = call double @"Float#-"(double %result7, double %result10)
%c = alloca double
store double %result11, double* %c
%b12 = load double, double* %b
%b13 = load double, double* %b
%result14 = call double @"Float#*"(double %b12, double %b13)
%c15 = load double, double* %c
%result16 = call double @"Float#-"(double %result14, double %c15)
%d = alloca double
store double %result16, double* %d
%b17 = load double, double* %b
%result18 = call double @"Float#-@"(double %b17)
%"::Math" = load %"Meta:Math"*, %"Meta:Math"** @"::Math"
%d19 = load double, double* %d
%result20 = call double @"Meta:Math#sqrt"(%"Meta:Math"* %"::Math", double %d19)
%result21 = call double @"Float#-"(double %result18, double %result20)
%t = alloca double
store double %result21, double* %t
br label %AndBegin
AndBegin: ; preds = %0
br label %AndBegin22
AndMore: ; preds = %AndEnd24
%t29 = load double, double* %t
%result30 = call double @"Isect#distance"(%Isect* %isect)
%result31 = call i1 @"Float#<"(double %t29, double %result30)
br label %AndEnd
AndEnd: ; preds = %AndMore, %AndEnd24
%AndResult32 = phi i1 [ %AndResult, %AndEnd24 ], [ %result31, %AndMore ]
br i1 %AndResult32, label %IfThen, label %IfEnd
AndBegin22: ; preds = %AndBegin
%d25 = load double, double* %d
%result26 = call i1 @"Float#>"(double %d25, double 0.000000e+00)
br i1 %result26, label %AndMore23, label %AndEnd24
AndMore23: ; preds = %AndBegin22
%t27 = load double, double* %t
%"::EPS" = load double, double* @"::EPS"
%result28 = call i1 @"Float#>"(double %t27, double %"::EPS")
br label %AndEnd24
AndEnd24: ; preds = %AndMore23, %AndBegin22
%AndResult = phi i1 [ %result26, %AndBegin22 ], [ %result28, %AndMore23 ]
br i1 %AndResult, label %AndMore, label %AndEnd
IfThen: ; preds = %AndEnd
%result33 = call %Vec* @"Ray#origin"(%Ray* %ray)
%result34 = call %Vec* @"Ray#dir"(%Ray* %ray)
%t35 = load double, double* %t
%result36 = call %Vec* @"Vec#mul"(%Vec* %result34, double %t35)
%result37 = call %Vec* @"Vec#add"(%Vec* %result33, %Vec* %result36)
call void @"Isect#hit_point="(%Isect* %isect, %Vec* %result37)
%"::void" = load %Void*, %Void** @"::void"
%result38 = call %Vec* @"Isect#hit_point"(%Isect* %isect)
%"addr_@position39" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 1
%"@position40" = load %Vec*, %Vec** %"addr_@position39"
%result41 = call %Vec* @"Vec#sub"(%Vec* %result38, %Vec* %"@position40")
%result42 = call %Vec* @"Vec#normalize"(%Vec* %result41)
call void @"Isect#normal="(%Isect* %isect, %Vec* %result42)
%"::void43" = load %Void*, %Void** @"::void"
%"addr_@color" = getelementptr inbounds %Sphere, %Sphere* %self, i32 0, i32 2
%"@color" = load %Vec*, %Vec** %"addr_@color"
%"::Util" = load %"Meta:Util"*, %"Meta:Util"** @"::Util"
%"::LIGHT" = load %Vec*, %Vec** @"::LIGHT"
%result44 = call %Vec* @"Isect#normal"(%Isect* %isect)
%result45 = call double @"Vec#dot"(%Vec* %"::LIGHT", %Vec* %result44)
%result46 = call double @"Meta:Util#clamp"(%"Meta:Util"* %"::Util", double %result45, double 1.000000e-01, double 1.000000e+00)
%result47 = call %Vec* @"Vec#mul"(%Vec* %"@color", double %result46)
call void @"Isect#color="(%Isect* %isect, %Vec* %result47)
%"::void48" = load %Void*, %Void** @"::void"
%t49 = load double, double* %t
call void @"Isect#distance="(%Isect* %isect, double %t49)
%"::void50" = load %Void*, %Void** @"::void"
%result51 = call i32 @"Isect#hit"(%Isect* %isect)
%result52 = call i32 @"Int#+"(i32 %result51, i32 1)
call void @"Isect#hit="(%Isect* %isect, i32 %result52)
%"::void53" = load %Void*, %Void** @"::void"
%result54 = call %Vec* @"Ray#dir"(%Ray* %ray)
call void @"Isect#ray_dir="(%Isect* %isect, %Vec* %result54)
%"::void55" = load %Void*, %Void** @"::void"
br label %IfEnd
IfEnd: ; preds = %IfThen, %AndEnd
ret void
}
define double @"Meta:Util#clamp"(%"Meta:Util"* %self, double %t, double %min, double %max) {
br label %IfBegin
IfBegin: ; preds = %0
%result = call i1 @"Float#<"(double %t, double %min)
br i1 %result, label %IfThen, label %IfElse
IfThen: ; preds = %IfBegin
br label %IfEnd
IfElse: ; preds = %IfBegin
br label %IfBegin1
IfEnd: ; preds = %IfEnd4, %IfThen
%ifResult6 = phi double [ %min, %IfThen ], [ %ifResult, %IfEnd4 ]
ret double %ifResult6
IfBegin1: ; preds = %IfElse
%result5 = call i1 @"Float#>"(double %t, double %max)
br i1 %result5, label %IfThen2, label %IfElse3
IfThen2: ; preds = %IfBegin1
br label %IfEnd4
IfElse3: ; preds = %IfBegin1
br label %IfEnd4
IfEnd4: ; preds = %IfElse3, %IfThen2
%ifResult = phi double [ %max, %IfThen2 ], [ %t, %IfElse3 ]
br label %IfEnd
}
define i32 @"Meta:Util#color"(%"Meta:Util"* %self, double %t) {
%"::IMAGE_DEPTH" = load i32, i32* @"::IMAGE_DEPTH"
%result = call double @"Int#to_f"(i32 %"::IMAGE_DEPTH")
%"::Util" = load %"Meta:Util"*, %"Meta:Util"** @"::Util"
%result1 = call double @"Meta:Util#clamp"(%"Meta:Util"* %"::Util", double %t, double 0.000000e+00, double 1.000000e+00)
%result2 = call double @"Float#*"(double %result, double %result1)
%result3 = call i32 @"Float#to_i"(double %result2)
%ret = alloca i32
store i32 %result3, i32* %ret
br label %IfBegin
IfBegin: ; preds = %0
%ret4 = load i32, i32* %ret
%"::IMAGE_DEPTH5" = load i32, i32* @"::IMAGE_DEPTH"
%result6 = call i1 @"Int#=="(i32 %ret4, i32 %"::IMAGE_DEPTH5")
br i1 %result6, label %IfThen, label %IfElse
IfThen: ; preds = %IfBegin
%"::IMAGE_DEPTH7" = load i32, i32* @"::IMAGE_DEPTH"
%result8 = call i32 @"Int#-"(i32 %"::IMAGE_DEPTH7", i32 1)
br label %IfEnd
IfElse: ; preds = %IfBegin
%ret9 = load i32, i32* %ret
br label %IfEnd
IfEnd: ; preds = %IfElse, %IfThen
%ifResult = phi i32 [ %result8, %IfThen ], [ %ret9, %IfElse ]
ret i32 %ifResult
}
define void @"Meta:Util#print_col"(%"Meta:Util"* %self, %Vec* %c) {
%as = bitcast %"Meta:Util"* %self to %Object*
%"::Util" = load %"Meta:Util"*, %"Meta:Util"** @"::Util"
%result = call double @"Vec#x"(%Vec* %c)
%result1 = call i32 @"Meta:Util#color"(%"Meta:Util"* %"::Util", double %result)
call void @"Object#putd"(%Object* %as, i32 %result1)
%"::void" = load %Void*, %Void** @"::void"
%as2 = bitcast %"Meta:Util"* %self to %Object*
call void @"Object#putchar"(%Object* %as2, i32 32)
%"::void3" = load %Void*, %Void** @"::void"
%as4 = bitcast %"Meta:Util"* %self to %Object*
%"::Util5" = load %"Meta:Util"*, %"Meta:Util"** @"::Util"
%result6 = call double @"Vec#y"(%Vec* %c)
%result7 = call i32 @"Meta:Util#color"(%"Meta:Util"* %"::Util5", double %result6)
call void @"Object#putd"(%Object* %as4, i32 %result7)
%"::void8" = load %Void*, %Void** @"::void"
%as9 = bitcast %"Meta:Util"* %self to %Object*
call void @"Object#putchar"(%Object* %as9, i32 32)
%"::void10" = load %Void*, %Void** @"::void"
%as11 = bitcast %"Meta:Util"* %self to %Object*
%"::Util12" = load %"Meta:Util"*, %"Meta:Util"** @"::Util"
%result13 = call double @"Vec#z"(%Vec* %c)
%result14 = call i32 @"Meta:Util#color"(%"Meta:Util"* %"::Util12", double %result13)
call void @"Object#putd"(%Object* %as11, i32 %result14)
%"::void15" = load %Void*, %Void** @"::void"
%as16 = bitcast %"Meta:Util"* %self to %Object*
call void @"Object#putchar"(%Object* %as16, i32 10)
%"::void17" = load %Void*, %Void** @"::void"
ret void
}
define void @"Meta:Util#intersect"(%"Meta:Util"* %self, %Ray* %ray, %Isect* %i) {
%"::SPHERE1" = load %Sphere*, %Sphere** @"::SPHERE1"
call void @"Sphere#intersect"(%Sphere* %"::SPHERE1", %Ray* %ray, %Isect* %i)
%"::void" = load %Void*, %Void** @"::void"
%"::SPHERE2" = load %Sphere*, %Sphere** @"::SPHERE2"
call void @"Sphere#intersect"(%Sphere* %"::SPHERE2", %Ray* %ray, %Isect* %i)
%"::void1" = load %Void*, %Void** @"::void"
%"::SPHERE3" = load %Sphere*, %Sphere** @"::SPHERE3"
call void @"Sphere#intersect"(%Sphere* %"::SPHERE3", %Ray* %ray, %Isect* %i)
%"::void2" = load %Void*, %Void** @"::void"
%"::PLANE" = load %Plane*, %Plane** @"::PLANE"
call void @"Plane#intersect"(%Plane* %"::PLANE", %Ray* %ray, %Isect* %i)
%"::void3" = load %Void*, %Void** @"::void"
ret void
}
define void @init_constants() {
%mem = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Isect = bitcast i8* %mem to %"Meta:Isect"*
%Isect = getelementptr inbounds %"Meta:Isect", %"Meta:Isect"* %class_Isect, i32 0, i32 0
%mem1 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str = bitcast i8* %mem1 to %String*
%"addr_@ptr" = getelementptr inbounds %String, %String* %str, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str_0, i32 0, i32 0), i8** %"addr_@ptr"
%"addr_@bytesize" = getelementptr inbounds %String, %String* %str, i32 0, i32 1
store i32 5, i32* %"addr_@bytesize"
store %String* %str, %String** %Isect
store %"Meta:Isect"* %class_Isect, %"Meta:Isect"** @"::Isect"
%mem2 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Vec = bitcast i8* %mem2 to %"Meta:Vec"*
%Vec = getelementptr inbounds %"Meta:Vec", %"Meta:Vec"* %class_Vec, i32 0, i32 0
%mem3 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str4 = bitcast i8* %mem3 to %String*
%"addr_@ptr5" = getelementptr inbounds %String, %String* %str4, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str_1, i32 0, i32 0), i8** %"addr_@ptr5"
%"addr_@bytesize6" = getelementptr inbounds %String, %String* %str4, i32 0, i32 1
store i32 3, i32* %"addr_@bytesize6"
store %String* %str4, %String** %Vec
store %"Meta:Vec"* %class_Vec, %"Meta:Vec"** @"::Vec"
%mem7 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Plane = bitcast i8* %mem7 to %"Meta:Plane"*
%Plane = getelementptr inbounds %"Meta:Plane", %"Meta:Plane"* %class_Plane, i32 0, i32 0
%mem8 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str9 = bitcast i8* %mem8 to %String*
%"addr_@ptr10" = getelementptr inbounds %String, %String* %str9, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str_2, i32 0, i32 0), i8** %"addr_@ptr10"
%"addr_@bytesize11" = getelementptr inbounds %String, %String* %str9, i32 0, i32 1
store i32 5, i32* %"addr_@bytesize11"
store %String* %str9, %String** %Plane
store %"Meta:Plane"* %class_Plane, %"Meta:Plane"** @"::Plane"
%mem12 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Int = bitcast i8* %mem12 to %"Meta:Int"*
%Int = getelementptr inbounds %"Meta:Int", %"Meta:Int"* %class_Int, i32 0, i32 0
%mem13 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str14 = bitcast i8* %mem13 to %String*
%"addr_@ptr15" = getelementptr inbounds %String, %String* %str14, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str_3, i32 0, i32 0), i8** %"addr_@ptr15"
%"addr_@bytesize16" = getelementptr inbounds %String, %String* %str14, i32 0, i32 1
store i32 3, i32* %"addr_@bytesize16"
store %String* %str14, %String** %Int
store %"Meta:Int"* %class_Int, %"Meta:Int"** @"::Int"
%mem17 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Class = bitcast i8* %mem17 to %"Meta:Class"*
%Class = getelementptr inbounds %"Meta:Class", %"Meta:Class"* %class_Class, i32 0, i32 0
%mem18 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str19 = bitcast i8* %mem18 to %String*
%"addr_@ptr20" = getelementptr inbounds %String, %String* %str19, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str_4, i32 0, i32 0), i8** %"addr_@ptr20"
%"addr_@bytesize21" = getelementptr inbounds %String, %String* %str19, i32 0, i32 1
store i32 5, i32* %"addr_@bytesize21"
store %String* %str19, %String** %Class
store %"Meta:Class"* %class_Class, %"Meta:Class"** @"::Class"
%mem22 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%"class_Shiika::Internal" = bitcast i8* %mem22 to %"Meta:Shiika::Internal"*
%"Shiika::Internal" = getelementptr inbounds %"Meta:Shiika::Internal", %"Meta:Shiika::Internal"* %"class_Shiika::Internal", i32 0, i32 0
%mem23 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str24 = bitcast i8* %mem23 to %String*
%"addr_@ptr25" = getelementptr inbounds %String, %String* %str24, i32 0, i32 0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str_5, i32 0, i32 0), i8** %"addr_@ptr25"
%"addr_@bytesize26" = getelementptr inbounds %String, %String* %str24, i32 0, i32 1
store i32 16, i32* %"addr_@bytesize26"
store %String* %str24, %String** %"Shiika::Internal"
store %"Meta:Shiika::Internal"* %"class_Shiika::Internal", %"Meta:Shiika::Internal"** @"::Shiika::Internal"
%mem27 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%"class_Shiika::Internal::Ptr" = bitcast i8* %mem27 to %"Meta:Shiika::Internal::Ptr"*
%"Shiika::Internal::Ptr" = getelementptr inbounds %"Meta:Shiika::Internal::Ptr", %"Meta:Shiika::Internal::Ptr"* %"class_Shiika::Internal::Ptr", i32 0, i32 0
%mem28 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str29 = bitcast i8* %mem28 to %String*
%"addr_@ptr30" = getelementptr inbounds %String, %String* %str29, i32 0, i32 0
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str_6, i32 0, i32 0), i8** %"addr_@ptr30"
%"addr_@bytesize31" = getelementptr inbounds %String, %String* %str29, i32 0, i32 1
store i32 21, i32* %"addr_@bytesize31"
store %String* %str29, %String** %"Shiika::Internal::Ptr"
store %"Meta:Shiika::Internal::Ptr"* %"class_Shiika::Internal::Ptr", %"Meta:Shiika::Internal::Ptr"** @"::Shiika::Internal::Ptr"
%mem32 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Float = bitcast i8* %mem32 to %"Meta:Float"*
%Float = getelementptr inbounds %"Meta:Float", %"Meta:Float"* %class_Float, i32 0, i32 0
%mem33 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str34 = bitcast i8* %mem33 to %String*
%"addr_@ptr35" = getelementptr inbounds %String, %String* %str34, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str_7, i32 0, i32 0), i8** %"addr_@ptr35"
%"addr_@bytesize36" = getelementptr inbounds %String, %String* %str34, i32 0, i32 1
store i32 5, i32* %"addr_@bytesize36"
store %String* %str34, %String** %Float
store %"Meta:Float"* %class_Float, %"Meta:Float"** @"::Float"
%mem37 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Object = bitcast i8* %mem37 to %"Meta:Object"*
%Object = getelementptr inbounds %"Meta:Object", %"Meta:Object"* %class_Object, i32 0, i32 0
%mem38 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str39 = bitcast i8* %mem38 to %String*
%"addr_@ptr40" = getelementptr inbounds %String, %String* %str39, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str_8, i32 0, i32 0), i8** %"addr_@ptr40"
%"addr_@bytesize41" = getelementptr inbounds %String, %String* %str39, i32 0, i32 1
store i32 6, i32* %"addr_@bytesize41"
store %String* %str39, %String** %Object
store %"Meta:Object"* %class_Object, %"Meta:Object"** @"::Object"
%mem42 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%"class_Shiika::Internal::Memory" = bitcast i8* %mem42 to %"Meta:Shiika::Internal::Memory"*
%"Shiika::Internal::Memory" = getelementptr inbounds %"Meta:Shiika::Internal::Memory", %"Meta:Shiika::Internal::Memory"* %"class_Shiika::Internal::Memory", i32 0, i32 0
%mem43 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str44 = bitcast i8* %mem43 to %String*
%"addr_@ptr45" = getelementptr inbounds %String, %String* %str44, i32 0, i32 0
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @str_9, i32 0, i32 0), i8** %"addr_@ptr45"
%"addr_@bytesize46" = getelementptr inbounds %String, %String* %str44, i32 0, i32 1
store i32 24, i32* %"addr_@bytesize46"
store %String* %str44, %String** %"Shiika::Internal::Memory"
store %"Meta:Shiika::Internal::Memory"* %"class_Shiika::Internal::Memory", %"Meta:Shiika::Internal::Memory"** @"::Shiika::Internal::Memory"
%mem47 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_MutableString = bitcast i8* %mem47 to %"Meta:MutableString"*
%MutableString = getelementptr inbounds %"Meta:MutableString", %"Meta:MutableString"* %class_MutableString, i32 0, i32 0
%mem48 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str49 = bitcast i8* %mem48 to %String*
%"addr_@ptr50" = getelementptr inbounds %String, %String* %str49, i32 0, i32 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @str_10, i32 0, i32 0), i8** %"addr_@ptr50"
%"addr_@bytesize51" = getelementptr inbounds %String, %String* %str49, i32 0, i32 1
store i32 13, i32* %"addr_@bytesize51"
store %String* %str49, %String** %MutableString
store %"Meta:MutableString"* %class_MutableString, %"Meta:MutableString"** @"::MutableString"
%mem52 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Math = bitcast i8* %mem52 to %"Meta:Math"*
%Math = getelementptr inbounds %"Meta:Math", %"Meta:Math"* %class_Math, i32 0, i32 0
%mem53 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str54 = bitcast i8* %mem53 to %String*
%"addr_@ptr55" = getelementptr inbounds %String, %String* %str54, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str_11, i32 0, i32 0), i8** %"addr_@ptr55"
%"addr_@bytesize56" = getelementptr inbounds %String, %String* %str54, i32 0, i32 1
store i32 4, i32* %"addr_@bytesize56"
store %String* %str54, %String** %Math
store %"Meta:Math"* %class_Math, %"Meta:Math"** @"::Math"
%mem57 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Never = bitcast i8* %mem57 to %"Meta:Never"*
%Never = getelementptr inbounds %"Meta:Never", %"Meta:Never"* %class_Never, i32 0, i32 0
%mem58 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str59 = bitcast i8* %mem58 to %String*
%"addr_@ptr60" = getelementptr inbounds %String, %String* %str59, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str_12, i32 0, i32 0), i8** %"addr_@ptr60"
%"addr_@bytesize61" = getelementptr inbounds %String, %String* %str59, i32 0, i32 1
store i32 5, i32* %"addr_@bytesize61"
store %String* %str59, %String** %Never
store %"Meta:Never"* %class_Never, %"Meta:Never"** @"::Never"
%mem62 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Sphere = bitcast i8* %mem62 to %"Meta:Sphere"*
%Sphere = getelementptr inbounds %"Meta:Sphere", %"Meta:Sphere"* %class_Sphere, i32 0, i32 0
%mem63 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str64 = bitcast i8* %mem63 to %String*
%"addr_@ptr65" = getelementptr inbounds %String, %String* %str64, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str_13, i32 0, i32 0), i8** %"addr_@ptr65"
%"addr_@bytesize66" = getelementptr inbounds %String, %String* %str64, i32 0, i32 1
store i32 6, i32* %"addr_@bytesize66"
store %String* %str64, %String** %Sphere
store %"Meta:Sphere"* %class_Sphere, %"Meta:Sphere"** @"::Sphere"
%mem67 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Void = bitcast i8* %mem67 to %"Meta:Void"*
%Void = getelementptr inbounds %"Meta:Void", %"Meta:Void"* %class_Void, i32 0, i32 0
%mem68 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str69 = bitcast i8* %mem68 to %String*
%"addr_@ptr70" = getelementptr inbounds %String, %String* %str69, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str_14, i32 0, i32 0), i8** %"addr_@ptr70"
%"addr_@bytesize71" = getelementptr inbounds %String, %String* %str69, i32 0, i32 1
store i32 4, i32* %"addr_@bytesize71"
store %String* %str69, %String** %Void
store %"Meta:Void"* %class_Void, %"Meta:Void"** @"::Void"
%mem72 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Util = bitcast i8* %mem72 to %"Meta:Util"*
%Util = getelementptr inbounds %"Meta:Util", %"Meta:Util"* %class_Util, i32 0, i32 0
%mem73 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str74 = bitcast i8* %mem73 to %String*
%"addr_@ptr75" = getelementptr inbounds %String, %String* %str74, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str_15, i32 0, i32 0), i8** %"addr_@ptr75"
%"addr_@bytesize76" = getelementptr inbounds %String, %String* %str74, i32 0, i32 1
store i32 4, i32* %"addr_@bytesize76"
store %String* %str74, %String** %Util
store %"Meta:Util"* %class_Util, %"Meta:Util"** @"::Util"
%mem77 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Ray = bitcast i8* %mem77 to %"Meta:Ray"*
%Ray = getelementptr inbounds %"Meta:Ray", %"Meta:Ray"* %class_Ray, i32 0, i32 0
%mem78 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str79 = bitcast i8* %mem78 to %String*
%"addr_@ptr80" = getelementptr inbounds %String, %String* %str79, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str_16, i32 0, i32 0), i8** %"addr_@ptr80"
%"addr_@bytesize81" = getelementptr inbounds %String, %String* %str79, i32 0, i32 1
store i32 3, i32* %"addr_@bytesize81"
store %String* %str79, %String** %Ray
store %"Meta:Ray"* %class_Ray, %"Meta:Ray"** @"::Ray"
%mem82 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Shiika = bitcast i8* %mem82 to %"Meta:Shiika"*
%Shiika = getelementptr inbounds %"Meta:Shiika", %"Meta:Shiika"* %class_Shiika, i32 0, i32 0
%mem83 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str84 = bitcast i8* %mem83 to %String*
%"addr_@ptr85" = getelementptr inbounds %String, %String* %str84, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str_17, i32 0, i32 0), i8** %"addr_@ptr85"
%"addr_@bytesize86" = getelementptr inbounds %String, %String* %str84, i32 0, i32 1
store i32 6, i32* %"addr_@bytesize86"
store %String* %str84, %String** %Shiika
store %"Meta:Shiika"* %class_Shiika, %"Meta:Shiika"** @"::Shiika"
%mem87 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_Bool = bitcast i8* %mem87 to %"Meta:Bool"*
%Bool = getelementptr inbounds %"Meta:Bool", %"Meta:Bool"* %class_Bool, i32 0, i32 0
%mem88 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str89 = bitcast i8* %mem88 to %String*
%"addr_@ptr90" = getelementptr inbounds %String, %String* %str89, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str_18, i32 0, i32 0), i8** %"addr_@ptr90"
%"addr_@bytesize91" = getelementptr inbounds %String, %String* %str89, i32 0, i32 1
store i32 4, i32* %"addr_@bytesize91"
store %String* %str89, %String** %Bool
store %"Meta:Bool"* %class_Bool, %"Meta:Bool"** @"::Bool"
%mem92 = call i8* @GC_malloc(i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to i64))
%class_String = bitcast i8* %mem92 to %"Meta:String"*
%String = getelementptr inbounds %"Meta:String", %"Meta:String"* %class_String, i32 0, i32 0
%mem93 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str94 = bitcast i8* %mem93 to %String*
%"addr_@ptr95" = getelementptr inbounds %String, %String* %str94, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str_19, i32 0, i32 0), i8** %"addr_@ptr95"
%"addr_@bytesize96" = getelementptr inbounds %String, %String* %str94, i32 0, i32 1
store i32 6, i32* %"addr_@bytesize96"
store %String* %str94, %String** %String
store %"Meta:String"* %class_String, %"Meta:String"** @"::String"
store i32 1000, i32* @"::IMAGE_WIDTH"
store i32 1000, i32* @"::IMAGE_HEIGHT"
store i32 256, i32* @"::IMAGE_DEPTH"
store double 1.000000e-04, double* @"::EPS"
store i32 4, i32* @"::MAX_REF"
%"::Vec" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec", double 5.770000e-01, double 5.770000e-01, double 5.770000e-01)
store %Vec* %result, %Vec** @"::LIGHT"
%"::Plane" = load %"Meta:Plane"*, %"Meta:Plane"** @"::Plane"
%"::Vec97" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result98 = call double @"Float#-@"(double 1.000000e+00)
%result99 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec97", double 0.000000e+00, double %result98, double 0.000000e+00)
%"::Vec100" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result101 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec100", double 0.000000e+00, double 1.000000e+00, double 0.000000e+00)
%"::Vec102" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result103 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec102", double 1.000000e+00, double 1.000000e+00, double 1.000000e+00)
%result104 = call %Plane* @"Meta:Plane#new"(%"Meta:Plane"* %"::Plane", %Vec* %result99, %Vec* %result101, %Vec* %result103)
store %Plane* %result104, %Plane** @"::PLANE"
store double 1.000000e+01, double* @"::T"
%"::Sphere" = load %"Meta:Sphere"*, %"Meta:Sphere"** @"::Sphere"
%"::Vec105" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result106 = call double @"Float#-@"(double 5.000000e-01)
%"::Math" = load %"Meta:Math"*, %"Meta:Math"** @"::Math"
%result107 = call double @"Meta:Math#sin"(%"Meta:Math"* %"::Math", double 0.000000e+00)
%result108 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec105", double 0.000000e+00, double %result106, double %result107)
%"::Vec109" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result110 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec109", double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
%result111 = call %Sphere* @"Meta:Sphere#new"(%"Meta:Sphere"* %"::Sphere", double 5.000000e-01, %Vec* %result108, %Vec* %result110)
store %Sphere* %result111, %Sphere** @"::SPHERE1"
%"::Sphere112" = load %"Meta:Sphere"*, %"Meta:Sphere"** @"::Sphere"
%"::Vec113" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%"::Math114" = load %"Meta:Math"*, %"Meta:Math"** @"::Math"
%"::T" = load double, double* @"::T"
%result115 = call double @"Float#*"(double %"::T", double 6.660000e-01)
%result116 = call double @"Meta:Math#cos"(%"Meta:Math"* %"::Math114", double %result115)
%result117 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec113", double 2.000000e+00, double 0.000000e+00, double %result116)
%"::Vec118" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result119 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec118", double 0.000000e+00, double 1.000000e+00, double 0.000000e+00)
%result120 = call %Sphere* @"Meta:Sphere#new"(%"Meta:Sphere"* %"::Sphere112", double 1.000000e+00, %Vec* %result117, %Vec* %result119)
store %Sphere* %result120, %Sphere** @"::SPHERE2"
%"::Sphere121" = load %"Meta:Sphere"*, %"Meta:Sphere"** @"::Sphere"
%"::Vec122" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result123 = call double @"Float#-@"(double 2.000000e+00)
%"::Math124" = load %"Meta:Math"*, %"Meta:Math"** @"::Math"
%"::T125" = load double, double* @"::T"
%result126 = call double @"Float#*"(double %"::T125", double 3.330000e-01)
%result127 = call double @"Meta:Math#cos"(%"Meta:Math"* %"::Math124", double %result126)
%result128 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec122", double %result123, double 5.000000e-01, double %result127)
%"::Vec129" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result130 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec129", double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%result131 = call %Sphere* @"Meta:Sphere#new"(%"Meta:Sphere"* %"::Sphere121", double 1.500000e+00, %Vec* %result128, %Vec* %result130)
store %Sphere* %result131, %Sphere** @"::SPHERE3"
%mem132 = call i8* @GC_malloc(i64 0)
%void_obj = bitcast i8* %mem132 to %Void*
store %Void* %void_obj, %Void** @"::void"
ret void
}
define void @user_main() {
CreateMain:
%mem = call i8* @GC_malloc(i64 0)
%main = bitcast i8* %mem to %Object*
br label %UserMain
UserMain: ; preds = %CreateMain
store i32 1000, i32* @"::IMAGE_WIDTH"
store i32 1000, i32* @"::IMAGE_HEIGHT"
store i32 256, i32* @"::IMAGE_DEPTH"
store double 1.000000e-04, double* @"::EPS"
store i32 4, i32* @"::MAX_REF"
%"::Vec" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec", double 5.770000e-01, double 5.770000e-01, double 5.770000e-01)
store %Vec* %result, %Vec** @"::LIGHT"
%"::Plane" = load %"Meta:Plane"*, %"Meta:Plane"** @"::Plane"
%"::Vec1" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result2 = call double @"Float#-@"(double 1.000000e+00)
%result3 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec1", double 0.000000e+00, double %result2, double 0.000000e+00)
%"::Vec4" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result5 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec4", double 0.000000e+00, double 1.000000e+00, double 0.000000e+00)
%"::Vec6" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result7 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec6", double 1.000000e+00, double 1.000000e+00, double 1.000000e+00)
%result8 = call %Plane* @"Meta:Plane#new"(%"Meta:Plane"* %"::Plane", %Vec* %result3, %Vec* %result5, %Vec* %result7)
store %Plane* %result8, %Plane** @"::PLANE"
store double 1.000000e+01, double* @"::T"
%"::Sphere" = load %"Meta:Sphere"*, %"Meta:Sphere"** @"::Sphere"
%"::Vec9" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result10 = call double @"Float#-@"(double 5.000000e-01)
%"::Math" = load %"Meta:Math"*, %"Meta:Math"** @"::Math"
%result11 = call double @"Meta:Math#sin"(%"Meta:Math"* %"::Math", double 0.000000e+00)
%result12 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec9", double 0.000000e+00, double %result10, double %result11)
%"::Vec13" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result14 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec13", double 1.000000e+00, double 0.000000e+00, double 0.000000e+00)
%result15 = call %Sphere* @"Meta:Sphere#new"(%"Meta:Sphere"* %"::Sphere", double 5.000000e-01, %Vec* %result12, %Vec* %result14)
store %Sphere* %result15, %Sphere** @"::SPHERE1"
%"::Sphere16" = load %"Meta:Sphere"*, %"Meta:Sphere"** @"::Sphere"
%"::Vec17" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%"::Math18" = load %"Meta:Math"*, %"Meta:Math"** @"::Math"
%"::T" = load double, double* @"::T"
%result19 = call double @"Float#*"(double %"::T", double 6.660000e-01)
%result20 = call double @"Meta:Math#cos"(%"Meta:Math"* %"::Math18", double %result19)
%result21 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec17", double 2.000000e+00, double 0.000000e+00, double %result20)
%"::Vec22" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result23 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec22", double 0.000000e+00, double 1.000000e+00, double 0.000000e+00)
%result24 = call %Sphere* @"Meta:Sphere#new"(%"Meta:Sphere"* %"::Sphere16", double 1.000000e+00, %Vec* %result21, %Vec* %result23)
store %Sphere* %result24, %Sphere** @"::SPHERE2"
%"::Sphere25" = load %"Meta:Sphere"*, %"Meta:Sphere"** @"::Sphere"
%"::Vec26" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result27 = call double @"Float#-@"(double 2.000000e+00)
%"::Math28" = load %"Meta:Math"*, %"Meta:Math"** @"::Math"
%"::T29" = load double, double* @"::T"
%result30 = call double @"Float#*"(double %"::T29", double 3.330000e-01)
%result31 = call double @"Meta:Math#cos"(%"Meta:Math"* %"::Math28", double %result30)
%result32 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec26", double %result27, double 5.000000e-01, double %result31)
%"::Vec33" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result34 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec33", double 0.000000e+00, double 0.000000e+00, double 1.000000e+00)
%result35 = call %Sphere* @"Meta:Sphere#new"(%"Meta:Sphere"* %"::Sphere25", double 1.500000e+00, %Vec* %result32, %Vec* %result34)
store %Sphere* %result35, %Sphere** @"::SPHERE3"
%mem36 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str = bitcast i8* %mem36 to %String*
%"addr_@ptr" = getelementptr inbounds %String, %String* %str, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str_20, i32 0, i32 0), i8** %"addr_@ptr"
%"addr_@bytesize" = getelementptr inbounds %String, %String* %str, i32 0, i32 1
store i32 2, i32* %"addr_@bytesize"
call void @"Object#puts"(%Object* %main, %String* %str)
%"::void" = load %Void*, %Void** @"::void"
%"::IMAGE_WIDTH" = load i32, i32* @"::IMAGE_WIDTH"
call void @"Object#putd"(%Object* %main, i32 %"::IMAGE_WIDTH")
%"::void37" = load %Void*, %Void** @"::void"
%mem38 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str39 = bitcast i8* %mem38 to %String*
%"addr_@ptr40" = getelementptr inbounds %String, %String* %str39, i32 0, i32 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str_21, i32 0, i32 0), i8** %"addr_@ptr40"
%"addr_@bytesize41" = getelementptr inbounds %String, %String* %str39, i32 0, i32 1
store i32 1, i32* %"addr_@bytesize41"
call void @"Object#puts"(%Object* %main, %String* %str39)
%"::void42" = load %Void*, %Void** @"::void"
%"::IMAGE_HEIGHT" = load i32, i32* @"::IMAGE_HEIGHT"
call void @"Object#putd"(%Object* %main, i32 %"::IMAGE_HEIGHT")
%"::void43" = load %Void*, %Void** @"::void"
%mem44 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str45 = bitcast i8* %mem44 to %String*
%"addr_@ptr46" = getelementptr inbounds %String, %String* %str45, i32 0, i32 0
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @str_22, i32 0, i32 0), i8** %"addr_@ptr46"
%"addr_@bytesize47" = getelementptr inbounds %String, %String* %str45, i32 0, i32 1
store i32 0, i32* %"addr_@bytesize47"
call void @"Object#puts"(%Object* %main, %String* %str45)
%"::void48" = load %Void*, %Void** @"::void"
%mem49 = call i8* @GC_malloc(i64 ptrtoint (%String* getelementptr (%String, %String* null, i32 1) to i64))
%str50 = bitcast i8* %mem49 to %String*
%"addr_@ptr51" = getelementptr inbounds %String, %String* %str50, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str_23, i32 0, i32 0), i8** %"addr_@ptr51"
%"addr_@bytesize52" = getelementptr inbounds %String, %String* %str50, i32 0, i32 1
store i32 3, i32* %"addr_@bytesize52"
call void @"Object#puts"(%Object* %main, %String* %str50)
%"::void53" = load %Void*, %Void** @"::void"
%row = alloca i32
store i32 0, i32* %row
br label %WhileBegin
WhileBegin: ; preds = %WhileEnd62, %UserMain
%row54 = load i32, i32* %row
%"::IMAGE_HEIGHT55" = load i32, i32* @"::IMAGE_HEIGHT"
%result56 = call i1 @"Int#<"(i32 %row54, i32 %"::IMAGE_HEIGHT55")
br i1 %result56, label %WhileBody, label %WhileEnd
WhileBody: ; preds = %WhileBegin
%col = alloca i32
store i32 0, i32* %col
br label %WhileBegin57
WhileEnd: ; preds = %WhileBegin
ret void
WhileBegin57: ; preds = %IfEnd, %WhileBody
%col58 = load i32, i32* %col
%"::IMAGE_WIDTH59" = load i32, i32* @"::IMAGE_WIDTH"
%result60 = call i1 @"Int#<"(i32 %col58, i32 %"::IMAGE_WIDTH59")
br i1 %result60, label %WhileBody61, label %WhileEnd62
WhileBody61: ; preds = %WhileBegin57
%col63 = load i32, i32* %col
%result64 = call double @"Int#to_f"(i32 %col63)
%"::IMAGE_WIDTH65" = load i32, i32* @"::IMAGE_WIDTH"
%result66 = call double @"Int#to_f"(i32 %"::IMAGE_WIDTH65")
%result67 = call double @"Float#/"(double %result66, double 2.000000e+00)
%result68 = call double @"Float#/"(double %result64, double %result67)
%result69 = call double @"Float#-"(double %result68, double 1.000000e+00)
%x = alloca double
store double %result69, double* %x
%"::IMAGE_HEIGHT70" = load i32, i32* @"::IMAGE_HEIGHT"
%row71 = load i32, i32* %row
%result72 = call i32 @"Int#-"(i32 %"::IMAGE_HEIGHT70", i32 %row71)
%result73 = call double @"Int#to_f"(i32 %result72)
%"::IMAGE_HEIGHT74" = load i32, i32* @"::IMAGE_HEIGHT"
%result75 = call double @"Int#to_f"(i32 %"::IMAGE_HEIGHT74")
%result76 = call double @"Float#/"(double %result75, double 2.000000e+00)
%result77 = call double @"Float#/"(double %result73, double %result76)
%result78 = call double @"Float#-"(double %result77, double 1.000000e+00)
%y = alloca double
store double %result78, double* %y
%"::Ray" = load %"Meta:Ray"*, %"Meta:Ray"** @"::Ray"
%"::Vec79" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result80 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec79", double 0.000000e+00, double 2.000000e+00, double 6.000000e+00)
%"::Vec81" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%x82 = load double, double* %x
%y83 = load double, double* %y
%result84 = call double @"Float#-@"(double 1.000000e+00)
%result85 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec81", double %x82, double %y83, double %result84)
%result86 = call %Vec* @"Vec#normalize"(%Vec* %result85)
%result87 = call %Ray* @"Meta:Ray#new"(%"Meta:Ray"* %"::Ray", %Vec* %result80, %Vec* %result86)
%ray = alloca %Ray*
store %Ray* %result87, %Ray** %ray
%"::Isect" = load %"Meta:Isect"*, %"Meta:Isect"** @"::Isect"
%"::Vec88" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result89 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec88", double 0.000000e+00, double 0.000000e+00, double 0.000000e+00)
%"::Vec90" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result91 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec90", double 0.000000e+00, double 0.000000e+00, double 0.000000e+00)
%"::Vec92" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result93 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec92", double 0.000000e+00, double 0.000000e+00, double 0.000000e+00)
%"::Vec94" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result95 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec94", double 0.000000e+00, double 0.000000e+00, double 0.000000e+00)
%result96 = call %Isect* @"Meta:Isect#new"(%"Meta:Isect"* %"::Isect", i32 0, %Vec* %result89, %Vec* %result91, %Vec* %result93, double 1.000000e+30, %Vec* %result95)
%i = alloca %Isect*
store %Isect* %result96, %Isect** %i
%"::Util" = load %"Meta:Util"*, %"Meta:Util"** @"::Util"
%ray97 = load %Ray*, %Ray** %ray
%i98 = load %Isect*, %Isect** %i
call void @"Meta:Util#intersect"(%"Meta:Util"* %"::Util", %Ray* %ray97, %Isect* %i98)
%"::void99" = load %Void*, %Void** @"::void"
br label %IfBegin
WhileEnd62: ; preds = %WhileBegin57
%row168 = load i32, i32* %row
%result169 = call i32 @"Int#+"(i32 %row168, i32 1)
store i32 %result169, i32* %row
br label %WhileBegin
IfBegin: ; preds = %WhileBody61
%i100 = load %Isect*, %Isect** %i
%result101 = call i32 @"Isect#hit"(%Isect* %i100)
%result102 = call i1 @"Int#>"(i32 %result101, i32 0)
br i1 %result102, label %IfThen, label %IfElse
IfThen: ; preds = %IfBegin
%i103 = load %Isect*, %Isect** %i
%result104 = call %Vec* @"Isect#color"(%Isect* %i103)
%dest_col = alloca %Vec*
store %Vec* %result104, %Vec** %dest_col
%"::Vec105" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%result106 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec105", double 1.000000e+00, double 1.000000e+00, double 1.000000e+00)
%i107 = load %Isect*, %Isect** %i
%result108 = call %Vec* @"Isect#color"(%Isect* %i107)
%result109 = call %Vec* @"Vec#multi"(%Vec* %result106, %Vec* %result108)
%temp_col = alloca %Vec*
store %Vec* %result109, %Vec** %temp_col
%j = alloca i32
store i32 1, i32* %j
br label %WhileBegin110
IfElse: ; preds = %IfBegin
%"::Util153" = load %"Meta:Util"*, %"Meta:Util"** @"::Util"
%"::Vec154" = load %"Meta:Vec"*, %"Meta:Vec"** @"::Vec"
%ray155 = load %Ray*, %Ray** %ray
%result156 = call %Vec* @"Ray#dir"(%Ray* %ray155)
%result157 = call double @"Vec#y"(%Vec* %result156)
%ray158 = load %Ray*, %Ray** %ray
%result159 = call %Vec* @"Ray#dir"(%Ray* %ray158)
%result160 = call double @"Vec#y"(%Vec* %result159)
%ray161 = load %Ray*, %Ray** %ray
%result162 = call %Vec* @"Ray#dir"(%Ray* %ray161)
%result163 = call double @"Vec#y"(%Vec* %result162)
%result164 = call %Vec* @"Meta:Vec#new"(%"Meta:Vec"* %"::Vec154", double %result157, double %result160, double %result163)
call void @"Meta:Util#print_col"(%"Meta:Util"* %"::Util153", %Vec* %result164)
%"::void165" = load %Void*, %Void** @"::void"
br label %IfEnd
IfEnd: ; preds = %IfElse, %WhileEnd114
%ifResult = phi %Void* [ %"::void152", %WhileEnd114 ], [ %"::void165", %IfElse ]
%col166 = load i32, i32* %col
%result167 = call i32 @"Int#+"(i32 %col166, i32 1)
store i32 %result167, i32* %col
br label %WhileBegin57
WhileBegin110: ; preds = %IfEnd137, %IfThen
%j111 = load i32, i32* %j
%"::MAX_REF" = load i32, i32* @"::MAX_REF"
%result112 = call i1 @"Int#<"(i32 %j111, i32 %"::MAX_REF")
br i1 %result112, label %WhileBody113, label %WhileEnd114
WhileBody113: ; preds = %WhileBegin110
%"::Ray115" = load %"Meta:Ray"*, %"Meta:Ray"** @"::Ray"
%i116 = load %Isect*, %Isect** %i
%result117 = call %Vec* @"Isect#hit_point"(%Isect* %i116)
%i118 = load %Isect*, %Isect** %i
%result119 = call %Vec* @"Isect#normal"(%Isect* %i118)
%"::EPS" = load double, double* @"::EPS"
%result120 = call %Vec* @"Vec#mul"(%Vec* %result119, double %"::EPS")
%result121 = call %Vec* @"Vec#add"(%Vec* %result117, %Vec* %result120)
%i122 = load %Isect*, %Isect** %i
%result123 = call %Vec* @"Isect#ray_dir"(%Isect* %i122)
%i124 = load %Isect*, %Isect** %i
%result125 = call %Vec* @"Isect#normal"(%Isect* %i124)
%result126 = call %Vec* @"Vec#reflect"(%Vec* %result123, %Vec* %result125)
%result127 = call %Ray* @"Meta:Ray#new"(%"Meta:Ray"* %"::Ray115", %Vec* %result121, %Vec* %result126)
%q = alloca %Ray*
store %Ray* %result127, %Ray** %q
%"::Util128" = load %"Meta:Util"*, %"Meta:Util"** @"::Util"
%q129 = load %Ray*, %Ray** %q
%i130 = load %Isect*, %Isect** %i
call void @"Meta:Util#intersect"(%"Meta:Util"* %"::Util128", %Ray* %q129, %Isect* %i130)
%"::void131" = load %Void*, %Void** @"::void"
%i132 = load %Isect*, %Isect** %i
%result133 = call i32 @"Isect#hit"(%Isect* %i132)
%j134 = load i32, i32* %j
%result135 = call i1 @"Int#>"(i32 %result133, i32 %j134)
br i1 %result135, label %IfThen136, label %IfEnd137
WhileEnd114: ; preds = %WhileBegin110
%"::Util150" = load %"Meta:Util"*, %"Meta:Util"** @"::Util"
%dest_col151 = load %Vec*, %Vec** %dest_col
call void @"Meta:Util#print_col"(%"Meta:Util"* %"::Util150", %Vec* %dest_col151)
%"::void152" = load %Void*, %Void** @"::void"
br label %IfEnd
IfThen136: ; preds = %WhileBody113
%dest_col138 = load %Vec*, %Vec** %dest_col
%temp_col139 = load %Vec*, %Vec** %temp_col
%i140 = load %Isect*, %Isect** %i
%result141 = call %Vec* @"Isect#color"(%Isect* %i140)
%result142 = call %Vec* @"Vec#multi"(%Vec* %temp_col139, %Vec* %result141)
%result143 = call %Vec* @"Vec#add"(%Vec* %dest_col138, %Vec* %result142)
store %Vec* %result143, %Vec** %dest_col
%temp_col144 = load %Vec*, %Vec** %temp_col
%i145 = load %Isect*, %Isect** %i
%result146 = call %Vec* @"Isect#color"(%Isect* %i145)
%result147 = call %Vec* @"Vec#multi"(%Vec* %temp_col144, %Vec* %result146)
store %Vec* %result147, %Vec** %temp_col
br label %IfEnd137
IfEnd137: ; preds = %IfThen136, %WhileBody113
%j148 = load i32, i32* %j
%result149 = call i32 @"Int#+"(i32 %j148, i32 1)
store i32 %result149, i32* %j
br label %WhileBegin110
}
define i32 @main() {
call void @GC_init()
call void @init_constants()
call void @user_main()
ret i32 0
}
attributes #0 = { argmemonly nounwind }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment