#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*/ SIGFPE;
int flt_difference(unsigned int *, unsigned int, unsigned int, unsigned int,
                   unsigned int);
int flt_sum(unsigned int *, unsigned int, unsigned int, unsigned int,
            unsigned int);
int /*<<< orphan*/ raise(int /*<<< orphan*/);
double _dadd(unsigned int bh, unsigned int bl, unsigned int ch,
             unsigned int cl) {
  int ok;
  double a[1];
  if (bh & 0x80000000) {
    if (ch & 0x80000000) {
      ok = flt_sum((unsigned int *)a, bh & 0x7fffffff, bl, ch & 0x7fffffff, cl);
      ((int *)a)[0] ^= 0x80000000;
    } else
      ok = flt_difference((unsigned int *)a, ch, cl, bh & 0x7fffffff, bl);
  } else if (ch & 0x80000000)
    ok = flt_difference((unsigned int *)a, bh, bl, ch & 0x7fffffff, cl);
  else
    ok = flt_sum((unsigned int *)a, bh, bl, ch, cl);
  if (!ok)
    raise(SIGFPE);
  return a[0];
}


x86 assembly (clang, -O0):
<_dadd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     11bf <_dadd+0x8f>
mov    -0xc(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     119b <_dadd+0x6b>
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
and    $0x7fffffff,%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
and    $0x7fffffff,%ecx
mov    -0x10(%rbp),%r8d
call   1050 <flt_sum@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%eax
xor    $0x80000000,%eax
mov    %eax,-0x20(%rbp)
jmp    11ba <_dadd+0x8a>
lea    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x4(%rbp),%ecx
and    $0x7fffffff,%ecx
mov    -0x8(%rbp),%r8d
call   1040 <flt_difference@plt>
mov    %eax,-0x14(%rbp)
jmp    1212 <_dadd+0xe2>
mov    -0xc(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     11f4 <_dadd+0xc4>
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
and    $0x7fffffff,%ecx
mov    -0x10(%rbp),%r8d
call   1040 <flt_difference@plt>
mov    %eax,-0x14(%rbp)
jmp    120d <_dadd+0xdd>
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
call   1050 <flt_sum@plt>
mov    %eax,-0x14(%rbp)
jmp    1212 <_dadd+0xe2>
cmpl   $0x0,-0x14(%rbp)
jne    122a <_dadd+0xfa>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dadd>:
push   %rax
mov    %ecx,%r8d
mov    %edx,%eax
mov    %esi,%r9d
mov    %edi,%ecx
test   %edi,%edi
js     116b <_dadd+0x3b>
test   %eax,%eax
js     1182 <_dadd+0x52>
mov    %rsp,%rdi
mov    %ecx,%esi
mov    %r9d,%edx
mov    %eax,%ecx
call   1050 <flt_sum@plt>
test   %eax,%eax
jne    1164 <_dadd+0x34>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1030 <raise@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret
and    $0x7fffffff,%ecx
test   %eax,%eax
js     119c <_dadd+0x6c>
mov    %rsp,%rdi
mov    %eax,%esi
mov    %r8d,%edx
mov    %r9d,%r8d
jmp    1191 <_dadd+0x61>
and    $0x7fffffff,%eax
mov    %rsp,%rdi
mov    %ecx,%esi
mov    %r9d,%edx
mov    %eax,%ecx
call   1040 <flt_difference@plt>
test   %eax,%eax
jne    1164 <_dadd+0x34>
jmp    1156 <_dadd+0x26>
and    $0x7fffffff,%eax
mov    %rsp,%rdi
mov    %ecx,%esi
mov    %r9d,%edx
mov    %eax,%ecx
call   1050 <flt_sum@plt>
xorb   $0x80,0x3(%rsp)
test   %eax,%eax
jne    1164 <_dadd+0x34>
jmp    1156 <_dadd+0x26>

LLVM IR (-O0):
@SIGFPE = global i32 0
define double @_dadd(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1 x double]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %5
%12 = and i32 %11, -2147483648
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %43
14: ; preds = %4
%15 = load i32, i32* %7
%16 = and i32 %15, -2147483648
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %33
18: ; preds = %14
%19 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 0
%20 = bitcast double* %19 to i32*
%21 = load i32, i32* %5
%22 = and i32 %21, 2147483647
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = and i32 %24, 2147483647
%26 = load i32, i32* %8
%27 = call i32 @flt_sum(i32* %20, i32 %22, i32 %23, i32 %25, i32 %26)
store i32 %27, i32* %9
%28 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 0
%29 = bitcast double* %28 to i32*
%30 = getelementptr inbounds i32, i32* %29, i64 0
%31 = load i32, i32* %30
%32 = xor i32 %31, -2147483648
store i32 %32, i32* %30
br label %42
33: ; preds = %14
%34 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 0
%35 = bitcast double* %34 to i32*
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = load i32, i32* %5
%39 = and i32 %38, 2147483647
%40 = load i32, i32* %6
%41 = call i32 @flt_difference(i32* %35, i32 %36, i32 %37, i32 %39, i32 %40)
store i32 %41, i32* %9
br label %42
42: ; preds = %33, %18
br label %65
43: ; preds = %4
%44 = load i32, i32* %7
%45 = and i32 %44, -2147483648
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %56
47: ; preds = %43
%48 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 0
%49 = bitcast double* %48 to i32*
%50 = load i32, i32* %5
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = and i32 %52, 2147483647
%54 = load i32, i32* %8
%55 = call i32 @flt_difference(i32* %49, i32 %50, i32 %51, i32 %53, i32 %54)
store i32 %55, i32* %9
br label %64
56: ; preds = %43
%57 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 0
%58 = bitcast double* %57 to i32*
%59 = load i32, i32* %5
%60 = load i32, i32* %6
%61 = load i32, i32* %7
%62 = load i32, i32* %8
%63 = call i32 @flt_sum(i32* %58, i32 %59, i32 %60, i32 %61, i32 %62)
store i32 %63, i32* %9
br label %64
64: ; preds = %56, %47
br label %65
65: ; preds = %64, %42
%66 = load i32, i32* %9
%67 = icmp ne i32 %66, 0
br i1 %67, label %71, label %68
68: ; preds = %65
%69 = load i32, i32* @SIGFPE
%70 = call i32 @raise(i32 %69)
br label %71
71: ; preds = %68, %65
%72 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 0
%73 = load double, double* %72
ret double %73
}

LLVM IR (-O2):
@SIGFPE = global i32 0
define double @_dadd(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [1 x double]
%6 = bitcast [1 x double]* %5 to i8*
%7 = icmp sgt i32 %0, -1
%8 = icmp sgt i32 %2, -1
%9 = bitcast [1 x double]* %5 to i32*
br i1 %7, label %19, label %10
10: ; preds = %4
%11 = and i32 %0, 2147483647
br i1 %8, label %17, label %12
12: ; preds = %10
%13 = and i32 %2, 2147483647
%14 = call i32 @flt_sum(i32* %9, i32 %11, i32 %1, i32 %13, i32 %3)
%15 = load i32, i32* %9
%16 = xor i32 %15, -2147483648
store i32 %16, i32* %9
br label %25
17: ; preds = %10
%18 = call i32 @flt_difference(i32* %9, i32 %2, i32 %3, i32 %11, i32 %1)
br label %25
19: ; preds = %4
br i1 %8, label %23, label %20
20: ; preds = %19
%21 = and i32 %2, 2147483647
%22 = call i32 @flt_difference(i32* %9, i32 %0, i32 %1, i32 %21, i32 %3)
br label %25
23: ; preds = %19
%24 = call i32 @flt_sum(i32* %9, i32 %0, i32 %1, i32 %2, i32 %3)
br label %25
25: ; preds = %20, %23, %12, %17
%26 = phi i32 [ %14, %12 ], [ %18, %17 ], [ %22, %20 ], [ %24, %23 ]
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* @SIGFPE
%30 = call i32 @raise(i32 %29)
br label %31
31: ; preds = %28, %25
%32 = getelementptr inbounds [1 x double], [1 x double]* %5, i64 0, i64 0
%33 = load double, double* %32
ret double %33
}