; LLVM IR from trustwallet/wallet-core :: trezor-crypto/crypto/monero (range_proof)

; 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.Hasher = type { i32, %union.anon, ptr, i32 }
%union.anon = type { %struct.SHA3_CTX }
%struct.SHA3_CTX = type { [25 x i64], [24 x i64], i32, i32 }
%struct.ge25519_t = type { [10 x i32], [10 x i32], [10 x i32], [10 x i32] }
%struct.range_sig = type { %struct.xmr_boro_sig, [64 x [32 x i8]] }
%struct.xmr_boro_sig = type { [64 x [32 x i8]], [64 x [32 x i8]], [32 x i8] }

@ge25519_niels_base_multiples = external constant [256 x [96 x i8]], align 16

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @xmr_gen_range_sig_ex(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #2 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca [9 x i32], align 16
  %17 = alloca [9 x i32], align 16
  %18 = alloca [9 x i32], align 16
  %19 = alloca [9 x i32], align 16
  %20 = alloca [32 x i8], align 16
  %21 = alloca %struct.Hasher, align 8
  %22 = alloca %struct.ge25519_t, align 4
  %23 = alloca %struct.ge25519_t, align 4
  %24 = alloca %struct.ge25519_t, align 4
  %25 = alloca %struct.ge25519_t, align 4
  %26 = alloca %struct.ge25519_t, align 4
  %27 = alloca i32, align 4
  %28 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i64 %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 64, ptr %15, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 36, ptr %16) #4
  call void @llvm.memset.p0.i64(ptr align 16 %16, i8 0, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 36, ptr %17) #4
  call void @llvm.memset.p0.i64(ptr align 16 %17, i8 0, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 36, ptr %18) #4
  call void @llvm.memset.p0.i64(ptr align 16 %18, i8 0, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 36, ptr %19) #4
  call void @llvm.memset.p0.i64(ptr align 16 %19, i8 0, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr %20) #4
  call void @llvm.memset.p0.i64(ptr align 16 %20, i8 0, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 424, ptr %21) #4
  call void @llvm.memset.p0.i64(ptr align 8 %21, i8 0, i64 424, i1 false)
  call void @xmr_hasher_init(ptr noundef %21)
  call void @llvm.lifetime.start.p0(i64 160, ptr %22) #4
  call void @llvm.memset.p0.i64(ptr align 4 %22, i8 0, i64 160, i1 false)
  call void @llvm.lifetime.start.p0(i64 160, ptr %23) #4
  call void @llvm.memset.p0.i64(ptr align 4 %23, i8 0, i64 160, i1 false)
  call void @llvm.lifetime.start.p0(i64 160, ptr %24) #4
  call void @llvm.memset.p0.i64(ptr align 4 %24, i8 0, i64 160, i1 false)
  call void @llvm.lifetime.start.p0(i64 160, ptr %25) #4
  call void @llvm.memset.p0.i64(ptr align 4 %25, i8 0, i64 160, i1 false)
  call void @llvm.lifetime.start.p0(i64 160, ptr %26) #4
  call void @llvm.memset.p0.i64(ptr align 4 %26, i8 0, i64 160, i1 false)
  call void @ge25519_set_neutral(ptr noundef %26)
  call void @ge25519_set_neutral(ptr noundef %22)
  call void @ge25519_set_xmr_h(ptr noundef %23)
  %29 = getelementptr inbounds [9 x i32], ptr %16, i64 0, i64 0
  call void @set256_modm(ptr noundef %29, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #4
  store i32 0, ptr %27, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %115, %7
  %31 = load i32, ptr %27, align 4, !tbaa !11
  %32 = icmp ult i32 %31, 64
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #4
  br label %118

34:                                               ; preds = %30
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = load i32, ptr %27, align 4, !tbaa !11
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds [9 x i32], ptr %35, i64 %37
  %39 = getelementptr inbounds [9 x i32], ptr %38, i64 0, i64 0
  call void @xmr_random_scalar(ptr noundef %39)
  %40 = load ptr, ptr %12, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %54

42:                                               ; preds = %34
  %43 = load i32, ptr %27, align 4, !tbaa !11
  %44 = icmp eq i32 %43, 63
  br i1 %44, label %45, label %54

45:                                               ; preds = %42
  %46 = load ptr, ptr %13, align 8, !tbaa !5
  %47 = load i32, ptr %27, align 4, !tbaa !11
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds [9 x i32], ptr %46, i64 %48
  %50 = getelementptr inbounds [9 x i32], ptr %49, i64 0, i64 0
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  %52 = getelementptr inbounds [9 x i32], ptr %51, i64 0, i64 0
  %53 = getelementptr inbounds [9 x i32], ptr %16, i64 0, i64 0
  call void @sub256_modm(ptr noundef %50, ptr noundef %52, ptr noundef %53)
  br label %54

54:                                               ; preds = %45, %42, %34
  %55 = getelementptr inbounds [9 x i32], ptr %16, i64 0, i64 0
  %56 = getelementptr inbounds [9 x i32], ptr %16, i64 0, i64 0
  %57 = load ptr, ptr %13, align 8, !tbaa !5
  %58 = load i32, ptr %27, align 4, !tbaa !11
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds [9 x i32], ptr %57, i64 %59
  %61 = getelementptr inbounds [9 x i32], ptr %60, i64 0, i64 0
  call void @add256_modm(ptr noundef %55, ptr noundef %56, ptr noundef %61)
  %62 = load ptr, ptr %14, align 8, !tbaa !5
  %63 = load i32, ptr %27, align 4, !tbaa !11
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds [9 x i32], ptr %62, i64 %64
  %66 = getelementptr inbounds [9 x i32], ptr %65, i64 0, i64 0
  call void @xmr_random_scalar(ptr noundef %66)
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = load i32, ptr %27, align 4, !tbaa !11
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds [9 x i32], ptr %67, i64 %69
  %71 = getelementptr inbounds [9 x i32], ptr %70, i64 0, i64 0
  call void @ge25519_scalarmult_base_niels(ptr noundef %25, ptr noundef @ge25519_niels_base_multiples, ptr noundef %71)
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = load i32, ptr %27, align 4, !tbaa !11
  %74 = zext i32 %73 to i64
  %75 = getelementptr inbounds [9 x i32], ptr %72, i64 %74
  %76 = getelementptr inbounds [9 x i32], ptr %75, i64 0, i64 0
  call void @ge25519_scalarmult_base_niels(ptr noundef %24, ptr noundef @ge25519_niels_base_multiples, ptr noundef %76)
  %77 = load i64, ptr %11, align 8, !tbaa !9
  %78 = load i32, ptr %27, align 4, !tbaa !11
  %79 = zext i32 %78 to i64
  %80 = lshr i64 %77, %79
  %81 = and i64 %80, 1
  %82 = icmp eq i64 %81, 0
  br i1 %82, label %83, label %84

83:                                               ; preds = %54
  br label %85

84:                                               ; preds = %54
  br label %85

85:                                               ; preds = %84, %83
  %86 = phi ptr [ %26, %83 ], [ %23, %84 ]
  call void @ge25519_add(ptr noundef %24, ptr noundef %24, ptr noundef %86, i8 noundef zeroext 0)
  call void @ge25519_add(ptr noundef %22, ptr noundef %22, ptr noundef %24, i8 noundef zeroext 0)
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.range_sig, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %27, align 4, !tbaa !11
  %90 = zext i32 %89 to i64
  %91 = getelementptr inbounds [64 x [32 x i8]], ptr %88, i64 0, i64 %90
  %92 = getelementptr inbounds [32 x i8], ptr %91, i64 0, i64 0
  call void @ge25519_pack(ptr noundef %92, ptr noundef %24)
  %93 = load i64, ptr %11, align 8, !tbaa !9
  %94 = load i32, ptr %27, align 4, !tbaa !11
  %95 = zext i32 %94 to i64
  %96 = lshr i64 %93, %95
  %97 = and i64 %96, 1
  %98 = icmp eq i64 %97, 0
  br i1 %98, label %99, label %112

99:                                               ; preds = %85
  %100 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 0
  call void @xmr_random_scalar(ptr noundef %100)
  %101 = getelementptr inbounds [9 x i32], ptr %18, i64 0, i64 0
  call void @xmr_hash_ge25519_to_scalar(ptr noundef %101, ptr noundef %25)
  call void @ge25519_add(ptr noundef %24, ptr noundef %24, ptr noundef %23, i8 noundef zeroext 1)
  %102 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 0
  %103 = getelementptr inbounds [9 x i32], ptr %18, i64 0, i64 0
  call void @xmr_add_keys2_vartime(ptr noundef %25, ptr noundef %102, ptr noundef %103, ptr noundef %24)
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.range_sig, ptr %104, i32 0, i32 0
  %106 = getelementptr inbounds %struct.xmr_boro_sig, ptr %105, i32 0, i32 1
  %107 = load i32, ptr %27, align 4, !tbaa !11
  %108 = zext i32 %107 to i64
  %109 = getelementptr inbounds [64 x [32 x i8]], ptr %106, i64 0, i64 %108
  %110 = getelementptr inbounds [32 x i8], ptr %109, i64 0, i64 0
  %111 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 0
  call void @contract256_modm(ptr noundef %110, ptr noundef %111)
  br label %112

112:                                              ; preds = %99, %85
  %113 = getelementptr inbounds [32 x i8], ptr %20, i64 0, i64 0
  call void @ge25519_pack(ptr noundef %113, ptr noundef %25)
  %114 = getelementptr inbounds [32 x i8], ptr %20, i64 0, i64 0
  call void @xmr_hasher_update(ptr noundef %21, ptr noundef %114, i64 noundef 32)
  call void @ge25519_double(ptr noundef %23, ptr noundef %23)
  br label %115

115:                                              ; preds = %112
  %116 = load i32, ptr %27, align 4, !tbaa !11
  %117 = add i32 %116, 1
  store i32 %117, ptr %27, align 4, !tbaa !11
  br label %30, !llvm.loop !13

118:                                              ; preds = %33
  %119 = getelementptr inbounds [32 x i8], ptr %20, i64 0, i64 0
  call void @xmr_hasher_final(ptr noundef %21, ptr noundef %119)
  %120 = getelementptr inbounds [9 x i32], ptr %19, i64 0, i64 0
  %121 = getelementptr inbounds [32 x i8], ptr %20, i64 0, i64 0
  call void @expand256_modm(ptr noundef %120, ptr noundef %121, i64 noundef 32)
  call void @ge25519_set_xmr_h(ptr noundef %23)
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #4
  store i32 0, ptr %28, align 4, !tbaa !11
  br label %122

122:                                              ; preds = %195, %118
  %123 = load i32, ptr %28, align 4, !tbaa !11
  %124 = icmp ult i32 %123, 64
  br i1 %124, label %126, label %125

125:                                              ; preds = %122
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #4
  br label %198

126:                                              ; preds = %122
  %127 = load i64, ptr %11, align 8, !tbaa !9
  %128 = load i32, ptr %28, align 4, !tbaa !11
  %129 = zext i32 %128 to i64
  %130 = lshr i64 %127, %129
  %131 = and i64 %130, 1
  %132 = icmp eq i64 %131, 0
  br i1 %132, label %133, label %154

133:                                              ; preds = %126
  %134 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 0
  %135 = load ptr, ptr %13, align 8, !tbaa !5
  %136 = load i32, ptr %28, align 4, !tbaa !11
  %137 = zext i32 %136 to i64
  %138 = getelementptr inbounds [9 x i32], ptr %135, i64 %137
  %139 = getelementptr inbounds [9 x i32], ptr %138, i64 0, i64 0
  %140 = getelementptr inbounds [9 x i32], ptr %19, i64 0, i64 0
  %141 = load ptr, ptr %14, align 8, !tbaa !5
  %142 = load i32, ptr %28, align 4, !tbaa !11
  %143 = zext i32 %142 to i64
  %144 = getelementptr inbounds [9 x i32], ptr %141, i64 %143
  %145 = getelementptr inbounds [9 x i32], ptr %144, i64 0, i64 0
  call void @mulsub256_modm(ptr noundef %134, ptr noundef %139, ptr noundef %140, ptr noundef %145)
  %146 = load ptr, ptr %8, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.range_sig, ptr %146, i32 0, i32 0
  %148 = getelementptr inbounds %struct.xmr_boro_sig, ptr %147, i32 0, i32 0
  %149 = load i32, ptr %28, align 4, !tbaa !11
  %150 = zext i32 %149 to i64
  %151 = getelementptr inbounds [64 x [32 x i8]], ptr %148, i64 0, i64 %150
  %152 = getelementptr inbounds [32 x i8], ptr %151, i64 0, i64 0
  %153 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 0
  call void @contract256_modm(ptr noundef %152, ptr noundef %153)
  br label %194

154:                                              ; preds = %126
  %155 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 0
  call void @xmr_random_scalar(ptr noundef %155)
  %156 = load ptr, ptr %8, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.range_sig, ptr %156, i32 0, i32 0
  %158 = getelementptr inbounds %struct.xmr_boro_sig, ptr %157, i32 0, i32 0
  %159 = load i32, ptr %28, align 4, !tbaa !11
  %160 = zext i32 %159 to i64
  %161 = getelementptr inbounds [64 x [32 x i8]], ptr %158, i64 0, i64 %160
  %162 = getelementptr inbounds [32 x i8], ptr %161, i64 0, i64 0
  %163 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 0
  call void @contract256_modm(ptr noundef %162, ptr noundef %163)
  %164 = load ptr, ptr %8, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct.range_sig, ptr %164, i32 0, i32 1
  %166 = load i32, ptr %28, align 4, !tbaa !11
  %167 = zext i32 %166 to i64
  %168 = getelementptr inbounds [64 x [32 x i8]], ptr %165, i64 0, i64 %167
  %169 = getelementptr inbounds [32 x i8], ptr %168, i64 0, i64 0
  %170 = call i32 @ge25519_unpack_vartime(ptr noundef %24, ptr noundef %169)
  %171 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 0
  %172 = getelementptr inbounds [9 x i32], ptr %19, i64 0, i64 0
  call void @xmr_add_keys2_vartime(ptr noundef %25, ptr noundef %171, ptr noundef %172, ptr noundef %24)
  %173 = getelementptr inbounds [9 x i32], ptr %18, i64 0, i64 0
  call void @xmr_hash_ge25519_to_scalar(ptr noundef %173, ptr noundef %25)
  %174 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 0
  %175 = load ptr, ptr %13, align 8, !tbaa !5
  %176 = load i32, ptr %28, align 4, !tbaa !11
  %177 = zext i32 %176 to i64
  %178 = getelementptr inbounds [9 x i32], ptr %175, i64 %177
  %179 = getelementptr inbounds [9 x i32], ptr %178, i64 0, i64 0
  %180 = getelementptr inbounds [9 x i32], ptr %18, i64 0, i64 0
  %181 = load ptr, ptr %14, align 8, !tbaa !5
  %182 = load i32, ptr %28, align 4, !tbaa !11
  %183 = zext i32 %182 to i64
  %184 = getelementptr inbounds [9 x i32], ptr %181, i64 %183
  %185 = getelementptr inbounds [9 x i32], ptr %184, i64 0, i64 0
  call void @mulsub256_modm(ptr noundef %174, ptr noundef %179, ptr noundef %180, ptr noundef %185)
  %186 = load ptr, ptr %8, align 8, !tbaa !5
  %187 = getelementptr inbounds %struct.range_sig, ptr %186, i32 0, i32 0
  %188 = getelementptr inbounds %struct.xmr_boro_sig, ptr %187, i32 0, i32 1
  %189 = load i32, ptr %28, align 4, !tbaa !11
  %190 = zext i32 %189 to i64
  %191 = getelementptr inbounds [64 x [32 x i8]], ptr %188, i64 0, i64 %190
  %192 = getelementptr inbounds [32 x i8], ptr %191, i64 0, i64 0
  %193 = getelementptr inbounds [9 x i32], ptr %17, i64 0, i64 0
  call void @contract256_modm(ptr noundef %192, ptr noundef %193)
  br label %194

194:                                              ; preds = %154, %133
  call void @ge25519_double(ptr noundef %23, ptr noundef %23)
  br label %195

195:                                              ; preds = %194
  %196 = load i32, ptr %28, align 4, !tbaa !11
  %197 = add i32 %196, 1
  store i32 %197, ptr %28, align 4, !tbaa !11
  br label %122, !llvm.loop !15

198:                                              ; preds = %125
  %199 = load ptr, ptr %9, align 8, !tbaa !5
  call void @ge25519_copy(ptr noundef %199, ptr noundef %22)
  %200 = load ptr, ptr %10, align 8, !tbaa !5
  %201 = getelementptr inbounds [9 x i32], ptr %16, i64 0, i64 0
  call void @copy256_modm(ptr noundef %200, ptr noundef %201)
  %202 = load ptr, ptr %8, align 8, !tbaa !5
  %203 = getelementptr inbounds %struct.range_sig, ptr %202, i32 0, i32 0
  %204 = getelementptr inbounds %struct.xmr_boro_sig, ptr %203, i32 0, i32 2
  %205 = getelementptr inbounds [32 x i8], ptr %204, i64 0, i64 0
  %206 = getelementptr inbounds [9 x i32], ptr %19, i64 0, i64 0
  call void @contract256_modm(ptr noundef %205, ptr noundef %206)
  call void @llvm.lifetime.end.p0(i64 160, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 424, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  ret void
}

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

declare void @xmr_hasher_init(ptr noundef) #3

declare void @ge25519_set_neutral(ptr noundef) #3

declare void @ge25519_set_xmr_h(ptr noundef) #3

declare void @set256_modm(ptr noundef, i64 noundef) #3

declare void @xmr_random_scalar(ptr noundef) #3

declare void @sub256_modm(ptr noundef, ptr noundef, ptr noundef) #3

declare void @add256_modm(ptr noundef, ptr noundef, ptr noundef) #3

declare void @ge25519_scalarmult_base_niels(ptr noundef, ptr noundef, ptr noundef) #3

declare void @ge25519_add(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) #3

declare void @ge25519_pack(ptr noundef, ptr noundef) #3

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

declare void @xmr_add_keys2_vartime(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

declare void @contract256_modm(ptr noundef, ptr noundef) #3

declare void @xmr_hasher_update(ptr noundef, ptr noundef, i64 noundef) #3

declare void @ge25519_double(ptr noundef, ptr noundef) #3

declare void @xmr_hasher_final(ptr noundef, ptr noundef) #3

declare void @expand256_modm(ptr noundef, ptr noundef, i64 noundef) #3

declare void @mulsub256_modm(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

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

declare void @ge25519_copy(ptr noundef, ptr noundef) #3

declare void @copy256_modm(ptr noundef, ptr noundef) #3

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

!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 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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.Hasher = type { i32, %union.anon, ptr, i32 }
%union.anon = type { %struct.SHA3_CTX }
%struct.SHA3_CTX = type { [25 x i64], [24 x i64], i32, i32 }
%struct.ge25519_t = type { [10 x i32], [10 x i32], [10 x i32], [10 x i32] }

@ge25519_niels_base_multiples = external constant [256 x [96 x i8]], align 16

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @xmr_gen_range_sig_ex(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) local_unnamed_addr #2 {
  %8 = alloca [9 x i32], align 16
  %9 = alloca [9 x i32], align 16
  %10 = alloca [9 x i32], align 16
  %11 = alloca [9 x i32], align 16
  %12 = alloca [32 x i8], align 16
  %13 = alloca %struct.Hasher, align 8
  %14 = alloca %struct.ge25519_t, align 4
  %15 = alloca %struct.ge25519_t, align 4
  %16 = alloca %struct.ge25519_t, align 4
  %17 = alloca %struct.ge25519_t, align 4
  %18 = alloca %struct.ge25519_t, align 4
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %8) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(36) %8, i8 0, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %9) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(36) %9, i8 0, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %10) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(36) %10, i8 0, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %11) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(36) %11, i8 0, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %12) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %12, i8 0, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 424, ptr nonnull %13) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(424) %13, i8 0, i64 424, i1 false)
  call void @xmr_hasher_init(ptr noundef nonnull %13) #4
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %14) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(160) %14, i8 0, i64 160, i1 false)
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %15) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(160) %15, i8 0, i64 160, i1 false)
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %16) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(160) %16, i8 0, i64 160, i1 false)
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %17) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(160) %17, i8 0, i64 160, i1 false)
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %18) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(160) %18, i8 0, i64 160, i1 false)
  call void @ge25519_set_neutral(ptr noundef nonnull %18) #4
  call void @ge25519_set_neutral(ptr noundef nonnull %14) #4
  call void @ge25519_set_xmr_h(ptr noundef nonnull %15) #4
  call void @set256_modm(ptr noundef nonnull %8, i64 noundef 0) #4
  %19 = icmp ne ptr %4, null
  %20 = getelementptr inbounds i8, ptr %0, i64 4128
  %21 = getelementptr inbounds i8, ptr %0, i64 2048
  br label %23

22:                                               ; preds = %35
  call void @xmr_hasher_final(ptr noundef nonnull %13, ptr noundef nonnull %12) #4
  call void @expand256_modm(ptr noundef nonnull %11, ptr noundef nonnull %12, i64 noundef 32) #4
  call void @ge25519_set_xmr_h(ptr noundef nonnull %15) #4
  br label %38

23:                                               ; preds = %7, %35
  %indvars.iv = phi i64 [ 0, %7 ], [ %indvars.iv.next, %35 ]
  %24 = getelementptr inbounds [9 x i32], ptr %5, i64 %indvars.iv
  call void @xmr_random_scalar(ptr noundef %24) #4
  %25 = icmp eq i64 %indvars.iv, 63
  %or.cond = and i1 %19, %25
  br i1 %or.cond, label %26, label %27

26:                                               ; preds = %23
  call void @sub256_modm(ptr noundef nonnull %24, ptr noundef nonnull %4, ptr noundef nonnull %8) #4
  br label %27

27:                                               ; preds = %26, %23
  call void @add256_modm(ptr noundef nonnull %8, ptr noundef nonnull %8, ptr noundef %24) #4
  %28 = getelementptr inbounds [9 x i32], ptr %6, i64 %indvars.iv
  call void @xmr_random_scalar(ptr noundef %28) #4
  call void @ge25519_scalarmult_base_niels(ptr noundef nonnull %17, ptr noundef nonnull @ge25519_niels_base_multiples, ptr noundef %28) #4
  call void @ge25519_scalarmult_base_niels(ptr noundef nonnull %16, ptr noundef nonnull @ge25519_niels_base_multiples, ptr noundef %24) #4
  %29 = shl nuw i64 1, %indvars.iv
  %30 = and i64 %29, %3
  %31 = icmp eq i64 %30, 0
  %. = select i1 %31, ptr %18, ptr %15
  call void @ge25519_add(ptr noundef nonnull %16, ptr noundef nonnull %16, ptr noundef nonnull %., i8 noundef zeroext 0) #4
  call void @ge25519_add(ptr noundef nonnull %14, ptr noundef nonnull %14, ptr noundef nonnull %16, i8 noundef zeroext 0) #4
  %32 = getelementptr inbounds [64 x [32 x i8]], ptr %20, i64 0, i64 %indvars.iv
  call void @ge25519_pack(ptr noundef nonnull %32, ptr noundef nonnull %16) #4
  br i1 %31, label %33, label %35

33:                                               ; preds = %27
  call void @xmr_random_scalar(ptr noundef nonnull %9) #4
  call void @xmr_hash_ge25519_to_scalar(ptr noundef nonnull %10, ptr noundef nonnull %17)
  call void @ge25519_add(ptr noundef nonnull %16, ptr noundef nonnull %16, ptr noundef nonnull %15, i8 noundef zeroext 1) #4
  call void @xmr_add_keys2_vartime(ptr noundef nonnull %17, ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %16) #4
  %34 = getelementptr inbounds [64 x [32 x i8]], ptr %21, i64 0, i64 %indvars.iv
  call void @contract256_modm(ptr noundef nonnull %34, ptr noundef nonnull %9) #4
  br label %35

35:                                               ; preds = %33, %27
  call void @ge25519_pack(ptr noundef nonnull %12, ptr noundef nonnull %17) #4
  call void @xmr_hasher_update(ptr noundef nonnull %13, ptr noundef nonnull %12, i64 noundef 32) #4
  call void @ge25519_double(ptr noundef nonnull %15, ptr noundef nonnull %15) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %22, label %23, !llvm.loop !5

36:                                               ; preds = %53
  call void @ge25519_copy(ptr noundef %1, ptr noundef nonnull %14) #4
  call void @copy256_modm(ptr noundef %2, ptr noundef nonnull %8) #4
  %37 = getelementptr inbounds i8, ptr %0, i64 4096
  call void @contract256_modm(ptr noundef nonnull %37, ptr noundef nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %18) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %17) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %16) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %15) #4
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %14) #4
  call void @llvm.lifetime.end.p0(i64 424, ptr nonnull %13) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %12) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %8) #4
  ret void

