#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ do_frstor(unsigned short *);
int /*<<< orphan*/ do_fsave(unsigned short *);
int /*<<< orphan*/ do_fsave_interesting_stuff(unsigned short *);
unsigned short *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ show_fpustate(unsigned char *, int);
int main(int argc, char **argv) {
  unsigned short *buf1 = malloc(54 * sizeof(short));
  unsigned short *buf2 = malloc(54 * sizeof(short));
  int xx = argc > 1;
  printf("Re-run with any arg to suppress least-significant\n"
         "   16 bits of FP numbers\n");
  do_fsave_interesting_stuff(buf1);
  show_fpustate((unsigned char *)buf1, xx);
  do_frstor(buf1);
  do_fsave(buf2);
  show_fpustate((unsigned char *)buf2, xx);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x6c,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x6c,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <do_fsave_interesting_stuff@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1060 <show_fpustate@plt>
mov    -0x18(%rbp),%rdi
call   1080 <do_frstor@plt>
mov    -0x20(%rbp),%rdi
call   1030 <do_fsave@plt>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1060 <show_fpustate@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
mov    $0x6c,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    $0x6c,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
xor    %ebp,%ebp
cmp    $0x2,%r14d
setge  %bpl
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <do_fsave_interesting_stuff@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <show_fpustate@plt>
mov    %rbx,%rdi
call   1080 <do_frstor@plt>
mov    %r15,%rdi
call   1040 <do_fsave@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1060 <show_fpustate@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [76 x i8] c"Re-run with any arg to suppress least-significant\0A 16 bits of FP numbers\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i16*
%7 = alloca i16*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i16* @malloc(i32 108)
store i16* %9, i16** %6
%10 = call i16* @malloc(i32 108)
store i16* %10, i16** %7
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
%13 = zext i1 %12 to i32
store i32 %13, i32* %8
%14 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str, i64 0, i64 0))
%15 = load i16*, i16** %6
%16 = call i32 @do_fsave_interesting_stuff(i16* %15)
%17 = load i16*, i16** %6
%18 = bitcast i16* %17 to i8*
%19 = load i32, i32* %8
%20 = call i32 @show_fpustate(i8* %18, i32 %19)
%21 = load i16*, i16** %6
%22 = call i32 @do_frstor(i16* %21)
%23 = load i16*, i16** %7
%24 = call i32 @do_fsave(i16* %23)
%25 = load i16*, i16** %7
%26 = bitcast i16* %25 to i8*
%27 = load i32, i32* %8
%28 = call i32 @show_fpustate(i8* %26, i32 %27)
ret i32 0
}

LLVM IR (-O2):
@str = [75 x i8] c"Re-run with any arg to suppress least-significant\0A 16 bits of FP numbers\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i16* @malloc(i32 108)
%4 = tail call i16* @malloc(i32 108)
%5 = icmp sgt i32 %0, 1
%6 = zext i1 %5 to i32
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @do_fsave_interesting_stuff(i16* %3)
%9 = bitcast i16* %3 to i8*
%10 = tail call i32 @show_fpustate(i8* %9, i32 %6)
%11 = tail call i32 @do_frstor(i16* %3)
%12 = tail call i32 @do_fsave(i16* %4)
%13 = bitcast i16* %4 to i8*
%14 = tail call i32 @show_fpustate(i8* %13, i32 %6)
ret i32 0
}