about summary refs log tree commit diff stats
path: root/reproducers/issue-508.c
blob: c8fd25199f69243b9547fdd5ccd5bc3af8f6cfef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <stdlib.h>
#include <sys/random.h>

int main() {
  int mem = 0x12345678;
  int buf = 0;
  getrandom(&buf, sizeof(buf), 0);
  register long rax asm("rax") = 0x1234567812345678;
  register int edi asm("edi") = buf;
  asm("cmpxchg %[edi],%[mem]"
      : [ mem ] "+m"(mem), [ rax ] "+r"(rax)
      : [ edi ] "r"(edi));
  long rax2 = rax;
  printf("rax2 = %lx\n", rax2);
  printf("rand= %d\n", buf);
}