; LLVM IR from krig/LISP :: komplott (lisp_print)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.object_t = type { ptr, ptr, i32 }

@.str.2 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@stdout = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [2 x i8], align 1

declare i32 @fputs(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @lisp_print(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %5, label %8

5:                                                ; preds = %1
  %6 = load ptr, ptr @stdout, align 8, !tbaa !5
  %7 = call i32 @fputs(ptr noundef @.str.3, ptr noundef %6)
  br label %94

8:                                                ; preds = %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.object_t, ptr %9, i32 0, i32 2
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = icmp eq i32 %11, 1
  br i1 %12, label %13, label %30

13:                                               ; preds = %8
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %25

16:                                               ; preds = %13
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.object_t, ptr %17, i32 0, i32 2
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %25

21:                                               ; preds = %16
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.object_t, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !12
  br label %26

25:                                               ; preds = %16, %13
  br label %26

26:                                               ; preds = %25, %21
  %27 = phi ptr [ %24, %21 ], [ @.str.2, %25 ]
  %28 = load ptr, ptr @stdout, align 8, !tbaa !5
  %29 = call i32 @fputs(ptr noundef %27, ptr noundef %28)
  br label %93

30:                                               ; preds = %8
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.object_t, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !9
  %34 = icmp eq i32 %33, 2
  br i1 %34, label %35, label %38

35:                                               ; preds = %30
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, ptr noundef %36)
  br label %92

38:                                               ; preds = %30
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.object_t, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %40, align 8, !tbaa !9
  %42 = icmp eq i32 %41, 3
  br i1 %42, label %43, label %51

43:                                               ; preds = %38
  %44 = load ptr, ptr @stdout, align 8, !tbaa !5
  %45 = call i32 @fputs(ptr noundef @.str.5, ptr noundef %44)
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.object_t, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !12
  call void @lisp_print(ptr noundef %48)
  %49 = load ptr, ptr @stdout, align 8, !tbaa !5
  %50 = call i32 @fputs(ptr noundef @.str.6, ptr noundef %49)
  br label %91

51:                                               ; preds = %38
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.object_t, ptr %52, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !9
  %55 = icmp eq i32 %54, 0
  br i1 %55, label %56, label %90

56:                                               ; preds = %51
  %57 = load ptr, ptr @stdout, align 8, !tbaa !5
  %58 = call i32 @fputs(ptr noundef @.str.7, ptr noundef %57)
  br label %59

59:                                               ; preds = %83, %56
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.object_t, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !12
  call void @lisp_print(ptr noundef %62)
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.object_t, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !13
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %68

67:                                               ; preds = %59
  br label %87

68:                                               ; preds = %59
  %69 = load ptr, ptr @stdout, align 8, !tbaa !5
  %70 = call i32 @fputs(ptr noundef @.str.8, ptr noundef %69)
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.object_t, ptr %71, i32 0, i32 1
  %73 = load ptr, ptr %72, align 8, !tbaa !13
  %74 = getelementptr inbounds %struct.object_t, ptr %73, i32 0, i32 2
  %75 = load i32, ptr %74, align 8, !tbaa !9
  %76 = icmp ne i32 %75, 0
  br i1 %76, label %77, label %83

77:                                               ; preds = %68
  %78 = load ptr, ptr @stdout, align 8, !tbaa !5
  %79 = call i32 @fputs(ptr noundef @.str.9, ptr noundef %78)
  %80 = load ptr, ptr %2, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.object_t, ptr %80, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !13
  call void @lisp_print(ptr noundef %82)
  br label %87

83:                                               ; preds = %68
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.object_t, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !13
  store ptr %86, ptr %2, align 8, !tbaa !5
  br label %59

87:                                               ; preds = %77, %67
  %88 = load ptr, ptr @stdout, align 8, !tbaa !5
  %89 = call i32 @fputs(ptr noundef @.str.10, ptr noundef %88)
  br label %90

90:                                               ; preds = %87, %51
  br label %91

91:                                               ; preds = %90, %43
  br label %92

92:                                               ; preds = %91, %35
  br label %93

93:                                               ; preds = %92, %26
  br label %94

94:                                               ; preds = %93, %5
  ret void
}

