; LLVM IR from Montimage/mmt-security :: src/lib (verdict_printer)

; 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 = external hidden unnamed_addr constant [30 x i8], align 1
@output_mode = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @verdict_printer_init(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [500 x i8], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #9
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #9
  store i32 0, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 500, ptr %8) #9
  call void @llvm.memset.p0.i64(ptr align 16 %8, i8 0, i64 500, i1 false)
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %64

11:                                               ; preds = %2
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 0
  %14 = load i8, ptr %13, align 1, !tbaa !11
  %15 = sext i8 %14 to i32
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %64

17:                                               ; preds = %11
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = call ptr @strchr(ptr noundef %18, i32 noundef 58) #10
  store ptr %19, ptr %5, align 8, !tbaa !5
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %24

22:                                               ; preds = %17
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  call void (ptr, i32, ...) @init_file(ptr noundef %23, i32 noundef 0)
  br label %61

24:                                               ; preds = %17
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = ptrtoint ptr %25 to i64
  %28 = ptrtoint ptr %26 to i64
  %29 = sub i64 %27, %28
  %30 = trunc i64 %29 to i32
  store i32 %30, ptr %6, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %24
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 500
  %34 = xor i1 %33, true
  %35 = xor i1 %34, true
  %36 = xor i1 %35, true
  %37 = zext i1 %36 to i32
  %38 = sext i32 %37 to i64
  %39 = call i64 @llvm.expect.i64(i64 %38, i64 0)
  %40 = icmp ne i64 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %31
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 4, ptr noundef @.str, i32 noundef 500)
  call void @exit(i32 noundef 0) #11
  unreachable

42:                                               ; preds = %31
  %43 = getelementptr inbounds [500 x i8], ptr %8, i64 0, i64 0
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = call ptr @strncpy(ptr noundef %43, ptr noundef %44, i64 noundef %46) #9
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [500 x i8], ptr %8, i64 0, i64 %49
  store i8 0, ptr %50, align 1, !tbaa !11
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = sext i32 %52 to i64
  %55 = getelementptr inbounds i8, ptr %53, i64 %54
  store ptr %55, ptr %3, align 8, !tbaa !5
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = call i64 @atoll(ptr noundef %56) #10
  %58 = trunc i64 %57 to i32
  store i32 %58, ptr %7, align 4, !tbaa !9
  %59 = getelementptr inbounds [500 x i8], ptr %8, i64 0, i64 0
  %60 = load i32, ptr %7, align 4, !tbaa !9
  call void (ptr, i32, ...) @init_file(ptr noundef %59, i32 noundef %60)
  br label %61

61:                                               ; preds = %42, %22
  %62 = load i32, ptr @output_mode, align 4, !tbaa !9
  %63 = or i32 %62, 2
  store i32 %63, ptr @output_mode, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %61, %11, %2
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %120

67:                                               ; preds = %64
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %68, i64 0
  %70 = load i8, ptr %69, align 1, !tbaa !11
  %71 = sext i8 %70 to i32
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %120

73:                                               ; preds = %67
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = call ptr @strchr(ptr noundef %74, i32 noundef 58) #10
  store ptr %75, ptr %5, align 8, !tbaa !5
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = icmp eq ptr %76, null
  br i1 %77, label %78, label %80

78:                                               ; preds = %73
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  call void (ptr, i32, ...) @init_redis(ptr noundef %79, i32 noundef 6379)
  br label %117

80:                                               ; preds = %73
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = ptrtoint ptr %81 to i64
  %84 = ptrtoint ptr %82 to i64
  %85 = sub i64 %83, %84
  %86 = trunc i64 %85 to i32
  store i32 %86, ptr %6, align 4, !tbaa !9
  br label %87