38:                                               ; preds = %22, %53
  %indvars.iv53 = phi i64 [ 0, %22 ], [ %indvars.iv.next54, %53 ]
  %39 = shl nuw i64 1, %indvars.iv53
  %40 = and i64 %39, %3
  %41 = icmp eq i64 %40, 0
  br i1 %41, label %42, label %46

42:                                               ; preds = %38
  %43 = getelementptr inbounds [9 x i32], ptr %5, i64 %indvars.iv53
  %44 = getelementptr inbounds [9 x i32], ptr %6, i64 %indvars.iv53
  call void @mulsub256_modm(ptr noundef nonnull %9, ptr noundef %43, ptr noundef nonnull %11, ptr noundef %44) #4
  %45 = getelementptr inbounds [64 x [32 x i8]], ptr %0, i64 0, i64 %indvars.iv53
  call void @contract256_modm(ptr noundef %45, ptr noundef nonnull %9) #4
  br label %53

46:                                               ; preds = %38
  call void @xmr_random_scalar(ptr noundef nonnull %9) #4
  %47 = getelementptr inbounds [64 x [32 x i8]], ptr %0, i64 0, i64 %indvars.iv53
  call void @contract256_modm(ptr noundef %47, ptr noundef nonnull %9) #4
  %48 = getelementptr inbounds [64 x [32 x i8]], ptr %20, i64 0, i64 %indvars.iv53
  %49 = call i32 @ge25519_unpack_vartime(ptr noundef nonnull %16, ptr noundef nonnull %48) #4
  call void @xmr_add_keys2_vartime(ptr noundef nonnull %17, ptr noundef nonnull %9, ptr noundef nonnull %11, ptr noundef nonnull %16) #4
  call void @xmr_hash_ge25519_to_scalar(ptr noundef nonnull %10, ptr noundef nonnull %17)
  %50 = getelementptr inbounds [9 x i32], ptr %5, i64 %indvars.iv53
  %51 = getelementptr inbounds [9 x i32], ptr %6, i64 %indvars.iv53
  call void @mulsub256_modm(ptr noundef nonnull %9, ptr noundef %50, ptr noundef nonnull %10, ptr noundef %51) #4
  %52 = getelementptr inbounds [64 x [32 x i8]], ptr %21, i64 0, i64 %indvars.iv53
  call void @contract256_modm(ptr noundef nonnull %52, ptr noundef nonnull %9) #4
  br label %53

53:                                               ; preds = %46, %42
  call void @ge25519_double(ptr noundef nonnull %15, ptr noundef nonnull %15) #4
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %exitcond56.not = icmp eq i64 %indvars.iv.next54, 64
  br i1 %exitcond56.not, label %36, label %38, !llvm.loop !7
}

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

declare void @xmr_hasher_init(ptr noundef) local_unnamed_addr #3

declare void @ge25519_set_neutral(ptr noundef) local_unnamed_addr #3

declare void @ge25519_set_xmr_h(ptr noundef) local_unnamed_addr #3

declare void @set256_modm(ptr noundef, i64 noundef) local_unnamed_addr #3

declare void @xmr_random_scalar(ptr noundef) local_unnamed_addr #3

declare void @sub256_modm(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @add256_modm(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @ge25519_scalarmult_base_niels(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @ge25519_add(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #3

declare void @ge25519_pack(ptr noundef, ptr noundef) local_unnamed_addr #3

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

declare void @xmr_add_keys2_vartime(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @contract256_modm(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @xmr_hasher_update(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

declare void @ge25519_double(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @xmr_hasher_final(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @expand256_modm(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

declare void @mulsub256_modm(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @ge25519_unpack_vartime(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @ge25519_copy(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @copy256_modm(ptr noundef, ptr noundef) local_unnamed_addr #3

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

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


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