#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 uint32_t;
typedef int int_fast16_t;
typedef int int32_t;

/* Variables and functions */
int softfloat_countLeadingZeros32(int);
int /*<<< orphan*/ softfloat_roundPackMToF128M(int, int, int *, int *);
int /*<<< orphan*/ softfloat_shiftLeftM(int, int *, int, int *);
void softfloat_normRoundPackMToF128M(bool sign, int32_t exp,
                                     uint32_t *extSigPtr, uint32_t *zWPtr) {
  const uint32_t *ptr;
  int_fast16_t shiftCount;
  uint32_t wordSig;
  ptr = extSigPtr + ((5) - 1);
  shiftCount = 0;
  for (;;) {
    wordSig = *ptr;
    if (wordSig)
      break;
    shiftCount += 32;
    if (160 <= shiftCount) {
      zWPtr[((4) - 1)] =
          (((uint32_t)(sign) << 31) + ((uint32_t)(0) << 16) + (0));
      zWPtr[(2)] = 0;
      zWPtr[(1)] = 0;
      zWPtr[(0)] = 0;
      return;
    }
    ptr -= 1;
  }
  shiftCount += softfloat_countLeadingZeros32(wordSig) - 15;
  if (shiftCount) {
    exp -= shiftCount;
    softfloat_shiftLeftM(5, extSigPtr, shiftCount, extSigPtr);
  }
  softfloat_roundPackMToF128M(sign, exp, extSigPtr, zWPtr);
}


x86 assembly (clang, -O0):
<softfloat_normRoundPackMToF128M>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1171 <softfloat_normRoundPackMToF128M+0x41>
jmp    11d1 <softfloat_normRoundPackMToF128M+0xa1>
mov    -0x24(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x24(%rbp)
mov    $0xa0,%eax
cmp    -0x24(%rbp),%eax
jg     11c0 <softfloat_normRoundPackMToF128M+0x90>
mov    -0x4(%rbp),%ecx
shl    $0x1f,%ecx
add    $0x0,%ecx
add    $0x0,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    121f <softfloat_normRoundPackMToF128M+0xef>
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rbp)
jmp    1159 <softfloat_normRoundPackMToF128M+0x29>
mov    -0x28(%rbp),%edi
call   1050 <softfloat_countLeadingZeros32@plt>
sub    $0xf,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     120c <softfloat_normRoundPackMToF128M+0xdc>
mov    -0x24(%rbp),%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x5,%edi
call   1030 <softfloat_shiftLeftM@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1040 <softfloat_roundPackMToF128M@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<softfloat_normRoundPackMToF128M>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%r12d
mov    %edi,%r15d
mov    0x10(%rdx),%edi
mov    $0xfffffff1,%ebp
test   %edi,%edi
jne    117f <softfloat_normRoundPackMToF128M+0x4f>
mov    0xc(%rbx),%edi
mov    $0x11,%ebp
test   %edi,%edi
jne    117f <softfloat_normRoundPackMToF128M+0x4f>
mov    0x8(%rbx),%edi
mov    $0x31,%ebp
test   %edi,%edi
jne    117f <softfloat_normRoundPackMToF128M+0x4f>
mov    0x4(%rbx),%edi
mov    $0x51,%ebp
test   %edi,%edi
jne    117f <softfloat_normRoundPackMToF128M+0x4f>
mov    (%rbx),%edi
mov    $0x71,%ebp
test   %edi,%edi
je     11b6 <softfloat_normRoundPackMToF128M+0x86>
call   1050 <softfloat_countLeadingZeros32@plt>
add    %ebp,%eax
je     119d <softfloat_normRoundPackMToF128M+0x6d>
sub    %eax,%r12d
mov    $0x5,%edi
mov    %rbx,%rsi
mov    %eax,%edx
mov    %rbx,%rcx
call   1030 <softfloat_shiftLeftM@plt>
mov    %r15d,%edi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <softfloat_roundPackMToF128M@plt>
shl    $0x1f,%r15d
mov    %r15d,0xc(%r14)
movl   $0x0,0x8(%r14)
movq   $0x0,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @softfloat_normRoundPackMToF128M(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 i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%12 = load i32*, i32** %7
%13 = getelementptr inbounds i32, i32* %12, i64 4
store i32* %13, i32** %9
store i32 0, i32* %10
br label %14
14: ; preds = %38, %4
%15 = load i32*, i32** %9
%16 = load i32, i32* %15
store i32 %16, i32* %11
%17 = load i32, i32* %11
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
br label %41
20: ; preds = %14
%21 = load i32, i32* %10
%22 = add nsw i32 %21, 32
store i32 %22, i32* %10
%23 = load i32, i32* %10
%24 = icmp sle i32 160, %23
br i1 %24, label %25, label %38
25: ; preds = %20
%26 = load i32, i32* %5
%27 = shl i32 %26, 31
%28 = add nsw i32 %27, 0
%29 = add nsw i32 %28, 0
%30 = load i32*, i32** %8
%31 = getelementptr inbounds i32, i32* %30, i64 3
store i32 %29, i32* %31
%32 = load i32*, i32** %8
%33 = getelementptr inbounds i32, i32* %32, i64 2
store i32 0, i32* %33
%34 = load i32*, i32** %8
%35 = getelementptr inbounds i32, i32* %34, i64 1
store i32 0, i32* %35
%36 = load i32*, i32** %8
%37 = getelementptr inbounds i32, i32* %36, i64 0
store i32 0, i32* %37
br label %63
38: ; preds = %20
%39 = load i32*, i32** %9
%40 = getelementptr inbounds i32, i32* %39, i64 -1
store i32* %40, i32** %9
br label %14
41: ; preds = %19
%42 = load i32, i32* %11
%43 = call i32 @softfloat_countLeadingZeros32(i32 %42)
%44 = sub nsw i32 %43, 15
%45 = load i32, i32* %10
%46 = add nsw i32 %45, %44
store i32 %46, i32* %10
%47 = load i32, i32* %10
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %57
49: ; preds = %41
%50 = load i32, i32* %10
%51 = load i32, i32* %6
%52 = sub nsw i32 %51, %50
store i32 %52, i32* %6
%53 = load i32*, i32** %7
%54 = load i32, i32* %10
%55 = load i32*, i32** %7
%56 = call i32 @softfloat_shiftLeftM(i32 5, i32* %53, i32 %54, i32* %55)
br label %57
57: ; preds = %49, %41
%58 = load i32, i32* %5
%59 = load i32, i32* %6
%60 = load i32*, i32** %7
%61 = load i32*, i32** %8
%62 = call i32 @softfloat_roundPackMToF128M(i32 %58, i32 %59, i32* %60, i32* %61)
br label %63
63: ; preds = %57, %25
ret void
}

LLVM IR (-O2):
define void @softfloat_normRoundPackMToF128M(i32 %0, i32 %1, i32* %2, i32* %3) {
%5 = getelementptr inbounds i32, i32* %2, i64 4
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %28
8: ; preds = %4
%9 = getelementptr inbounds i32, i32* %2, i64 3
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %28
12: ; preds = %25
%13 = shl i32 %0, 31
%14 = getelementptr inbounds i32, i32* %3, i64 3
store i32 %13, i32* %14
%15 = getelementptr inbounds i32, i32* %3, i64 2
store i32 0, i32* %15
%16 = getelementptr inbounds i32, i32* %3, i64 1
store i32 0, i32* %16
store i32 0, i32* %3
br label %40
17: ; preds = %8
%18 = getelementptr inbounds i32, i32* %2, i64 2
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = getelementptr inbounds i32, i32* %2, i64 1
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 0
br i1 %27, label %12, label %28
28: ; preds = %8, %17, %21, %25, %4
%29 = phi i32 [ -15, %4 ], [ 17, %8 ], [ 49, %17 ], [ 81, %21 ], [ 113, %25 ]
%30 = phi i32 [ %6, %4 ], [ %10, %8 ], [ %19, %17 ], [ %23, %21 ], [ %26, %25 ]
%31 = tail call i32 @softfloat_countLeadingZeros32(i32 %30)
%32 = add i32 %29, %31
%33 = icmp eq i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %28
%35 = sub nsw i32 %1, %32
%36 = tail call i32 @softfloat_shiftLeftM(i32 5, i32* %2, i32 %32, i32* %2)
br label %37
37: ; preds = %34, %28
%38 = phi i32 [ %35, %34 ], [ %1, %28 ]
%39 = tail call i32 @softfloat_roundPackMToF128M(i32 %0, i32 %38, i32* %2, i32* %3)
br label %40
40: ; preds = %37, %12
ret void
}