; LLVM IR from Montimage/mmt-security :: src/lib/expression.ll (parse_variable)

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

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

; 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
declare dso_local ptr @expr_create_a_variable(ptr noundef, ptr noundef, i16 noundef zeroext) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @_parse_a_proto_name(ptr noundef, ptr noundef, i64 noundef, i1 noundef zeroext) #1

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #3

; Function Attrs: nounwind uwtable
declare dso_local i64 @_parse_a_number(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @_parse_variable(ptr noundef %0, ptr noundef %1, i64 noundef %2) #1 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i16, align 2
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %13) #4
  store i16 -1, ptr %13, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  store ptr null, ptr %15, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %17, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = call i64 @_jump_space(ptr noundef %18, i64 noundef %19)
  store i64 %20, ptr %8, align 8, !tbaa !9
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %30, label %23

23:                                               ; preds = %3
  %24 = load i64, ptr %7, align 8, !tbaa !9
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %30, label %26

26:                                               ; preds = %23
  %27 = load i64, ptr %8, align 8, !tbaa !9
  %28 = load i64, ptr %7, align 8, !tbaa !9
  %29 = icmp eq i64 %27, %28
  br i1 %29, label %30, label %32

30:                                               ; preds = %26, %23, %3
  %31 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %31, ptr %4, align 8
  store i32 1, ptr %16, align 4
  br label %132

32:                                               ; preds = %26
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i64, ptr %8, align 8, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %33, i64 %34
  store ptr %35, ptr %14, align 8, !tbaa !5
  %36 = call ptr @__ctype_b_loc() #5
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = load ptr, ptr %14, align 8, !tbaa !5
  %39 = load i8, ptr %38, align 1, !tbaa !13
  %40 = sext i8 %39 to i32
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds i16, ptr %37, i64 %41
  %43 = load i16, ptr %42, align 2, !tbaa !11
  %44 = zext i16 %43 to i32
  %45 = and i32 %44, 2048
  %46 = icmp ne i32 %45, 0
  %47 = zext i1 %46 to i8
  store i8 %47, ptr %10, align 1, !tbaa !14
  %48 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %48, ptr %9, align 8, !tbaa !9
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  %50 = load i64, ptr %7, align 8, !tbaa !9
  %51 = call i64 @_parse_a_proto_name(ptr noundef %11, ptr noundef %49, i64 noundef %50, i1 noundef zeroext true)
  store i64 %51, ptr %8, align 8, !tbaa !9
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %130

54:                                               ; preds = %32
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load i64, ptr %8, align 8, !tbaa !9
  %57 = getelementptr inbounds i8, ptr %55, i64 %56
  %58 = load i8, ptr %57, align 1, !tbaa !13
  %59 = sext i8 %58 to i32
  %60 = icmp eq i32 %59, 46
  br i1 %60, label %61, label %118

61:                                               ; preds = %54
  %62 = load i64, ptr %8, align 8, !tbaa !9
  %63 = add i64 %62, 1
  store i64 %63, ptr %8, align 8, !tbaa !9
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load i64, ptr %8, align 8, !tbaa !9
  %66 = getelementptr inbounds i8, ptr %64, i64 %65
  store ptr %66, ptr %14, align 8, !tbaa !5
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = load i64, ptr %7, align 8, !tbaa !9
  %69 = load i64, ptr %8, align 8, !tbaa !9
  %70 = sub i64 %68, %69
  %71 = call i64 @_parse_a_proto_name(ptr noundef %12, ptr noundef %67, i64 noundef %70, i1 noundef zeroext true)
  %72 = load i64, ptr %8, align 8, !tbaa !9
  %73 = add i64 %72, %71
  store i64 %73, ptr %8, align 8, !tbaa !9
  %74 = load ptr, ptr %12, align 8, !tbaa !5
  %75 = icmp ne ptr %74, null
  br i1 %75, label %76, label %111

