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


x86 assembly (clang, -O0):
<_dsub>:
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 <_dsub+0x8f>
mov    -0xc(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     1190 <_dsub+0x60>
lea    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
and    $0x7fffffff,%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    11ba <_dsub+0x8a>
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
and    $0x7fffffff,%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%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    1212 <_dsub+0xe2>
mov    -0xc(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     11f4 <_dsub+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   1050 <flt_sum@plt>
mov    %eax,-0x14(%rbp)
jmp    120d <_dsub+0xdd>
lea    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
call   1040 <flt_difference@plt>
mov    %eax,-0x14(%rbp)
jmp    1212 <_dsub+0xe2>
cmpl   $0x0,-0x14(%rbp)
jne    1226 <_dsub+0xf6>
mov    $0x8,%edi
call   1030 <raise@plt>
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dsub>:
push   %rax
mov    %ecx,%r8d
mov    %edx,%eax
mov    %esi,%r9d
mov    %edi,%ecx
test   %edi,%edi
js     114f <_dsub+0x1f>
test   %eax,%eax
js     1173 <_dsub+0x43>
mov    %rsp,%rdi
mov    %ecx,%esi
mov    %r9d,%edx
mov    %eax,%ecx
jmp    11a3 <_dsub+0x73>
test   %eax,%eax
js     118d <_dsub+0x5d>
and    $0x7fffffff,%ecx
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    11b6 <_dsub+0x86>
jmp    11ac <_dsub+0x7c>
and    $0x7fffffff,%eax
mov    %rsp,%rdi
mov    %ecx,%esi
mov    %r9d,%edx
mov    %eax,%ecx
call   1050 <flt_sum@plt>
test   %eax,%eax
jne    11b6 <_dsub+0x86>
jmp    11ac <_dsub+0x7c>
and    $0x7fffffff,%eax
and    $0x7fffffff,%ecx
mov    %rsp,%rdi
mov    %eax,%esi
mov    %r8d,%edx
mov    %r9d,%r8d
call   1040 <flt_difference@plt>
test   %eax,%eax
jne    11b6 <_dsub+0x86>
mov    $0x8,%edi
call   1030 <raise@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @_dsub(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 %28
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* %7
%22 = and i32 %21, 2147483647
%23 = load i32, i32* %8
%24 = load i32, i32* %5
%25 = and i32 %24, 2147483647
%26 = load i32, i32* %6
%27 = call i32 @flt_difference(i32* %20, i32 %22, i32 %23, i32 %25, i32 %26)
store i32 %27, i32* %9
br label %42
28: ; preds = %14
%29 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 0
%30 = bitcast double* %29 to i32*
%31 = load i32, i32* %5
%32 = and i32 %31, 2147483647
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = load i32, i32* %8
%36 = call i32 @flt_sum(i32* %30, i32 %32, i32 %33, i32 %34, i32 %35)
store i32 %36, i32* %9
%37 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 0
%38 = bitcast double* %37 to i32*
%39 = getelementptr inbounds i32, i32* %38, i64 0
%40 = load i32, i32* %39
%41 = xor i32 %40, -2147483648
store i32 %41, i32* %39
br label %42
42: ; preds = %28, %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_sum(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_difference(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 %70, label %68
68: ; preds = %65
%69 = call i32 @raise(i32 8)
br label %70
70: ; preds = %68, %65
%71 = getelementptr inbounds [1 x double], [1 x double]* %10, i64 0, i64 0
%72 = load double, double* %71
ret double %72
}

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