#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*/ FE_ALL_EXCEPT;
scalar_t__ FE_DOWNWARD;
scalar_t__ FE_TONEAREST;
scalar_t__ FE_TOWARDZERO;
scalar_t__ FE_UPWARD;
int FLT_ROUNDS;
int /*<<< orphan*/ assert(int);
scalar_t__ feclearexcept(int /*<<< orphan*/);
scalar_t__ fegetround();
scalar_t__ fesetround(scalar_t__);
scalar_t__ getround();
void test_fegsetround(void) {
  assert(fegetround() == FE_TONEAREST);
  assert(getround() == FE_TONEAREST);
  assert(FLT_ROUNDS == 1);
  assert(fesetround(FE_DOWNWARD) == 0);
  assert(fegetround() == FE_DOWNWARD);
  assert(getround() == FE_DOWNWARD);
  assert(FLT_ROUNDS == 3);
  assert(fesetround(FE_UPWARD) == 0);
  assert(getround() == FE_UPWARD);
  assert(fegetround() == FE_UPWARD);
  assert(FLT_ROUNDS == 2);
  assert(fesetround(FE_TOWARDZERO) == 0);
  assert(getround() == FE_TOWARDZERO);
  assert(fegetround() == FE_TOWARDZERO);
  assert(FLT_ROUNDS == 0);
  assert(fesetround(FE_TONEAREST) == 0);
  assert(getround() == FE_TONEAREST);
  assert(FLT_ROUNDS == 1);
  assert(feclearexcept(FE_ALL_EXCEPT) == 0);
}