76:                                               ; preds = %61
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = load i64, ptr %8, align 8, !tbaa !9
  %79 = getelementptr inbounds i8, ptr %77, i64 %78
  %80 = load i8, ptr %79, align 1, !tbaa !13
  %81 = sext i8 %80 to i32
  %82 = icmp eq i32 %81, 46
  br i1 %82, label %83, label %104

83:                                               ; preds = %76
  %84 = load i64, ptr %8, align 8, !tbaa !9
  %85 = add i64 %84, 1
  store i64 %85, ptr %8, align 8, !tbaa !9
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = load i64, ptr %8, align 8, !tbaa !9
  %88 = getelementptr inbounds i8, ptr %86, i64 %87
  store ptr %88, ptr %14, align 8, !tbaa !5
  %89 = load ptr, ptr %14, align 8, !tbaa !5
  %90 = load i64, ptr %7, align 8, !tbaa !9
  %91 = load i64, ptr %8, align 8, !tbaa !9
  %92 = sub i64 %90, %91
  %93 = call i64 @_parse_a_number(ptr noundef %15, ptr noundef %89, i64 noundef %92)
  %94 = load i64, ptr %8, align 8, !tbaa !9
  %95 = add i64 %94, %93
  store i64 %95, ptr %8, align 8, !tbaa !9
  %96 = load ptr, ptr %15, align 8, !tbaa !5
  %97 = load double, ptr %96, align 8, !tbaa !16
  %98 = fptoui double %97 to i16
  store i16 %98, ptr %13, align 2, !tbaa !11
  br label %99

99:                                               ; preds = %83
  %100 = load ptr, ptr %15, align 8, !tbaa !5
  %101 = call i64 @mmt_mem_free(ptr noundef %100)
  store ptr null, ptr %15, align 8, !tbaa !5
  br label %102

102:                                              ; preds = %99
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103, %76
  %105 = load ptr, ptr %11, align 8, !tbaa !5
  %106 = load ptr, ptr %12, align 8, !tbaa !5
  %107 = load i16, ptr %13, align 2, !tbaa !11
  %108 = call ptr @expr_create_a_variable(ptr noundef %105, ptr noundef %106, i16 noundef zeroext %107)
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %108, ptr %109, align 8, !tbaa !5
  %110 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %110, ptr %4, align 8
  store i32 1, ptr %16, align 4
  br label %132

111:                                              ; preds = %61
  br label %112

112:                                              ; preds = %111
  %113 = load ptr, ptr %11, align 8, !tbaa !5
  %114 = call i64 @mmt_mem_free(ptr noundef %113)
  store ptr null, ptr %11, align 8, !tbaa !5
  br label %115

115:                                              ; preds = %112
  br label %116

116:                                              ; preds = %115
  br label %117

117:                                              ; preds = %116
  br label %129

118:                                              ; preds = %54
  %119 = load i8, ptr %10, align 1, !tbaa !14, !range !18, !noundef !19
  %120 = trunc i8 %119 to i1
  br i1 %120, label %121, label %128

121:                                              ; preds = %118
  br label %122

122:                                              ; preds = %121
  %123 = load ptr, ptr %11, align 8, !tbaa !5
  %124 = call i64 @mmt_mem_free(ptr noundef %123)
  store ptr null, ptr %11, align 8, !tbaa !5
  br label %125

125:                                              ; preds = %122
  br label %126

126:                                              ; preds = %125
  %127 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %127, ptr %4, align 8
  store i32 1, ptr %16, align 4
  br label %132

128:                                              ; preds = %118
  br label %129

129:                                              ; preds = %128, %117
  br label %130

130:                                              ; preds = %129, %32
  %131 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %131, ptr %4, align 8
  store i32 1, ptr %16, align 4
  br label %132

132:                                              ; preds = %130, %126, %104, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %133 = load i64, ptr %4, align 8
  ret i64 %133
}

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

