#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 */
typedef int fpu_control_t;

/* Variables and functions */
int _FPU_DOUBLE;
int _FPU_EXTENDED;
int /*<<< orphan*/ _FPU_GETCW(int);
int _FPU_RC_DOWN;
int _FPU_RC_UP;
int _FPU_RC_ZERO;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int main(int argc, char **argv) {
  fpu_control_t cw;
  _FPU_GETCW(cw);
  printf("cw register: 0x%08x\n", cw);
  printf("PC: Precision control: 0x%0x\n", (cw >> 8) & 0x3);
  if (cw & _FPU_EXTENDED)
    puts("  round to extended precision");
  else if (cw & _FPU_DOUBLE)
    puts("  round to double precision");
  else
    puts("  round to single precision");
  printf("RC: Rounding control: 0x%0x\n", (cw >> 10) & 0x3);
  if (cw & _FPU_RC_ZERO)
    puts("  rounding toward zero");
  else if (cw & _FPU_RC_DOWN)
    puts("  rounding down (toward -infinity)");
  else if (cw & _FPU_RC_UP)
    puts("  rounding up (toward +infinity)");
  else
    puts("  rounding to nearest");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <_FPU_GETCW@plt>
mov    -0x14(%rbp),%esi
lea    0xea8(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
sar    $0x8,%esi
and    $0x3,%esi
lea    0xea8(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
mov    0x2e4c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1198 <main+0x68>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
jmp    11cf <main+0x9f>
mov    -0x14(%rbp),%eax
mov    0x2e56(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11be <main+0x8e>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
jmp    11ca <main+0x9a>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
jmp    11cf <main+0x9f>
mov    -0x14(%rbp),%esi
sar    $0xa,%esi
and    $0x3,%esi
lea    0xeaa(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
mov    0x2dea(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     120a <main+0xda>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
jmp    126c <main+0x13c>
mov    -0x14(%rbp),%eax
mov    0x2dcc(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1230 <main+0x100>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
jmp    1267 <main+0x137>
mov    -0x14(%rbp),%eax
mov    0x2d86(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1256 <main+0x126>
lea    0xe94(%rip),%rdi
call   1030 <puts@plt>
jmp    1262 <main+0x132>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
jmp    1267 <main+0x137>
jmp    126c <main+0x13c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1040 <_FPU_GETCW@plt>
lea    0xec3(%rip),%rdi
call   1050 <printf@plt>
lea    0xecc(%rip),%rdi
xor    %esi,%esi
call   1050 <printf@plt>
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
lea    0xeec(%rip),%rdi
xor    %esi,%esi
call   1050 <printf@plt>
lea    0xefb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"cw register: 0x%08x\0A\00"
@.str.1 = [30 x i8] c"PC: Precision control: 0x%0x\0A\00"
@_FPU_EXTENDED = global i32 0
@.str.2 = [30 x i8] c" round to extended precision\00"
@_FPU_DOUBLE = global i32 0
@.str.3 = [28 x i8] c" round to double precision\00"
@.str.4 = [28 x i8] c" round to single precision\00"
@.str.5 = [29 x i8] c"RC: Rounding control: 0x%0x\0A\00"
@_FPU_RC_ZERO = global i32 0
@.str.6 = [23 x i8] c" rounding toward zero\00"
@_FPU_RC_DOWN = global i32 0
@.str.7 = [35 x i8] c" rounding down (toward -infinity)\00"
@_FPU_RC_UP = global i32 0
@.str.8 = [33 x i8] c" rounding up (toward +infinity)\00"
@.str.9 = [22 x i8] c" rounding to nearest\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %6
%8 = call i32 @_FPU_GETCW(i32 %7)
%9 = load i32, i32* %6
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %6
%12 = ashr i32 %11, 8
%13 = and i32 %12, 3
%14 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %6
%16 = load i32, i32* @_FPU_EXTENDED
%17 = and i32 %15, %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %31
21: ; preds = %2
%22 = load i32, i32* %6
%23 = load i32, i32* @_FPU_DOUBLE
%24 = and i32 %22, %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %30
28: ; preds = %21
%29 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %28, %26
br label %31
31: ; preds = %30, %19
%32 = load i32, i32* %6
%33 = ashr i32 %32, 10
%34 = and i32 %33, 3
%35 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %6
%37 = load i32, i32* @_FPU_RC_ZERO
%38 = and i32 %36, %37
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %31
%41 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %60
42: ; preds = %31
%43 = load i32, i32* %6
%44 = load i32, i32* @_FPU_RC_DOWN
%45 = and i32 %43, %44
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 @puts(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
br label %59
49: ; preds = %42
%50 = load i32, i32* %6
%51 = load i32, i32* @_FPU_RC_UP
%52 = and i32 %50, %51
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
br label %58
56: ; preds = %49
%57 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
br label %58
58: ; preds = %56, %54
br label %59
59: ; preds = %58, %47
br label %60
60: ; preds = %59, %40
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"cw register: 0x%08x\0A\00"
@.str.1 = [30 x i8] c"PC: Precision control: 0x%0x\0A\00"
@_FPU_EXTENDED = global i32 0
@_FPU_DOUBLE = global i32 0
@.str.4 = [28 x i8] c" round to single precision\00"
@.str.5 = [29 x i8] c"RC: Rounding control: 0x%0x\0A\00"
@_FPU_RC_ZERO = global i32 0
@_FPU_RC_DOWN = global i32 0
@_FPU_RC_UP = global i32 0
@.str.9 = [22 x i8] c" rounding to nearest\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @_FPU_GETCW(i32 undef)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 undef)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 0)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
ret i32 0
}