#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_fldenv(unsigned short *);
int /*<<< orphan*/ do_fstenv(unsigned short *);
unsigned short *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int i;
  unsigned short *buf = malloc(14 * sizeof(short));
  for (i = 0; i < 14; i++)
    buf[i] = i;
  buf[0] = 0x037f;
  do_fldenv(buf);
  do_fstenv(buf);
  for (i = 0; i < 14; i++) {
    printf("%04x ", buf[i]);
    if (i > 0 && ((i % 12) == 11))
      printf("\n");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1c,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xe,-0x8(%rbp)
jge    118e <main+0x4e>
mov    -0x8(%rbp),%eax
mov    %ax,%dx
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1164 <main+0x24>
mov    -0x10(%rbp),%rax
movw   $0x37f,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <do_fldenv@plt>
mov    -0x10(%rbp),%rdi
call   1050 <do_fstenv@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xe,-0x8(%rbp)
jge    1213 <main+0xd3>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movzwl (%rax,%rcx,2),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1200 <main+0xc0>
mov    -0x8(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
cmp    $0xb,%edx
jne    1200 <main+0xc0>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1205 <main+0xc5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b0 <main+0x70>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1c,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
movabs $0xb000a00090008,%rax
mov    %rax,0x10(%r15)
movl   $0xd000c,0x18(%r15)
movaps 0xe7f(%rip),%xmm0
movups %xmm0,(%r15)
mov    %r15,%rdi
call   1030 <do_fldenv@plt>
mov    %r15,%rdi
call   1060 <do_fstenv@plt>
mov    $0xb,%bpl
lea    0xe71(%rip),%r14
xor    %ebx,%ebx
jmp    11be <main+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
add    $0xff,%bpl
cmp    $0xe,%rbx
je     11f5 <main+0xa5>
movzwl (%r15,%rbx,2),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbx,%rbx
je     11b0 <main+0x60>
movzbl %bl,%eax
imul   $0xab,%eax,%eax
shr    $0x9,%eax
and    $0xfffffffc,%eax
lea    (%rax,%rax,2),%eax
add    %bpl,%al
jne    11b0 <main+0x60>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    11b0 <main+0x60>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%04x \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i16*
store i32 0, i32* %1
%4 = call i16* @malloc(i32 28)
store i16* %4, i16** %3
store i32 0, i32* %2
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 14
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %2
%10 = trunc i32 %9 to i16
%11 = load i16*, i16** %3
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i16, i16* %11, i64 %13
store i16 %10, i16* %14
br label %15
15: ; preds = %8
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %5
18: ; preds = %5
%19 = load i16*, i16** %3
%20 = getelementptr inbounds i16, i16* %19, i64 0
store i16 895, i16* %20
%21 = load i16*, i16** %3
%22 = call i32 @do_fldenv(i16* %21)
%23 = load i16*, i16** %3
%24 = call i32 @do_fstenv(i16* %23)
store i32 0, i32* %2
br label %25
25: ; preds = %45, %18
%26 = load i32, i32* %2
%27 = icmp slt i32 %26, 14
br i1 %27, label %28, label %48
28: ; preds = %25
%29 = load i16*, i16** %3
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i16, i16* %29, i64 %31
%33 = load i16, i16* %32
%34 = zext i16 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %2
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %28
%39 = load i32, i32* %2
%40 = srem i32 %39, 12
%41 = icmp eq i32 %40, 11
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %44
44: ; preds = %42, %38, %28
br label %45
45: ; preds = %44
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 1
store i32 %47, i32* %2
br label %25
48: ; preds = %25
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%04x \00"
define i32 @main() {
%1 = tail call i16* @malloc(i32 28)
%2 = getelementptr inbounds i16, i16* %1, i64 8
store i16 8, i16* %2
%3 = getelementptr inbounds i16, i16* %1, i64 9
store i16 9, i16* %3
%4 = getelementptr inbounds i16, i16* %1, i64 10
store i16 10, i16* %4
%5 = getelementptr inbounds i16, i16* %1, i64 11
store i16 11, i16* %5
%6 = getelementptr inbounds i16, i16* %1, i64 12
store i16 12, i16* %6
%7 = getelementptr inbounds i16, i16* %1, i64 13
store i16 13, i16* %7
%8 = bitcast i16* %1 to <8 x i16>*
store <8 x i16> <i16 895, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7>, <8 x i16>* %8
%9 = tail call i32 @do_fldenv(i16* %1)
%10 = tail call i32 @do_fstenv(i16* %1)
br label %11
11: ; preds = %0, %24
%12 = phi i64 [ 0, %0 ], [ %25, %24 ]
%13 = getelementptr inbounds i16, i16* %1, i64 %12
%14 = load i16, i16* %13
%15 = zext i16 %14 to i32
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = icmp ne i64 %12, 0
%18 = trunc i64 %12 to i8
%19 = urem i8 %18, 12
%20 = icmp eq i8 %19, 11
%21 = and i1 %17, %20
br i1 %21, label %22, label %24
22: ; preds = %11
%23 = tail call i32 @putchar(i32 10)
br label %24
24: ; preds = %11, %22
%25 = add nuw nsw i64 %12, 1
%26 = icmp eq i64 %25, 14
br i1 %26, label %27, label %11
27: ; preds = %24
%28 = tail call i32 @putchar(i32 10)
ret i32 0
}