!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", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}


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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @expr_create_a_variable(ptr noundef, ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @_parse_a_proto_name(ptr noundef, ptr noundef, i64 noundef, i1 noundef zeroext) local_unnamed_addr #1

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

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i64 @_parse_a_number(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i64 @_parse_variable(ptr nocapture noundef writeonly %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  store ptr null, ptr %6, align 8, !tbaa !5
  store ptr null, ptr %0, align 8, !tbaa !5
  %7 = tail call i64 @_jump_space(ptr noundef %1, i64 noundef %2)
  %8 = icmp eq ptr %1, null
  %9 = icmp eq i64 %2, 0
  %or.cond = or i1 %8, %9
  %10 = icmp eq i64 %7, %2
  %or.cond47 = select i1 %or.cond, i1 true, i1 %10
  br i1 %or.cond47, label %57, label %11

11:                                               ; preds = %3
  %12 = getelementptr inbounds i8, ptr %1, i64 %7
  %13 = tail call ptr @__ctype_b_loc() #5
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = load i8, ptr %12, align 1, !tbaa !9
  %16 = sext i8 %15 to i64
  %17 = getelementptr inbounds i16, ptr %14, i64 %16
  %18 = load i16, ptr %17, align 2, !tbaa !10
  %19 = and i16 %18, 2048
  %.not = icmp eq i16 %19, 0
  %20 = call i64 @_parse_a_proto_name(ptr noundef nonnull %4, ptr noundef nonnull %12, i64 noundef %2, i1 noundef zeroext true)
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %.not45 = icmp eq ptr %21, null
  br i1 %.not45, label %57, label %22

22:                                               ; preds = %11
  %23 = getelementptr inbounds i8, ptr %1, i64 %20
  %24 = load i8, ptr %23, align 1, !tbaa !9
  %25 = icmp eq i8 %24, 46
  br i1 %25, label %26, label %54

26:                                               ; preds = %22
  %27 = add i64 %20, 1
  %28 = getelementptr inbounds i8, ptr %1, i64 %27
  %29 = sub i64 %2, %27
  %30 = call i64 @_parse_a_proto_name(ptr noundef nonnull %5, ptr noundef %28, i64 noundef %29, i1 noundef zeroext true)
  %31 = add i64 %30, %27
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %.not46 = icmp eq ptr %32, null
  br i1 %.not46, label %51, label %33

33:                                               ; preds = %26
  %34 = getelementptr inbounds i8, ptr %1, i64 %31
  %35 = load i8, ptr %34, align 1, !tbaa !9
  %36 = icmp eq i8 %35, 46
  br i1 %36, label %37, label %47

37:                                               ; preds = %33
  %38 = add i64 %31, 1
  %39 = getelementptr inbounds i8, ptr %1, i64 %38
  %40 = sub i64 %2, %38
  %41 = call i64 @_parse_a_number(ptr noundef nonnull %6, ptr noundef %39, i64 noundef %40)
  %42 = add i64 %41, %38
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load double, ptr %43, align 8, !tbaa !12
  %45 = fptoui double %44 to i16
  %46 = call i64 @mmt_mem_free(ptr noundef nonnull %43)
  store ptr null, ptr %6, align 8, !tbaa !5
  %.pre = load ptr, ptr %5, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %37, %33
  %48 = phi ptr [ %.pre, %37 ], [ %32, %33 ]
  %.040 = phi i64 [ %42, %37 ], [ %31, %33 ]
  %.0 = phi i16 [ %45, %37 ], [ -1, %33 ]
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = call ptr @expr_create_a_variable(ptr noundef %49, ptr noundef %48, i16 noundef zeroext %.0)
  store ptr %50, ptr %0, align 8, !tbaa !5
  br label %57

51:                                               ; preds = %26
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = call i64 @mmt_mem_free(ptr noundef %52)
  br label %57

54:                                               ; preds = %22
  br i1 %.not, label %57, label %55

55:                                               ; preds = %54
  %56 = call i64 @mmt_mem_free(ptr noundef nonnull %21)
  br label %57

57:                                               ; preds = %11, %54, %51, %3, %55, %47
  %.039 = phi i64 [ %.040, %47 ], [ %7, %55 ], [ %7, %3 ], [ %31, %51 ], [ %20, %54 ], [ %20, %11 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  ret i64 %.039
}

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

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}


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