; LLVM IR from clangen/musikcube :: src/3rdparty/win32_src/pdcurses (kernel)

; 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.RIPPEDOFFLINE = type { i32, ptr }

@linesrippedoff = external dso_local global i8, align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@__PRETTY_FUNCTION__.ripoffline = external hidden unnamed_addr constant [44 x i8], align 1
@linesripped = external dso_local global [5 x %struct.RIPPEDOFFLINE], align 16

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @ripoffline(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %2
  br label %10

9:                                                ; preds = %2
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 276, ptr noundef @__PRETTY_FUNCTION__.ripoffline) #2
  unreachable

10:                                               ; preds = %8
  %11 = load i8, ptr @linesrippedoff, align 1, !tbaa !11
  %12 = sext i8 %11 to i32
  %13 = icmp slt i32 %12, 5
  br i1 %13, label %14, label %34

14:                                               ; preds = %10
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %34

17:                                               ; preds = %14
  %18 = load ptr, ptr %5, align 8, !tbaa !9
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %34

20:                                               ; preds = %17
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = load i8, ptr @linesrippedoff, align 1, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [5 x %struct.RIPPEDOFFLINE], ptr @linesripped, i64 0, i64 %24
  %26 = getelementptr inbounds %struct.RIPPEDOFFLINE, ptr %25, i32 0, i32 0
  store i32 %21, ptr %26, align 16, !tbaa !12
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = load i8, ptr @linesrippedoff, align 1, !tbaa !11
  %29 = add i8 %28, 1
  store i8 %29, ptr @linesrippedoff, align 1, !tbaa !11
  %30 = sext i8 %28 to i32
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [5 x %struct.RIPPEDOFFLINE], ptr @linesripped, i64 0, i64 %31
  %33 = getelementptr inbounds %struct.RIPPEDOFFLINE, ptr %32, i32 0, i32 1
  store ptr %27, ptr %33, align 8, !tbaa !14
  store i32 0, ptr %3, align 4
  br label %35

34:                                               ; preds = %17, %14, %10
  store i32 -1, ptr %3, align 4
  br label %35

35:                                               ; preds = %34, %20
  %36 = load i32, ptr %3, align 4
  ret i32 %36
}

attributes #0 = { noreturn 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 = { 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 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"", !6, i64 0, !10, i64 8}
!14 = !{!13, !10, 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"

%struct.RIPPEDOFFLINE = type { i32, ptr }

@linesrippedoff = external dso_local local_unnamed_addr global i8, align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@__PRETTY_FUNCTION__.ripoffline = external hidden unnamed_addr constant [44 x i8], align 1
@linesripped = external dso_local local_unnamed_addr global [5 x %struct.RIPPEDOFFLINE], align 16

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @ripoffline(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 276, ptr noundef nonnull @__PRETTY_FUNCTION__.ripoffline) #2
  unreachable

4:                                                ; preds = %2
  %5 = load i8, ptr @linesrippedoff, align 1, !tbaa !5
  %6 = icmp slt i8 %5, 5
  %7 = icmp ne i32 %0, 0
  %or.cond = and i1 %7, %6
  br i1 %or.cond, label %8, label %13

8:                                                ; preds = %4
  %9 = sext i8 %5 to i64
  %10 = getelementptr inbounds [5 x %struct.RIPPEDOFFLINE], ptr @linesripped, i64 0, i64 %9
  store i32 %0, ptr %10, align 16, !tbaa !8
  %11 = add nsw i8 %5, 1
  store i8 %11, ptr @linesrippedoff, align 1, !tbaa !5
  %12 = getelementptr inbounds [5 x %struct.RIPPEDOFFLINE], ptr @linesripped, i64 0, i64 %9, i32 1
  store ptr %1, ptr %12, align 8, !tbaa !12
  br label %13

13:                                               ; preds = %4, %8
  %.0 = phi i32 [ 0, %8 ], [ -1, %4 ]
  ret i32 %.0
}

attributes #0 = { noreturn 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 = { 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 = { noreturn 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !10, i64 0}
!9 = !{!"", !10, i64 0, !11, i64 8}
!10 = !{!"int", !6, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!9, !11, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass