; LLVM IR from billziss-gh/imap :: doc (graph)

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

@stdin = external global ptr, align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@stdout = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca [80 x i8], align 16
  %11 = alloca i8, align 1
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 80, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #5
  %12 = call ptr @imap_ensure(ptr noundef null, i32 noundef 1)
  store ptr %12, ptr %6, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %74, %2
  %14 = getelementptr inbounds [80 x i8], ptr %10, i64 0, i64 0
  %15 = load ptr, ptr @stdin, align 8, !tbaa !9
  %16 = call ptr @fgets(ptr noundef %14, i32 noundef 80, ptr noundef %15)
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %75

18:                                               ; preds = %13
  %19 = getelementptr inbounds [80 x i8], ptr %10, i64 0, i64 0
  %20 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %19, ptr noundef @.str, ptr noundef %8, ptr noundef %9) #5
  %21 = icmp eq i32 2, %20
  br i1 %21, label %22, label %31

22:                                               ; preds = %18
  %23 = load ptr, ptr %6, align 8, !tbaa !9
  %24 = call ptr @imap_ensure(ptr noundef %23, i32 noundef 1)
  store ptr %24, ptr %6, align 8, !tbaa !9
  %25 = load ptr, ptr %6, align 8, !tbaa !9
  %26 = load i64, ptr %8, align 8, !tbaa !11
  %27 = call ptr @imap_assign(ptr noundef %25, i64 noundef %26)
  store ptr %27, ptr %7, align 8, !tbaa !9
  %28 = load ptr, ptr %6, align 8, !tbaa !9
  %29 = load ptr, ptr %7, align 8, !tbaa !9
  %30 = load i64, ptr %9, align 8, !tbaa !11
  call void @imap_setval(ptr noundef %28, ptr noundef %29, i64 noundef %30)
  br label %74

31:                                               ; preds = %18
  %32 = getelementptr inbounds [80 x i8], ptr %10, i64 0, i64 0
  %33 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %32, ptr noundef @.str.1, ptr noundef %8, ptr noundef %11) #5
  %34 = icmp eq i32 2, %33
  br i1 %34, label %35, label %45

35:                                               ; preds = %31
  %36 = load i8, ptr %11, align 1, !tbaa !13
  %37 = sext i8 %36 to i32
  %38 = icmp eq i32 61, %37
  br i1 %38, label %39, label %45

39:                                               ; preds = %35
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = call ptr @imap_ensure(ptr noundef %40, i32 noundef 1)
  store ptr %41, ptr %6, align 8, !tbaa !9
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = load i64, ptr %8, align 8, !tbaa !11
  %44 = call ptr @imap_assign(ptr noundef %42, i64 noundef %43)
  store ptr %44, ptr %7, align 8, !tbaa !9
  br label %73

45:                                               ; preds = %35, %31
  %46 = getelementptr inbounds [80 x i8], ptr %10, i64 0, i64 0
  %47 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %46, ptr noundef @.str.1, ptr noundef %8, ptr noundef %11) #5
  %48 = icmp eq i32 2, %47
  br i1 %48, label %49, label %56

49:                                               ; preds = %45
  %50 = load i8, ptr %11, align 1, !tbaa !13
  %51 = sext i8 %50 to i32
  %52 = icmp eq i32 114, %51
  br i1 %52, label %53, label %56

53:                                               ; preds = %49
  %54 = load ptr, ptr %6, align 8, !tbaa !9
  %55 = load i64, ptr %8, align 8, !tbaa !11
  call void @imap_remove(ptr noundef %54, i64 noundef %55)
  br label %72

56:                                               ; preds = %49, %45
  %57 = getelementptr inbounds [80 x i8], ptr %10, i64 0, i64 0
  %58 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %57, ptr noundef @.str.2, ptr noundef %11) #5
  %59 = icmp eq i32 1, %58
  br i1 %59, label %60, label %71

60:                                               ; preds = %56
  %61 = load i8, ptr %11, align 1, !tbaa !13
  %62 = sext i8 %61 to i32
  %63 = icmp eq i32 100, %62
  br i1 %63, label %64, label %71

64:                                               ; preds = %60
  %65 = load ptr, ptr @stdout, align 8, !tbaa !9
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.3) #5
  %67 = load ptr, ptr %6, align 8, !tbaa !9
  %68 = load ptr, ptr @stdout, align 8, !tbaa !9
  call void @imap_dump(ptr noundef %67, ptr noundef @fprintf, ptr noundef %68)
  %69 = load ptr, ptr @stdout, align 8, !tbaa !9
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef @.str.4) #5
  br label %71

71:                                               ; preds = %64, %60, %56
  br label %72

72:                                               ; preds = %71, %53
  br label %73

73:                                               ; preds = %72, %39
  br label %74

74:                                               ; preds = %73, %22
  br label %13, !llvm.loop !14

75:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  ret i32 0
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @imap_ensure(ptr noundef, i32 noundef) #2

declare ptr @fgets(ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @__isoc99_sscanf(ptr noundef, ptr noundef, ...) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @imap_assign(ptr noundef, i64 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @imap_setval(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @imap_remove(ptr noundef, i64 noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @imap_dump(ptr noundef, ptr noundef, ptr noundef) #2

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

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


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

@stdin = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca [80 x i8], align 16
  %6 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #4
  %7 = tail call ptr @imap_ensure(ptr noundef null, i32 noundef 1)
  %8 = load ptr, ptr @stdin, align 8, !tbaa !5
  %9 = call ptr @fgets(ptr noundef nonnull %5, i32 noundef 80, ptr noundef %8)
  %.not16 = icmp eq ptr %9, null
  br i1 %.not16, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %44
  %.017 = phi ptr [ %.1, %44 ], [ %7, %2 ]
  %10 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %5, ptr noundef nonnull @.str, ptr noundef nonnull %3, ptr noundef nonnull %4) #4
  %11 = icmp eq i32 %10, 2
  br i1 %11, label %12, label %17

12:                                               ; preds = %.lr.ph
  %13 = call ptr @imap_ensure(ptr noundef %.017, i32 noundef 1)
  %14 = load i64, ptr %3, align 8, !tbaa !9
  %15 = call ptr @imap_assign(ptr noundef %13, i64 noundef %14)
  %16 = load i64, ptr %4, align 8, !tbaa !9
  call void @imap_setval(ptr noundef %13, ptr noundef %15, i64 noundef %16)
  br label %44

17:                                               ; preds = %.lr.ph
  %18 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %5, ptr noundef nonnull @.str.1, ptr noundef nonnull %3, ptr noundef nonnull %6) #4
  %19 = icmp eq i32 %18, 2
  %20 = load i8, ptr %6, align 1
  %21 = icmp eq i8 %20, 61
  %or.cond = select i1 %19, i1 %21, i1 false
  br i1 %or.cond, label %22, label %26

22:                                               ; preds = %17
  %23 = call ptr @imap_ensure(ptr noundef %.017, i32 noundef 1)
  %24 = load i64, ptr %3, align 8, !tbaa !9
  %25 = call ptr @imap_assign(ptr noundef %23, i64 noundef %24)
  br label %44

26:                                               ; preds = %17
  %27 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %5, ptr noundef nonnull @.str.1, ptr noundef nonnull %3, ptr noundef nonnull %6) #4
  %28 = icmp eq i32 %27, 2
  %29 = load i8, ptr %6, align 1
  %30 = icmp eq i8 %29, 114
  %or.cond5 = select i1 %28, i1 %30, i1 false
  br i1 %or.cond5, label %31, label %33

31:                                               ; preds = %26
  %32 = load i64, ptr %3, align 8, !tbaa !9
  call void @imap_remove(ptr noundef %.017, i64 noundef %32)
  br label %44

33:                                               ; preds = %26
  %34 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %5, ptr noundef nonnull @.str.2, ptr noundef nonnull %6) #4
  %35 = icmp eq i32 %34, 1
  %36 = load i8, ptr %6, align 1
  %37 = icmp eq i8 %36, 100
  %or.cond8 = select i1 %35, i1 %37, i1 false
  br i1 %or.cond8, label %38, label %44

38:                                               ; preds = %33
  %39 = load ptr, ptr @stdout, align 8, !tbaa !5
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.3) #4
  %41 = load ptr, ptr @stdout, align 8, !tbaa !5
  call void @imap_dump(ptr noundef %.017, ptr noundef nonnull @fprintf, ptr noundef %41)
  %42 = load ptr, ptr @stdout, align 8, !tbaa !5
  %43 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %42, ptr noundef nonnull @.str.4) #4
  br label %44

44:                                               ; preds = %22, %33, %38, %31, %12
  %.1 = phi ptr [ %13, %12 ], [ %23, %22 ], [ %.017, %31 ], [ %.017, %38 ], [ %.017, %33 ]
  %45 = load ptr, ptr @stdin, align 8, !tbaa !5
  %46 = call ptr @fgets(ptr noundef nonnull %5, i32 noundef 80, ptr noundef %45)
  %.not = icmp eq ptr %46, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %44, %2
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret i32 0
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @imap_ensure(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef ptr @fgets(ptr noundef, i32 noundef, ptr nocapture noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @imap_assign(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @imap_setval(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @imap_remove(ptr noundef, i64 noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @imap_dump(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass