; LLVM IR from hutusi/rethink-c :: test (test_bitmap)

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

@.str.1 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [19 x i8], align 1
@__PRETTY_FUNCTION__.test_bitmap_words = external hidden unnamed_addr constant [25 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.50 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.51 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.52 = external hidden unnamed_addr constant [23 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 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

declare void @alloc_test_free(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @test_bitmap_words() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @set_bit(ptr noundef %1, i32 noundef 0)
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %8, label %9

8:                                                ; preds = %0
  br label %10

9:                                                ; preds = %0
  call void @__assert_fail(ptr noundef @.str.44, ptr noundef @.str.1, i32 noundef 279, ptr noundef @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

10:                                               ; preds = %8
  call void @set_bit(ptr noundef %1, i32 noundef 1)
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = icmp eq i32 %11, 3
  br i1 %12, label %13, label %14

13:                                               ; preds = %10
  br label %15

14:                                               ; preds = %10
  call void @__assert_fail(ptr noundef @.str.45, ptr noundef @.str.1, i32 noundef 281, ptr noundef @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

15:                                               ; preds = %13
  call void @set_bit(ptr noundef %1, i32 noundef 2)
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = icmp eq i32 %16, 7
  br i1 %17, label %18, label %19

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @__assert_fail(ptr noundef @.str.46, ptr noundef @.str.1, i32 noundef 283, ptr noundef @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

20:                                               ; preds = %18
  call void @clear_bit(ptr noundef %1, i32 noundef 1)
  %21 = load i32, ptr %1, align 4, !tbaa !5
  %22 = icmp eq i32 %21, 5
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  br label %25

24:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.47, ptr noundef @.str.1, i32 noundef 286, ptr noundef @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

25:                                               ; preds = %23
  %26 = call i32 @get_bit(ptr noundef %1, i32 noundef 0)
  %27 = icmp eq i32 %26, 1
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  br label %30

29:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.48, ptr noundef @.str.1, i32 noundef 288, ptr noundef @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

30:                                               ; preds = %28
  %31 = call i32 @get_bit(ptr noundef %1, i32 noundef 1)
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  br label %35

34:                                               ; preds = %30
  call void @__assert_fail(ptr noundef @.str.49, ptr noundef @.str.1, i32 noundef 289, ptr noundef @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

35:                                               ; preds = %33
  store i32 -1, ptr %1, align 4, !tbaa !5
  %36 = load i32, ptr %1, align 4, !tbaa !5
  %37 = icmp eq i32 %36, -1
  br i1 %37, label %38, label %39

38:                                               ; preds = %35
  br label %40

39:                                               ; preds = %35
  call void @__assert_fail(ptr noundef @.str.50, ptr noundef @.str.1, i32 noundef 292, ptr noundef @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

40:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 10, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = mul i64 4, %42
  %44 = call ptr @alloc_test_malloc(i64 noundef %43)
  store ptr %44, ptr %3, align 8, !tbaa !9
  %45 = load ptr, ptr %3, align 8, !tbaa !9
  call void @set_bitmap(ptr noundef %45, i32 noundef 10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %60, %40
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = mul nsw i32 %48, 32
  %50 = icmp slt i32 %47, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %63

52:                                               ; preds = %46
  %53 = load ptr, ptr %3, align 8, !tbaa !9
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = call i32 @get_bit(ptr noundef %53, i32 noundef %54)
  %56 = icmp eq i32 %55, 1
  br i1 %56, label %57, label %58

57:                                               ; preds = %52
  br label %59

58:                                               ; preds = %52
  call void @__assert_fail(ptr noundef @.str.51, ptr noundef @.str.1, i32 noundef 298, ptr noundef @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

59:                                               ; preds = %57
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %4, align 4, !tbaa !5
  br label %46, !llvm.loop !11

63:                                               ; preds = %51
  %64 = load ptr, ptr %3, align 8, !tbaa !9
  call void @clear_bitmap(ptr noundef %64, i32 noundef 10)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %79, %63
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = load i32, ptr %2, align 4, !tbaa !5
  %68 = mul nsw i32 %67, 32
  %69 = icmp slt i32 %66, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %82

71:                                               ; preds = %65
  %72 = load ptr, ptr %3, align 8, !tbaa !9
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = call i32 @get_bit(ptr noundef %72, i32 noundef %73)
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %77

76:                                               ; preds = %71
  br label %78

77:                                               ; preds = %71
  call void @__assert_fail(ptr noundef @.str.52, ptr noundef @.str.1, i32 noundef 303, ptr noundef @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

78:                                               ; preds = %76
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %5, align 4, !tbaa !5
  br label %65, !llvm.loop !13

82:                                               ; preds = %70
  %83 = load ptr, ptr %3, align 8, !tbaa !9
  call void @alloc_test_free(ptr noundef %83)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

declare void @set_bit(ptr noundef, i32 noundef) #2

declare void @clear_bit(ptr noundef, i32 noundef) #2

declare i32 @get_bit(ptr noundef, i32 noundef) #2

declare ptr @alloc_test_malloc(i64 noundef) #2

declare void @set_bitmap(ptr noundef, i32 noundef) #2

declare void @clear_bitmap(ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 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 #4 = { nounwind }
attributes #5 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.1 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.44 = external hidden unnamed_addr constant [19 x i8], align 1
@__PRETTY_FUNCTION__.test_bitmap_words = external hidden unnamed_addr constant [25 x i8], align 1
@.str.45 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.49 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.51 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.52 = external hidden unnamed_addr constant [23 x i8], align 1

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

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

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

declare void @alloc_test_free(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @test_bitmap_words() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @set_bit(ptr noundef nonnull %1, i32 noundef 0) #4
  %2 = load i32, ptr %1, align 4, !tbaa !5
  %3 = icmp eq i32 %2, 1
  br i1 %3, label %5, label %4

4:                                                ; preds = %0
  call void @__assert_fail(ptr noundef nonnull @.str.44, ptr noundef nonnull @.str.1, i32 noundef 279, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

5:                                                ; preds = %0
  call void @set_bit(ptr noundef nonnull %1, i32 noundef 1) #4
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 3
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  call void @__assert_fail(ptr noundef nonnull @.str.45, ptr noundef nonnull @.str.1, i32 noundef 281, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

9:                                                ; preds = %5
  call void @set_bit(ptr noundef nonnull %1, i32 noundef 2) #4
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = icmp eq i32 %10, 7
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @__assert_fail(ptr noundef nonnull @.str.46, ptr noundef nonnull @.str.1, i32 noundef 283, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

13:                                               ; preds = %9
  call void @clear_bit(ptr noundef nonnull %1, i32 noundef 1) #4
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 5
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  call void @__assert_fail(ptr noundef nonnull @.str.47, ptr noundef nonnull @.str.1, i32 noundef 286, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

17:                                               ; preds = %13
  %18 = call i32 @get_bit(ptr noundef nonnull %1, i32 noundef 0) #4
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  call void @__assert_fail(ptr noundef nonnull @.str.48, ptr noundef nonnull @.str.1, i32 noundef 288, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

21:                                               ; preds = %17
  %22 = call i32 @get_bit(ptr noundef nonnull %1, i32 noundef 1) #4
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  call void @__assert_fail(ptr noundef nonnull @.str.49, ptr noundef nonnull @.str.1, i32 noundef 289, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

25:                                               ; preds = %21
  store i32 -1, ptr %1, align 4, !tbaa !5
  %26 = call ptr @alloc_test_malloc(i64 noundef 40) #4
  call void @set_bitmap(ptr noundef %26, i32 noundef 10) #4
  br label %30

27:                                               ; preds = %30
  %28 = add nuw nsw i32 %.01314, 1
  %exitcond.not = icmp eq i32 %28, 320
  br i1 %exitcond.not, label %29, label %30, !llvm.loop !9

29:                                               ; preds = %27
  call void @clear_bitmap(ptr noundef %26, i32 noundef 10) #4
  br label %37

30:                                               ; preds = %25, %27
  %.01314 = phi i32 [ 0, %25 ], [ %28, %27 ]
  %31 = call i32 @get_bit(ptr noundef %26, i32 noundef %.01314) #4
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %27, label %33

33:                                               ; preds = %30
  call void @__assert_fail(ptr noundef nonnull @.str.51, ptr noundef nonnull @.str.1, i32 noundef 298, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable

34:                                               ; preds = %37
  %35 = add nuw nsw i32 %.015, 1
  %exitcond16.not = icmp eq i32 %35, 320
  br i1 %exitcond16.not, label %36, label %37, !llvm.loop !11

36:                                               ; preds = %34
  call void @alloc_test_free(ptr noundef %26) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret void

37:                                               ; preds = %29, %34
  %.015 = phi i32 [ 0, %29 ], [ %35, %34 ]
  %38 = call i32 @get_bit(ptr noundef %26, i32 noundef %.015) #4
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %34, label %40

40:                                               ; preds = %37
  call void @__assert_fail(ptr noundef nonnull @.str.52, ptr noundef nonnull @.str.1, i32 noundef 303, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bitmap_words) #5
  unreachable
}

declare void @set_bit(ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @clear_bit(ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @get_bit(ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @alloc_test_malloc(i64 noundef) local_unnamed_addr #2

declare void @set_bitmap(ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @clear_bitmap(ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 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 #4 = { nounwind }
attributes #5 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass