`OSArchitecture` from `read_wmic` does not match a normal standard
 For example, `x86_64` shows as `64-bit`
422510
def read_wmic_cpu
      res = @backend.run_command('wmic cpu get architecture /format:list')
      if res.exit_status == 0
        sys_info = {}
        res.stdout.lines.each { |line|
          m = /^\s*([^=]*?)\s*=\s*(.*?)\s*$/.match(line)
          sys_info[m[1].to_sym] = m[2] unless m.nil? || m[1].nil?
        }
      end

      # This converts `wmic os get architecture` output to a normal standard
      # https://msdn.microsoft.com/en-us/library/aa394373(VS.85).aspx
      arch_map = {
        0 => 'i386',
        1 => 'mips',
        2 => 'alpha',
        3 => 'powerpc',
        5 => 'arm',
        6 => 'ia64',
        9 => 'x86_64',
      }

      # The value of `wmic cpu get architecture` is always a number between 0-9
      arch_number = sys_info[:Architecture].to_i
      arch_map[arch_number]
    end
97476
function platformPostfix() {
    if (/^win/.test(process.platform)) {
        return process.arch == 'x64' ? 'win64' : 'win32';
    } else if (/^darwin/.test(process.platform)) {
        return 'osx64';
    }
    // This might not be ideal, but we don't have anything else and there is always a chance that it will work
    return process.arch == 'x64' ? 'linux64' : 'linux32';
}
301988
@Override
	protected int detectTotalCpuPercent() throws Exception {
		Process process = null;
		try {

			// Execute command
			String cmd;
			if (command == null || command.isEmpty()) {
				String os = System.getProperty("os.name").toLowerCase();
				if (os.indexOf("win") >= 0) {

					// Windows command to query the actual CPU usage
					cmd = "wmic cpu get loadpercentage";

				} else {

					// Linux command to query the actual CPU usage
					cmd = "top -b -n2 -p 1 | fgrep \"Cpu(s)\" | tail -1 | awk -F'id,' -v prefix=\"$prefix\" "
							+ "'{ split($1, vs, \",\"); v=vs[length(vs)]; sub(\"%\", \"\", v); printf \"%s%.1f%%\n\", prefix, 100 - v }'";
				}
			} else {
				cmd = command;
			}
			process = Runtime.getRuntime().exec(cmd);
			BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
			StringBuilder tmp = new StringBuilder();
			String line = "";
			while ((line = reader.readLine()) != null) {
				tmp.setLength(0);
				char[] chars = line.toCharArray();
				for (char c : chars) {
					if (Character.isDigit(c)) {
						tmp.append(c);
					}
					if (c == ',' || c == '.') {
						tmp.append('.');
					}
				}
				if (tmp.length() > 0) {
					try {
						return (int) Double.parseDouble(tmp.toString());
					} catch (Exception ignored) {
					}
				}
			}
		} finally {
			if (process != null) {
				try {
					process.destroy();
				} catch (Exception ignored) {
				}
			}
		}
		return 0;
	}
765463
def _classify_arithmetic_load(self, regs_init, regs_fini, mem_fini, written_regs, read_regs):
        
        matches = []

        # Check for "dst_reg <- dst_reg OP mem[src_reg + offset]" pattern.
        for op_name, op_fn in self._binary_ops.items():
            for dst_reg, dst_val in regs_fini.items():
                # Make sure the *dst* register was read and written.
                if dst_reg not in written_regs or dst_reg not in read_regs:
                    continue

                dst_size = self._arch_regs_size[dst_reg]

                for addr in mem_fini.get_addresses():
                    success, val = mem_fini.try_read(addr, dst_size // 8)

                    if success and dst_val == op_fn(regs_init[dst_reg], val) & (2**dst_size - 1):

                        for src_reg, src_val in regs_init.items():
                            # Make sure the *src* register was read.
                            if src_reg not in read_regs:
                                continue

                            # Check restrictions.
                            if self._arch_regs_size[src_reg] != self._address_size:
                                continue

                            offset = (addr - src_val) & (2**self._address_size - 1)

                            src_reg_ir = ReilRegisterOperand(src_reg, self._arch_regs_size[src_reg])
                            src_off_ir = ReilImmediateOperand(offset, self._address_size)
                            dst_reg_ir = ReilRegisterOperand(dst_reg, self._arch_regs_size[dst_reg])

                            matches.append({
                                "src": [dst_reg_ir, src_reg_ir, src_off_ir],
                                "dst": [dst_reg_ir],
                                "op":  op_name
                            })

        # Check for "dst_reg <- dst_reg OP mem[offset]" pattern.
        for op_name, op_fn in self._binary_ops.items():
            for dst_reg, dst_val in regs_fini.items():
                # Make sure the *dst* register was read and written.
                if dst_reg not in written_regs or dst_reg not in read_regs:
                    continue

                dst_size = self._arch_regs_size[dst_reg]

                for addr in mem_fini.get_addresses():
                    success, val = mem_fini.try_read(addr, dst_size // 8)

                    if success and dst_val == op_fn(regs_init[dst_reg], val) & (2**dst_size - 1):
                        src_reg_ir = ReilEmptyOperand()
                        src_off_ir = ReilImmediateOperand(addr, self._address_size)
                        dst_reg_ir = ReilRegisterOperand(dst_reg, self._arch_regs_size[dst_reg])

                        matches.append({
                            "src": [dst_reg_ir, src_reg_ir, src_off_ir],
                            "dst": [dst_reg_ir],
                            "op":  op_name
                        })

        return matches
292213
def read_uint(self):
		
		if self.reader.sysinfo.ProcessorArchitecture == PROCESSOR_ARCHITECTURE.AMD64:
			return int.from_bytes(self.read(8), byteorder = 'little', signed = False)
		else:
			return int.from_bytes(self.read(4), byteorder = 'little', signed = False)
175029
def convert_prot(prot):
    
    # https://msdn.microsoft.com/en-us/library/windows/desktop/aa366786(v=vs.85).aspx
    if prot & 0x10:
        return 4
    if prot & 0x20:
        return 5
    if prot & 0x40:
        return 7
    if prot & 0x80:
        return 7
    if prot & 0x01:
        return 0
    if prot & 0x02:
        return 1
    if prot & 0x04:
        return 3
    if prot & 0x08:
        return 3
    raise angr.errors.SimValueError("Unknown windows memory protection constant: %#x" % prot)
129315
def get_build_platform():
    
    from sysconfig import get_platform

    plat = get_platform()
    if sys.platform == "darwin" and not plat.startswith('macosx-'):
        try:
            version = _macosx_vers()
            machine = os.uname()[4].replace(" ", "_")
            return "macosx-%d.%d-%s" % (
                int(version[0]), int(version[1]),
                _macosx_arch(machine),
            )
        except ValueError:
            # if someone is running a non-Mac darwin system, this will fall
            # through to the default implementation
            pass
    return plat
171802
public final void mOCTAL_ESC() throws RecognitionException {
		try {
			// druidG.g:741:5: ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) )
			int alt46=3;
			int LA46_0 = input.LA(1);
			if ( (LA46_0=='\\') ) {
				int LA46_1 = input.LA(2);
				if ( ((LA46_1 >= '0' && LA46_1 <= '3')) ) {
					int LA46_2 = input.LA(3);
					if ( ((LA46_2 >= '0' && LA46_2 <= '7')) ) {
						int LA46_4 = input.LA(4);
						if ( ((LA46_4 >= '0' && LA46_4 <= '7')) ) {
							alt46=1;
						}

						else {
							alt46=2;
						}

					}

					else {
						alt46=3;
					}

				}
				else if ( ((LA46_1 >= '4' && LA46_1 <= '7')) ) {
					int LA46_3 = input.LA(3);
					if ( ((LA46_3 >= '0' && LA46_3 <= '7')) ) {
						alt46=2;
					}

					else {
						alt46=3;
					}

				}

				else {
					int nvaeMark = input.mark();
					try {
						input.consume();
						NoViableAltException nvae =
							new NoViableAltException("", 46, 1, input);
						throw nvae;
					} finally {
						input.rewind(nvaeMark);
					}
				}

			}

			else {
				NoViableAltException nvae =
					new NoViableAltException("", 46, 0, input);
				throw nvae;
			}

			switch (alt46) {
				case 1 :
					// druidG.g:741:9: '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' )
					{
					match('\\'); 
					if ( (input.LA(1) >= '0' && input.LA(1) <= '3') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					if ( (input.LA(1) >= '0' && input.LA(1) <= '7') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					if ( (input.LA(1) >= '0' && input.LA(1) <= '7') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;
				case 2 :
					// druidG.g:742:9: '\\\\' ( '0' .. '7' ) ( '0' .. '7' )
					{
					match('\\'); 
					if ( (input.LA(1) >= '0' && input.LA(1) <= '7') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					if ( (input.LA(1) >= '0' && input.LA(1) <= '7') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;
				case 3 :
					// druidG.g:743:9: '\\\\' ( '0' .. '7' )
					{
					match('\\'); 
					if ( (input.LA(1) >= '0' && input.LA(1) <= '7') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;

			}
		}
		finally {
			// do for sure before leaving
		}
	}
987638
function readInt32W(buffer, offset, isBigEndian, noAssert) {
  var neg, val;

  if (!noAssert) {
    assert.ok(typeof (isBigEndian) === 'boolean',
        'missing or invalid endian');

    assert.ok(offset !== undefined && offset !== null,
        'missing offset');

    assert.ok(offset + 3 < buffer.length,
        'Trying to read beyond buffer length');
  }

  val = readUInt32W(buffer, offset, isBigEndian, noAssert);
  neg = val & 0x80000000;
  if (!neg) {
    return (val);
  }

  return (0xffffffff - val + 1) * -1;
}
277957
def endian(self):
        
        if self._endian is None:
            value = self._DEFAULT_ENDIAN[self.arch]
            if value is None:
                raise NotImplementedError('Could not determine the default byte order of %s architecture.' % self.arch)
            return value
        else:
            return self._endian
1310494
private function getCpuCount(): int
    {
        if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
            /*
            $str = trim((string) shell_exec('wmic cpu get NumberOfCores 2>&1'));
            if (!preg_match('/(\d+)/', $str, $matches)) {
                throw new \RuntimeException('wmic failed to get number of cpu cores on windows!');
            }
            return ((int) $matches [1]);
            */
            return 1;
        }

        if (!extension_loaded('pcntl')) {
            return 1;
        }

        $has_nproc = trim((string) @shell_exec('command -v nproc'));
        if ($has_nproc) {
            $ret = @shell_exec('nproc');
            if (is_string($ret)) {
                $ret = trim($ret);
                /** @var int|false */
                $tmp = filter_var($ret, FILTER_VALIDATE_INT);
                if (is_int($tmp)) {
                    return $tmp;
                }
            }
        }

        $ret = @shell_exec('sysctl -n hw.ncpu');
        if (is_string($ret)) {
            $ret = trim($ret);
            /** @var int|false */
            $tmp = filter_var($ret, FILTER_VALIDATE_INT);
            if (is_int($tmp)) {
                return $tmp;
            }
        }

        if (is_readable('/proc/cpuinfo')) {
            $cpuinfo = file_get_contents('/proc/cpuinfo');
            $count = substr_count($cpuinfo, 'processor');
            if ($count > 0) {
                return $count;
            }
        }

        throw new \LogicException('failed to detect number of CPUs!');
    }
429475
def _select_source_arch(self, source, source64):
        
        src = ""
        if self.meta.arch == "x86_64":
            if source64:
                src = source64
            else:
                src = source
            if self.meta.skip_unst in self.answer and source64 in self.unst:
                src = source
        else:
            if source:
                src = source
            if self.meta.skip_unst in self.answer and source in self.unst:
                src = source64
        return src
63424
def mach_o_change(path, what, value):
    

    def do_macho(file, bits, endian):
        # Read Mach-O header (the magic number is assumed read by the caller)
        cputype, cpusubtype, filetype, ncmds, sizeofcmds, flags = read_data(file, endian, 6)
        # 64-bits header has one more field.
        if bits == 64:
            read_data(file, endian)
        # The header is followed by ncmds commands
        for n in range(ncmds):
            where = file.tell()
            # Read command header
            cmd, cmdsize = read_data(file, endian, 2)
            if cmd == LC_LOAD_DYLIB:
                # The first data field in LC_LOAD_DYLIB commands is the
                # offset of the name, starting from the beginning of the
                # command.
                name_offset = read_data(file, endian)
                file.seek(where + name_offset, os.SEEK_SET)
                # Read the NUL terminated string
                load = file.read(cmdsize - name_offset).decode()
                load = load[:load.index('\0')]
                # If the string is what is being replaced, overwrite it.
                if load == what:
                    file.seek(where + name_offset, os.SEEK_SET)
                    file.write(value.encode() + '\0'.encode())
            # Seek to the next command
            file.seek(where + cmdsize, os.SEEK_SET)

    def do_file(file, offset=0, size=maxint):
        file = fileview(file, offset, size)
        # Read magic number
        magic = read_data(file, BIG_ENDIAN)
        if magic == FAT_MAGIC:
            # Fat binaries contain nfat_arch Mach-O binaries
            nfat_arch = read_data(file, BIG_ENDIAN)
            for n in range(nfat_arch):
                # Read arch header
                cputype, cpusubtype, offset, size, align = read_data(file, BIG_ENDIAN, 5)
                do_file(file, offset, size)
        elif magic == MH_MAGIC:
            do_macho(file, 32, BIG_ENDIAN)
        elif magic == MH_CIGAM:
            do_macho(file, 32, LITTLE_ENDIAN)
        elif magic == MH_MAGIC_64:
            do_macho(file, 64, BIG_ENDIAN)
        elif magic == MH_CIGAM_64:
            do_macho(file, 64, LITTLE_ENDIAN)

    assert(len(what) >= len(value))

    with open(path, 'r+b') as f:
        do_file(f)
869770
def _select_md5sum_arch(self, md5sum, md5sum64):
        
        if md5sum and md5sum64:
            if self.meta.arch == "x86_64":
                return md5sum64
            else:
                return md5sum
        if md5sum:
            return md5sum
        else:
            return md5sum64
234179
def _osx_memdata():
    '''
    
    '''
    grains = {'mem_total': 0, 'swap_total': 0}

    sysctl = salt.utils.path.which('sysctl')
    if sysctl:
        mem = __salt__['cmd.run']('{0} -n hw.memsize'.format(sysctl))
        swap_total = __salt__['cmd.run']('{0} -n vm.swapusage'.format(sysctl)).split()[2].replace(',', '.')
        if swap_total.endswith('K'):
            _power = 2**10
        elif swap_total.endswith('M'):
            _power = 2**20
        elif swap_total.endswith('G'):
            _power = 2**30
        swap_total = float(swap_total[:-1]) * _power

        grains['mem_total'] = int(mem) // 1024 // 1024
        grains['swap_total'] = int(swap_total) // 1024 // 1024
    return grains
1020133
def macshim():
    """"""
    import subprocess, sys
    subprocess.call([
        sys.argv[0] + '32'
    ]+sys.argv[1:], 
        env={"VERSIONER_PYTHON_PREFER_32_BIT":"yes"}
    )
577725
function getInstallDirWow64 (cb) {
    var key = new Registry({
      hive: Registry.HKLM,
      key: '\\Software\\Wow6432Node\\VideoLAN\\VLC'
    })
    key.get('InstallDir', cb)
  }