x86 assembly (clang, -O0):
<test_fegsetround>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1040 <fegetround@plt>
mov    0x2e76(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x0,%al
call   1060 <getround@plt>
mov    0x2e58(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2e51(%rip),%rax
cmpl   $0x1,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%rdi
call   1030 <fesetround@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x0,%al
call   1040 <fegetround@plt>
mov    0x2dfb(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x0,%al
call   1060 <getround@plt>
mov    0x2ddd(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2dde(%rip),%rax
cmpl   $0x3,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%rdi
call   1030 <fesetround@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x0,%al
call   1060 <getround@plt>
mov    0x2d78(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x0,%al
call   1040 <fegetround@plt>
mov    0x2d5a(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2d6b(%rip),%rax
cmpl   $0x2,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%rdi
call   1030 <fesetround@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x0,%al
call   1060 <getround@plt>
mov    0x2d25(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x0,%al
call   1040 <fegetround@plt>
mov    0x2d07(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2cf8(%rip),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2cd1(%rip),%rax
mov    (%rax),%rdi
call   1030 <fesetround@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x0,%al
call   1060 <getround@plt>
mov    0x2caa(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2ca3(%rip),%rax
cmpl   $0x1,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    0x2c5c(%rip),%rax
mov    (%rax),%edi
call   1070 <feclearexcept@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_fegsetround>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <fegetround@plt>
mov    0x2e75(%rip),%r14
xor    %edi,%edi
cmp    (%r14),%rax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
call   1060 <getround@plt>
xor    %edi,%edi
cmp    (%r14),%rax
sete   %dil
call   1050 <assert@plt>
mov    0x2e5b(%rip),%r15
xor    %edi,%edi
cmpl   $0x1,(%r15)
sete   %dil
call   1050 <assert@plt>
mov    0x2e2d(%rip),%rbx
mov    (%rbx),%rdi
call   1030 <fesetround@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
call   1040 <fegetround@plt>
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
call   1060 <getround@plt>
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x3,(%r15)
sete   %dil
call   1050 <assert@plt>
mov    0x2dc7(%rip),%rbx
mov    (%rbx),%rdi
call   1030 <fesetround@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
call   1060 <getround@plt>
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
call   1040 <fegetround@plt>
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x2,(%r15)
sete   %dil
call   1050 <assert@plt>
mov    0x2d91(%rip),%rbx
mov    (%rbx),%rdi
call   1030 <fesetround@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
call   1060 <getround@plt>
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
call   1040 <fegetround@plt>
xor    %edi,%edi
cmp    (%rbx),%rax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,(%r15)
sete   %dil
call   1050 <assert@plt>
mov    (%r14),%rdi
call   1030 <fesetround@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
xor    %eax,%eax
call   1060 <getround@plt>
xor    %edi,%edi
cmp    (%r14),%rax
sete   %dil
call   1050 <assert@plt>
xor    %edi,%edi
cmpl   $0x1,(%r15)
sete   %dil
call   1050 <assert@plt>
mov    0x2cd9(%rip),%rax
mov    (%rax),%edi
call   1070 <feclearexcept@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <assert@plt>

LLVM IR (-O0):
@FE_TONEAREST = global i64 0
@FLT_ROUNDS = global i32 0
@FE_DOWNWARD = global i64 0
@FE_UPWARD = global i64 0
@FE_TOWARDZERO = global i64 0
@FE_ALL_EXCEPT = global i32 0
define void @test_fegsetround() {
%1 = call i64 (...) @fegetround()
%2 = load i64, i64* @FE_TONEAREST
%3 = icmp eq i64 %1, %2
%4 = zext i1 %3 to i32
%5 = call i32 @assert(i32 %4)
%6 = call i64 (...) @getround()
%7 = load i64, i64* @FE_TONEAREST
%8 = icmp eq i64 %6, %7
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i32, i32* @FLT_ROUNDS
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i64, i64* @FE_DOWNWARD
%16 = call i64 @fesetround(i64 %15)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i64 (...) @fegetround()
%21 = load i64, i64* @FE_DOWNWARD
%22 = icmp eq i64 %20, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = call i64 (...) @getround()
%26 = load i64, i64* @FE_DOWNWARD
%27 = icmp eq i64 %25, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i32, i32* @FLT_ROUNDS
%31 = icmp eq i32 %30, 3
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i64, i64* @FE_UPWARD
%35 = call i64 @fesetround(i64 %34)
%36 = icmp eq i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = call i64 (...) @getround()
%40 = load i64, i64* @FE_UPWARD
%41 = icmp eq i64 %39, %40
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = call i64 (...) @fegetround()
%45 = load i64, i64* @FE_UPWARD
%46 = icmp eq i64 %44, %45
%47 = zext i1 %46 to i32
%48 = call i32 @assert(i32 %47)
%49 = load i32, i32* @FLT_ROUNDS
%50 = icmp eq i32 %49, 2
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = load i64, i64* @FE_TOWARDZERO
%54 = call i64 @fesetround(i64 %53)
%55 = icmp eq i64 %54, 0
%56 = zext i1 %55 to i32
%57 = call i32 @assert(i32 %56)
%58 = call i64 (...) @getround()
%59 = load i64, i64* @FE_TOWARDZERO
%60 = icmp eq i64 %58, %59
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = call i64 (...) @fegetround()
%64 = load i64, i64* @FE_TOWARDZERO
%65 = icmp eq i64 %63, %64
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
%68 = load i32, i32* @FLT_ROUNDS
%69 = icmp eq i32 %68, 0
%70 = zext i1 %69 to i32
%71 = call i32 @assert(i32 %70)
%72 = load i64, i64* @FE_TONEAREST
%73 = call i64 @fesetround(i64 %72)
%74 = icmp eq i64 %73, 0
%75 = zext i1 %74 to i32
%76 = call i32 @assert(i32 %75)
%77 = call i64 (...) @getround()
%78 = load i64, i64* @FE_TONEAREST
%79 = icmp eq i64 %77, %78
%80 = zext i1 %79 to i32
%81 = call i32 @assert(i32 %80)
%82 = load i32, i32* @FLT_ROUNDS
%83 = icmp eq i32 %82, 1
%84 = zext i1 %83 to i32
%85 = call i32 @assert(i32 %84)
%86 = load i32, i32* @FE_ALL_EXCEPT
%87 = call i64 @feclearexcept(i32 %86)
%88 = icmp eq i64 %87, 0
%89 = zext i1 %88 to i32
%90 = call i32 @assert(i32 %89)
ret void
}

LLVM IR (-O2):
@FE_TONEAREST = global i64 0
@FLT_ROUNDS = global i32 0
@FE_DOWNWARD = global i64 0
@FE_UPWARD = global i64 0
@FE_TOWARDZERO = global i64 0
@FE_ALL_EXCEPT = global i32 0
define void @test_fegsetround() {
%1 = tail call i64 (...) @fegetround()
%2 = load i64, i64* @FE_TONEAREST
%3 = icmp eq i64 %1, %2
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i64 (...) @getround()
%7 = load i64, i64* @FE_TONEAREST
%8 = icmp eq i64 %6, %7
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = load i32, i32* @FLT_ROUNDS
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = load i64, i64* @FE_DOWNWARD
%16 = tail call i64 @fesetround(i64 %15)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
%20 = tail call i64 (...) @fegetround()
%21 = load i64, i64* @FE_DOWNWARD
%22 = icmp eq i64 %20, %21
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = tail call i64 (...) @getround()
%26 = load i64, i64* @FE_DOWNWARD
%27 = icmp eq i64 %25, %26
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
%30 = load i32, i32* @FLT_ROUNDS
%31 = icmp eq i32 %30, 3
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = load i64, i64* @FE_UPWARD
%35 = tail call i64 @fesetround(i64 %34)
%36 = icmp eq i64 %35, 0
%37 = zext i1 %36 to i32
%38 = tail call i32 @assert(i32 %37)
%39 = tail call i64 (...) @getround()
%40 = load i64, i64* @FE_UPWARD
%41 = icmp eq i64 %39, %40
%42 = zext i1 %41 to i32
%43 = tail call i32 @assert(i32 %42)
%44 = tail call i64 (...) @fegetround()
%45 = load i64, i64* @FE_UPWARD
%46 = icmp eq i64 %44, %45
%47 = zext i1 %46 to i32
%48 = tail call i32 @assert(i32 %47)
%49 = load i32, i32* @FLT_ROUNDS
%50 = icmp eq i32 %49, 2
%51 = zext i1 %50 to i32
%52 = tail call i32 @assert(i32 %51)
%53 = load i64, i64* @FE_TOWARDZERO
%54 = tail call i64 @fesetround(i64 %53)
%55 = icmp eq i64 %54, 0
%56 = zext i1 %55 to i32
%57 = tail call i32 @assert(i32 %56)
%58 = tail call i64 (...) @getround()
%59 = load i64, i64* @FE_TOWARDZERO
%60 = icmp eq i64 %58, %59
%61 = zext i1 %60 to i32
%62 = tail call i32 @assert(i32 %61)
%63 = tail call i64 (...) @fegetround()
%64 = load i64, i64* @FE_TOWARDZERO
%65 = icmp eq i64 %63, %64
%66 = zext i1 %65 to i32
%67 = tail call i32 @assert(i32 %66)
%68 = load i32, i32* @FLT_ROUNDS
%69 = icmp eq i32 %68, 0
%70 = zext i1 %69 to i32
%71 = tail call i32 @assert(i32 %70)
%72 = load i64, i64* @FE_TONEAREST
%73 = tail call i64 @fesetround(i64 %72)
%74 = icmp eq i64 %73, 0
%75 = zext i1 %74 to i32
%76 = tail call i32 @assert(i32 %75)
%77 = tail call i64 (...) @getround()
%78 = load i64, i64* @FE_TONEAREST
%79 = icmp eq i64 %77, %78
%80 = zext i1 %79 to i32
%81 = tail call i32 @assert(i32 %80)
%82 = load i32, i32* @FLT_ROUNDS
%83 = icmp eq i32 %82, 1
%84 = zext i1 %83 to i32
%85 = tail call i32 @assert(i32 %84)
%86 = load i32, i32* @FE_ALL_EXCEPT
%87 = tail call i64 @feclearexcept(i32 %86)
%88 = icmp eq i64 %87, 0
%89 = zext i1 %88 to i32
%90 = tail call i32 @assert(i32 %89)
ret void
}