Coverage Report

Created: 2024-07-27 06:12

/src/lzma-fuzz/sdk/C/BraIA64.c
Line
Count
Source (jump to first uncovered line)
1
/* BraIA64.c -- Converter for IA-64 code
2
2017-01-26 : Igor Pavlov : Public domain */
3
4
#include "Precomp.h"
5
6
#include "CpuArch.h"
7
#include "Bra.h"
8
9
SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
10
12
{
11
12
  SizeT i;
12
12
  if (size < 16)
13
0
    return 0;
14
12
  size -= 16;
15
12
  i = 0;
16
12
  do
17
48
  {
18
48
    unsigned m = ((UInt32)0x334B0000 >> (data[i] & 0x1E)) & 3;
19
48
    if (m)
20
31
    {
21
31
      m++;
22
31
      do
23
71
      {
24
71
        Byte *p = data + (i + (size_t)m * 5 - 8);
25
71
        if (((p[3] >> m) & 15) == 5
26
71
            && (((p[-1] | ((UInt32)p[0] << 8)) >> m) & 0x70) == 0)
27
10
        {
28
10
          unsigned raw = GetUi32(p);
29
10
          unsigned v = raw >> m;
30
10
          v = (v & 0xFFFFF) | ((v & (1 << 23)) >> 3);
31
          
32
10
          v <<= 4;
33
10
          if (encoding)
34
0
            v += ip + (UInt32)i;
35
10
          else
36
10
            v -= ip + (UInt32)i;
37
10
          v >>= 4;
38
          
39
10
          v &= 0x1FFFFF;
40
10
          v += 0x700000;
41
10
          v &= 0x8FFFFF;
42
10
          raw &= ~((UInt32)0x8FFFFF << m);
43
10
          raw |= (v << m);
44
10
          SetUi32(p, raw);
45
10
        }
46
71
      }
47
71
      while (++m <= 4);
48
31
    }
49
48
    i += 16;
50
48
  }
51
48
  while (i <= size);
52
12
  return i;
53
12
}