| 1 | #include <stdint.h> |
|---|---|
| 2 | #include <stdio.h> |
| 3 | #include <stdlib.h> |
| 4 | |
| 5 | int __llvm_profile_runtime = 0; |
| 6 | uint64_t __llvm_profile_get_size_for_buffer(void); |
| 7 | int __llvm_profile_write_buffer(char *); |
| 8 | void __llvm_profile_reset_counters(void); |
| 9 | int __llvm_profile_check_compatibility(const char *, uint64_t); |
| 10 | |
| 11 | int gg = 0; |
| 12 | void bar(char c) { |
| 13 | if (c == '1') |
| 14 | gg++; |
| 15 | else |
| 16 | gg--; |
| 17 | } |
| 18 | |
| 19 | /* Returns 0 (size) when an error occurs. */ |
| 20 | uint64_t libEntry(char *Buffer, uint64_t MaxSize) { |
| 21 | |
| 22 | uint64_t Size = __llvm_profile_get_size_for_buffer(); |
| 23 | if (Size > MaxSize) |
| 24 | return 0; |
| 25 | |
| 26 | __llvm_profile_reset_counters(); |
| 27 | |
| 28 | bar(c: '1'); |
| 29 | |
| 30 | if (__llvm_profile_write_buffer(Buffer)) |
| 31 | return 0; |
| 32 | |
| 33 | /* Now check compatibility. Should return 0. */ |
| 34 | if (__llvm_profile_check_compatibility(Buffer, Size)) |
| 35 | return 0; |
| 36 | |
| 37 | return Size; |
| 38 | } |
| 39 | |
| 40 |