declare i32 @printf(ptr noundef, ...) #0

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 16}
!10 = !{!"object_t", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!10, !6, i64 8}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @fputs(ptr nocapture noundef readonly, ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local void @lisp_print(ptr noundef %0) local_unnamed_addr #1 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %3, label %6

3:                                                ; preds = %1
  %4 = load ptr, ptr @stdout, align 8, !tbaa !5
  %5 = tail call i32 @fputs(ptr noundef nonnull @.str.3, ptr noundef %4)
  br label %common.ret23

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load i32, ptr %7, align 8, !tbaa !9
  switch i32 %8, label %common.ret23 [
    i32 1, label %9
    i32 2, label %13
    i32 3, label %15
    i32 0, label %21
  ]

9:                                                ; preds = %6
  %10 = load ptr, ptr %0, align 8, !tbaa !12
  %11 = load ptr, ptr @stdout, align 8, !tbaa !5
  %12 = tail call i32 @fputs(ptr noundef %10, ptr noundef %11)
  br label %common.ret23

13:                                               ; preds = %6
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef nonnull %0)
  br label %common.ret23

common.ret23:                                     ; preds = %6, %9, %.loopexit, %13, %3, %15
  ret void

15:                                               ; preds = %6
  %16 = load ptr, ptr @stdout, align 8, !tbaa !5
  %17 = tail call i32 @fputs(ptr noundef nonnull @.str.5, ptr noundef %16)
  %18 = load ptr, ptr %0, align 8, !tbaa !12
  tail call void @lisp_print(ptr noundef %18)
  %19 = load ptr, ptr @stdout, align 8, !tbaa !5
  %20 = tail call i32 @fputs(ptr noundef nonnull @.str.6, ptr noundef %19)
  br label %common.ret23

21:                                               ; preds = %6
  %22 = load ptr, ptr @stdout, align 8, !tbaa !5
  %23 = tail call i32 @fputs(ptr noundef nonnull @.str.7, ptr noundef %22)
  br label %24

24:                                               ; preds = %29, %21
  %.0 = phi ptr [ %0, %21 ], [ %32, %29 ]
  %25 = load ptr, ptr %.0, align 8, !tbaa !12
  tail call void @lisp_print(ptr noundef %25)
  %26 = getelementptr inbounds i8, ptr %.0, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = icmp eq ptr %27, null
  br i1 %28, label %.loopexit, label %29

29:                                               ; preds = %24
  %30 = load ptr, ptr @stdout, align 8, !tbaa !5
  %31 = tail call i32 @fputs(ptr noundef nonnull @.str.8, ptr noundef %30)
  %32 = load ptr, ptr %26, align 8, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %34 = load i32, ptr %33, align 8, !tbaa !9
  %.not = icmp eq i32 %34, 0
  br i1 %.not, label %24, label %35

35:                                               ; preds = %29
  %36 = load ptr, ptr @stdout, align 8, !tbaa !5
  %37 = tail call i32 @fputs(ptr noundef nonnull @.str.9, ptr noundef %36)
  %38 = load ptr, ptr %26, align 8, !tbaa !13
  tail call void @lisp_print(ptr noundef %38)
  br label %.loopexit

.loopexit:                                        ; preds = %24, %35
  %39 = load ptr, ptr @stdout, align 8, !tbaa !5
  %40 = tail call i32 @fputs(ptr noundef nonnull @.str.10, ptr noundef %39)
  br label %common.ret23
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

attributes #0 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 16}
!10 = !{!"object_t", !6, i64 0, !6, i64 8, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!10, !6, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass