#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;
int /*<<< orphan*/ asprintf(char **, char *, ...);
int fetestexcept(int /*<<< orphan*/);
char *fmt_flags(void) {
  int flags = fetestexcept(FE_ALL_EXCEPT);
  char *fmt;
  if (flags) {
    asprintf(&fmt, "%s%s%s%s%s", flags & 0 ? "OVERFLOW " : "",
             flags & 0 ? "UNDERFLOW " : "", flags & 0 ? "DIV0 " : "",
             flags & 0 ? "INEXACT " : "", flags & 0 ? "INVALID" : "");
  } else {
    asprintf(&fmt, "OK");
  }
  return fmt;
}


x86 assembly (clang, -O0):
<fmt_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
call   1030 <fetestexcept@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11e5 <fmt_flags+0xc5>
mov    -0x4(%rbp),%ecx
and    $0x0,%ecx
lea    0xed5(%rip),%rdx
lea    0xeb4(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x4(%rbp),%esi
and    $0x0,%esi
lea    0xeba(%rip),%rcx
lea    0xea3(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
mov    -0x4(%rbp),%esi
and    $0x0,%esi
lea    0xe9f(%rip),%r8
lea    0xe93(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r8
mov    -0x4(%rbp),%esi
and    $0x0,%esi
lea    0xe84(%rip),%r9
lea    0xe7e(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r9
mov    -0x4(%rbp),%edi
and    $0x0,%edi
lea    0xe69(%rip),%rax
lea    0xe6c(%rip),%rsi
cmp    $0x0,%edi
cmovne %rsi,%rax
lea    -0x10(%rbp),%rdi
lea    0xe2b(%rip),%rsi
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <asprintf@plt>
jmp    11f7 <fmt_flags+0xd7>
lea    -0x10(%rbp),%rdi
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1040 <asprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmt_flags>:
sub    $0x18,%rsp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
call   1030 <fetestexcept@plt>
test   %eax,%eax
je     115f <fmt_flags+0x3f>
lea    0xed0(%rip),%rcx
mov    %rcx,(%rsp)
lea    0xeb8(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %rcx,%rdx
mov    %rcx,%r8
mov    %rcx,%r9
xor    %eax,%eax
call   1040 <asprintf@plt>
jmp    1172 <fmt_flags+0x52>
lea    0xea5(%rip),%rsi
lea    0x10(%rsp),%rdi
xor    %eax,%eax
call   1040 <asprintf@plt>
mov    0x10(%rsp),%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@FE_ALL_EXCEPT = global i32 0
@.str = [11 x i8] c"%s%s%s%s%s\00"
@.str.1 = [10 x i8] c"OVERFLOW \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [11 x i8] c"UNDERFLOW \00"
@.str.4 = [6 x i8] c"DIV0 \00"
@.str.5 = [9 x i8] c"INEXACT \00"
@.str.6 = [8 x i8] c"INVALID\00"
@.str.7 = [3 x i8] c"OK\00"
define i8* @fmt_flags() {
%1 = alloca i32
%2 = alloca i8*
%3 = load i32, i32* @FE_ALL_EXCEPT
%4 = call i32 @fetestexcept(i32 %3)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %34
7: ; preds = %0
%8 = load i32, i32* %1
%9 = and i32 %8, 0
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i64
%12 = select i1 %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%13 = load i32, i32* %1
%14 = and i32 %13, 0
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%18 = load i32, i32* %1
%19 = and i32 %18, 0
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%23 = load i32, i32* %1
%24 = and i32 %23, 0
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%28 = load i32, i32* %1
%29 = and i32 %28, 0
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0)
%33 = call i32 (i8**, i8*, ...) @asprintf(i8** %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %17, i8* %22, i8* %27, i8* %32)
br label %36
34: ; preds = %0
%35 = call i32 (i8**, i8*, ...) @asprintf(i8** %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %36
36: ; preds = %34, %7
%37 = load i8*, i8** %2
ret i8* %37
}

LLVM IR (-O2):
@FE_ALL_EXCEPT = global i32 0
@.str = [11 x i8] c"%s%s%s%s%s\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.7 = [3 x i8] c"OK\00"
define i8* @fmt_flags() {
%1 = alloca i8*
%2 = load i32, i32* @FE_ALL_EXCEPT
%3 = tail call i32 @fetestexcept(i32 %2)
%4 = bitcast i8** %1 to i8*
%5 = icmp eq i32 %3, 0
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 (i8**, i8*, ...) @asprintf(i8** %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %10
8: ; preds = %0
%9 = call i32 (i8**, i8*, ...) @asprintf(i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = load i8*, i8** %1
ret i8* %11
}