87:                                               ; preds = %80
  %88 = load i32, ptr %6, align 4, !tbaa !9
  %89 = icmp slt i32 %88, 500
  %90 = xor i1 %89, true
  %91 = xor i1 %90, true
  %92 = xor i1 %91, true
  %93 = zext i1 %92 to i32
  %94 = sext i32 %93 to i64
  %95 = call i64 @llvm.expect.i64(i64 %94, i64 0)
  %96 = icmp ne i64 %95, 0
  br i1 %96, label %97, label %98

97:                                               ; preds = %87
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 4, ptr noundef @.str, i32 noundef 500)
  call void @exit(i32 noundef 0) #11
  unreachable

98:                                               ; preds = %87
  %99 = getelementptr inbounds [500 x i8], ptr %8, i64 0, i64 0
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = load i32, ptr %6, align 4, !tbaa !9
  %102 = sext i32 %101 to i64
  %103 = call ptr @strncpy(ptr noundef %99, ptr noundef %100, i64 noundef %102) #9
  %104 = load i32, ptr %6, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [500 x i8], ptr %8, i64 0, i64 %105
  store i8 0, ptr %106, align 1, !tbaa !11
  %107 = load i32, ptr %6, align 4, !tbaa !9
  %108 = add nsw i32 %107, 1
  %109 = load ptr, ptr %4, align 8, !tbaa !5
  %110 = sext i32 %108 to i64
  %111 = getelementptr inbounds i8, ptr %109, i64 %110
  store ptr %111, ptr %4, align 8, !tbaa !5
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = call i64 @atoll(ptr noundef %112) #10
  %114 = trunc i64 %113 to i32
  store i32 %114, ptr %7, align 4, !tbaa !9
  %115 = getelementptr inbounds [500 x i8], ptr %8, i64 0, i64 0
  %116 = load i32, ptr %7, align 4, !tbaa !9
  call void (ptr, i32, ...) @init_redis(ptr noundef %115, i32 noundef %116)
  br label %117

117:                                              ; preds = %98, %78
  %118 = load i32, ptr @output_mode, align 4, !tbaa !9
  %119 = or i32 %118, 1
  store i32 %119, ptr @output_mode, align 4, !tbaa !9
  br label %120

120:                                              ; preds = %117, %67, %64
  call void @llvm.lifetime.end.p0(i64 500, ptr %8) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #9
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #3

declare void @init_file(...) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.expect.i64(i64, i64) #5

declare void @mmt_sec_log(i32 noundef, ptr noundef, ...) #4

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #6

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #7

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i64 @atoll(ptr noundef nonnull) #8

declare void @init_redis(...) #4

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind willreturn memory(read) "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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #6 = { 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 #7 = { 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 #8 = { inlinehint nounwind willreturn memory(read) 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 #9 = { nounwind }
attributes #10 = { nounwind willreturn memory(read) }
attributes #11 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}


; 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 = external hidden unnamed_addr constant [30 x i8], align 1
@output_mode = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @verdict_printer_init(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca [500 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 500, ptr nonnull %3) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(500) %3, i8 0, i64 500, i1 false)
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %28, label %4

4:                                                ; preds = %2
  %5 = load i8, ptr %0, align 1, !tbaa !5
  %.not32 = icmp eq i8 %5, 0
  br i1 %.not32, label %28, label %6

6:                                                ; preds = %4
  %7 = tail call ptr @strchr(ptr noundef nonnull dereferenceable(1) %0, i32 noundef 58) #9
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  tail call void (ptr, i32, ...) @init_file(ptr noundef nonnull %0, i32 noundef 0) #8
  br label %25

10:                                               ; preds = %6
  %11 = ptrtoint ptr %7 to i64
  %12 = ptrtoint ptr %0 to i64
  %13 = sub i64 %11, %12
  %14 = trunc i64 %13 to i32
  %15 = icmp sgt i32 %14, 499
  br i1 %15, label %16, label %17, !prof !8

16:                                               ; preds = %10
  tail call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 4, ptr noundef nonnull @.str, i32 noundef 500) #8
  tail call void @exit(i32 noundef 0) #10
  unreachable

17:                                               ; preds = %10
  %sext = shl i64 %13, 32
  %18 = ashr exact i64 %sext, 32
  %19 = call ptr @strncpy(ptr noundef nonnull %3, ptr noundef nonnull %0, i64 noundef %18) #8
  %20 = getelementptr inbounds [500 x i8], ptr %3, i64 0, i64 %18
  store i8 0, ptr %20, align 1, !tbaa !5
  %sext33 = add i64 %sext, 4294967296
  %21 = ashr exact i64 %sext33, 32
  %22 = getelementptr inbounds i8, ptr %0, i64 %21
  %23 = call i64 @atoll(ptr nocapture noundef %22) #9
  %24 = trunc i64 %23 to i32
  call void (ptr, i32, ...) @init_file(ptr noundef nonnull %3, i32 noundef %24) #8
  br label %25

25:                                               ; preds = %17, %9
  %26 = load i32, ptr @output_mode, align 4, !tbaa !9
  %27 = or i32 %26, 2
  store i32 %27, ptr @output_mode, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %25, %4, %2
  %.not34 = icmp eq ptr %1, null
  br i1 %.not34, label %53, label %29

29:                                               ; preds = %28
  %30 = load i8, ptr %1, align 1, !tbaa !5
  %.not35 = icmp eq i8 %30, 0
  br i1 %.not35, label %53, label %31

31:                                               ; preds = %29
  %32 = call ptr @strchr(ptr noundef nonnull dereferenceable(1) %1, i32 noundef 58) #9
  %33 = icmp eq ptr %32, null
  br i1 %33, label %34, label %35

34:                                               ; preds = %31
  call void (ptr, i32, ...) @init_redis(ptr noundef nonnull %1, i32 noundef 6379) #8
  br label %50

35:                                               ; preds = %31
  %36 = ptrtoint ptr %32 to i64
  %37 = ptrtoint ptr %1 to i64
  %38 = sub i64 %36, %37
  %39 = trunc i64 %38 to i32
  %40 = icmp sgt i32 %39, 499
  br i1 %40, label %41, label %42, !prof !8

41:                                               ; preds = %35
  call void (i32, ptr, ...) @mmt_sec_log(i32 noundef 4, ptr noundef nonnull @.str, i32 noundef 500) #8
  call void @exit(i32 noundef 0) #10
  unreachable

42:                                               ; preds = %35
  %sext36 = shl i64 %38, 32
  %43 = ashr exact i64 %sext36, 32
  %44 = call ptr @strncpy(ptr noundef nonnull %3, ptr noundef nonnull %1, i64 noundef %43) #8
  %45 = getelementptr inbounds [500 x i8], ptr %3, i64 0, i64 %43
  store i8 0, ptr %45, align 1, !tbaa !5
  %sext37 = add i64 %sext36, 4294967296
  %46 = ashr exact i64 %sext37, 32
  %47 = getelementptr inbounds i8, ptr %1, i64 %46
  %48 = call i64 @atoll(ptr nocapture noundef %47) #9
  %49 = trunc i64 %48 to i32
  call void (ptr, i32, ...) @init_redis(ptr noundef nonnull %3, i32 noundef %49) #8
  br label %50

50:                                               ; preds = %42, %34
  %51 = load i32, ptr @output_mode, align 4, !tbaa !9
  %52 = or i32 %51, 1
  store i32 %52, ptr @output_mode, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %50, %29, %28
  call void @llvm.lifetime.end.p0(i64 500, ptr nonnull %3) #8
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #3

declare void @init_file(...) local_unnamed_addr #4

declare void @mmt_sec_log(i32 noundef, ptr noundef, ...) local_unnamed_addr #4

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #6

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i64 @atoll(ptr nocapture noundef nonnull) local_unnamed_addr #7

declare void @init_redis(...) local_unnamed_addr #4

; 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { "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 = { 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 #6 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 #7 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { 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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !6, i64 0}


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