; LLVM IR from masyagin1998/GCI :: src/bytecode-generator (bytecode-generator)

; 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.BYTECODE_ERROR = type { %struct.POS, i32 }
%struct.POS = type { ptr, i64, i64, i64, i64 }

@stderr = external global ptr, align 8
@.str.44 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @print_bytecode_error(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store ptr null, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.BYTECODE_ERROR, ptr %4, i32 0, i32 1
  %6 = load i32, ptr %5, align 8, !tbaa !9
  switch i32 %6, label %12 [
    i32 0, label %7
    i32 -1, label %8
    i32 -2, label %9
    i32 -3, label %10
    i32 -4, label %11
  ]

7:                                                ; preds = %1
  store ptr @.str.44, ptr %3, align 8, !tbaa !5
  br label %12

8:                                                ; preds = %1
  store ptr @.str.45, ptr %3, align 8, !tbaa !5
  br label %12

9:                                                ; preds = %1
  store ptr @.str.46, ptr %3, align 8, !tbaa !5
  br label %12

10:                                               ; preds = %1
  store ptr @.str.47, ptr %3, align 8, !tbaa !5
  br label %12

11:                                               ; preds = %1
  store ptr @.str.48, ptr %3, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %11, %10, %9, %8, %7, %1
  %13 = load ptr, ptr @stderr, align 8, !tbaa !5
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.BYTECODE_ERROR, ptr %14, i32 0, i32 0
  %16 = getelementptr inbounds %struct.POS, ptr %15, i32 0, i32 2
  %17 = load i64, ptr %16, align 8, !tbaa !14
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.BYTECODE_ERROR, ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds %struct.POS, ptr %19, i32 0, i32 3
  %21 = load i64, ptr %20, align 8, !tbaa !15
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef @.str.49, i64 noundef %17, i64 noundef %21, ptr noundef %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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" }
attributes #3 = { nounwind }

!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, !13, i64 40}
!10 = !{!"BYTECODE_ERROR", !11, i64 0, !13, i64 40}
!11 = !{!"POS", !6, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!12 = !{!"long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !12, i64 16}
!15 = !{!10, !12, i64 24}


; 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.44 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [20 x i8], align 1
@switch.table.print_bytecode_error = private unnamed_addr constant [5 x ptr] [ptr @.str.48, ptr @.str.47, ptr @.str.46, ptr @.str.45, ptr @.str.44], align 8

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_bytecode_error(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %switch.tableidx = add i32 %3, 4
  %4 = icmp ult i32 %switch.tableidx, 5
  br i1 %4, label %switch.lookup, label %6

switch.lookup:                                    ; preds = %1
  %5 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [5 x ptr], ptr @switch.table.print_bytecode_error, i64 0, i64 %5
  %switch.load = load ptr, ptr %switch.gep, align 8
  br label %6

6:                                                ; preds = %switch.lookup, %1
  %.0 = phi ptr [ null, %1 ], [ %switch.load, %switch.lookup ]
  %7 = load ptr, ptr @stderr, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i64, ptr %8, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load i64, ptr %10, align 8, !tbaa !15
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.49, i64 noundef %9, i64 noundef %11, ptr noundef %.0) #2
  ret void
}

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" }
attributes #2 = { cold nounwind }

!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, !12, i64 40}
!6 = !{!"BYTECODE_ERROR", !7, i64 0, !12, i64 40}
!7 = !{!"POS", !8, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!6, !11, i64 16}
!15 = !{!6, !11, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass