long build_context(long stack) {
  long *p = (long *)stack;
  --p;
  *(--p) = 0x13200;
  *(--p) = 0;
  *(--p) = 0;
  *(--p) = 0;
  *(--p) = 0;
  *(--p) = 0;
  *(--p) = 0;
  *(--p) = 0;
  p -= 27;
  __asm__("fnsave (%%eax)" ::"a"(p));
  return (long)p;
}


x86 assembly (clang, -O0):
<build_context>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x10(%rbp)
movq   $0x13200,-0x8(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x10(%rbp)
movq   $0x0,-0x8(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x10(%rbp)
movq   $0x0,-0x8(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x10(%rbp)
movq   $0x0,-0x8(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x10(%rbp)
movq   $0x0,-0x8(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x10(%rbp)
movq   $0x0,-0x8(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x10(%rbp)
movq   $0x0,-0x8(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffff8,%rcx
mov    %rcx,-0x10(%rbp)
movq   $0x0,-0x8(%rax)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffff28,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
fnsave (%eax)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_context>:
movq   $0x13200,-0x10(%rdi)
lea    -0x120(%rdi),%rax
xorps  %xmm0,%xmm0
movups %xmm0,-0x48(%rdi)
movups %xmm0,-0x38(%rdi)
movups %xmm0,-0x28(%rdi)
movq   $0x0,-0x18(%rdi)
fnsave (%eax)
ret

LLVM IR (-O0):
define i64 @build_context(i64 %0) {
%2 = alloca i64
%3 = alloca i64*
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = inttoptr i64 %4 to i64*
store i64* %5, i64** %3
%6 = load i64*, i64** %3
%7 = getelementptr inbounds i64, i64* %6, i32 -1
store i64* %7, i64** %3
%8 = load i64*, i64** %3
%9 = getelementptr inbounds i64, i64* %8, i32 -1
store i64* %9, i64** %3
store i64 78336, i64* %9
%10 = load i64*, i64** %3
%11 = getelementptr inbounds i64, i64* %10, i32 -1
store i64* %11, i64** %3
store i64 0, i64* %11
%12 = load i64*, i64** %3
%13 = getelementptr inbounds i64, i64* %12, i32 -1
store i64* %13, i64** %3
store i64 0, i64* %13
%14 = load i64*, i64** %3
%15 = getelementptr inbounds i64, i64* %14, i32 -1
store i64* %15, i64** %3
store i64 0, i64* %15
%16 = load i64*, i64** %3
%17 = getelementptr inbounds i64, i64* %16, i32 -1
store i64* %17, i64** %3
store i64 0, i64* %17
%18 = load i64*, i64** %3
%19 = getelementptr inbounds i64, i64* %18, i32 -1
store i64* %19, i64** %3
store i64 0, i64* %19
%20 = load i64*, i64** %3
%21 = getelementptr inbounds i64, i64* %20, i32 -1
store i64* %21, i64** %3
store i64 0, i64* %21
%22 = load i64*, i64** %3
%23 = getelementptr inbounds i64, i64* %22, i32 -1
store i64* %23, i64** %3
store i64 0, i64* %23
%24 = load i64*, i64** %3
%25 = getelementptr inbounds i64, i64* %24, i64 -27
store i64* %25, i64** %3
%26 = load i64*, i64** %3
%27 = load i64*, i64** %3
%28 = ptrtoint i64* %27 to i64
ret i64 %28
}

LLVM IR (-O2):
define i64 @build_context(i64 %0) {
%2 = inttoptr i64 %0 to i64*
%3 = getelementptr inbounds i64, i64* %2, i64 -2
store i64 78336, i64* %3
%4 = getelementptr inbounds i64, i64* %2, i64 -9
%5 = getelementptr inbounds i64, i64* %2, i64 -36
%6 = bitcast i64* %4 to i8*
tail call void asm sideeffect "fnsave (%eax)", "{ax},~{dirflag},~{fpsr},~{flags}"(i64* %5)
%7 = ptrtoint i64* %5 to i64
ret i64 %7
}