#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 */
long pcount_for_goto_dw(unsigned long x) {
  size_t i;
  long result = 0;
  i = 0;
  if (!(i < 8 * sizeof(unsigned long)))
    goto done;
loop : {
  unsigned bit = (x >> i) & 0x1;
  result += bit;
}
  i++;
  if (i < 8 * sizeof(unsigned long))
    goto loop;
done:
  return result;
}


x86 assembly (clang, -O0):
<pcount_for_goto_dw>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x40,-0x10(%rbp)
jb     1128 <pcount_for_goto_dw+0x28>
jmp    116b <pcount_for_goto_dw+0x6b>
jmp    112d <pcount_for_goto_dw+0x2d>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
shr    %cl,%rax
and    $0x1,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x40,-0x10(%rbp)
jae    1166 <pcount_for_goto_dw+0x66>
jmp    112d <pcount_for_goto_dw+0x2d>
jmp    116b <pcount_for_goto_dw+0x6b>
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcount_for_goto_dw>:
movq   %rdi,%xmm0
pshufd $0x44,%xmm0,%xmm5
movdqa 0xeee(%rip),%xmm1
pxor   %xmm7,%xmm7
mov    $0x40,%eax
movapd 0xeed(%rip),%xmm2
movdqa 0xef4(%rip),%xmm8
movdqa 0xefb(%rip),%xmm9
movdqa 0xf02(%rip),%xmm10
movdqa 0xf09(%rip),%xmm11
nopw   0x0(%rax,%rax,1)
movdqa %xmm5,%xmm0
psrlq  %xmm1,%xmm0
pshufd $0xee,%xmm1,%xmm4
movdqa %xmm5,%xmm3
psrlq  %xmm4,%xmm3
movsd  %xmm0,%xmm3
movdqa %xmm1,%xmm0
paddq  %xmm8,%xmm0
movdqa %xmm5,%xmm4
psrlq  %xmm0,%xmm4
andpd  %xmm2,%xmm3
pshufd $0xee,%xmm0,%xmm6
movdqa %xmm5,%xmm0
psrlq  %xmm6,%xmm0
paddq  %xmm7,%xmm3
movsd  %xmm4,%xmm0
andpd  %xmm2,%xmm0
paddq  %xmm3,%xmm0
movdqa %xmm1,%xmm3
paddq  %xmm9,%xmm3
movdqa %xmm5,%xmm4
psrlq  %xmm3,%xmm4
pshufd $0xee,%xmm3,%xmm3
movdqa %xmm5,%xmm6
psrlq  %xmm3,%xmm6
movsd  %xmm4,%xmm6
andpd  %xmm2,%xmm6
movdqa %xmm1,%xmm3
paddq  %xmm10,%xmm3
movdqa %xmm5,%xmm4
psrlq  %xmm3,%xmm4
pshufd $0xee,%xmm3,%xmm3
movdqa %xmm5,%xmm7
psrlq  %xmm3,%xmm7
movsd  %xmm4,%xmm7
andpd  %xmm2,%xmm7
paddq  %xmm6,%xmm7
paddq  %xmm0,%xmm7
paddq  %xmm11,%xmm1
add    $0xfffffffffffffff8,%rax
jne    1150 <pcount_for_goto_dw+0x50>
pshufd $0xee,%xmm7,%xmm0
paddq  %xmm7,%xmm0
movq   %xmm0,%rax
ret

LLVM IR (-O0):
define i64 @pcount_for_goto_dw(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
store i64 %0, i64* %2
store i64 0, i64* %4
store i64 0, i64* %3
%6 = load i64, i64* %3
%7 = icmp ult i64 %6, 64
br i1 %7, label %9, label %8
8: ; preds = %1
br label %26
9: ; preds = %1
br label %10
10: ; preds = %24, %9
%11 = load i64, i64* %2
%12 = load i64, i64* %3
%13 = lshr i64 %11, %12
%14 = and i64 %13, 1
%15 = trunc i64 %14 to i32
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = zext i32 %16 to i64
%18 = load i64, i64* %4
%19 = add nsw i64 %18, %17
store i64 %19, i64* %4
%20 = load i64, i64* %3
%21 = add i64 %20, 1
store i64 %21, i64* %3
%22 = load i64, i64* %3
%23 = icmp ult i64 %22, 64
br i1 %23, label %24, label %25
24: ; preds = %10
br label %10
25: ; preds = %10
br label %26
26: ; preds = %25, %8
%27 = load i64, i64* %4
ret i64 %27
}

LLVM IR (-O2):
define i64 @pcount_for_goto_dw(i64 %0) {
%2 = insertelement <2 x i64> poison, i64 %0, i64 0
%3 = shufflevector <2 x i64> %2, <2 x i64> poison, <2 x i32> zeroinitializer
br label %4
4: ; preds = %4, %1
%5 = phi i64 [ 0, %1 ], [ %23, %4 ]
%6 = phi <2 x i64> [ zeroinitializer, %1 ], [ %22, %4 ]
%7 = phi <2 x i64> [ <i64 0, i64 1>, %1 ], [ %24, %4 ]
%8 = lshr <2 x i64> %3, %7
%9 = and <2 x i64> %8, <i64 1, i64 1>
%10 = add <2 x i64> %9, %6
%11 = add <2 x i64> %7, <i64 2, i64 2>
%12 = lshr <2 x i64> %3, %11
%13 = and <2 x i64> %12, <i64 1, i64 1>
%14 = add <2 x i64> %13, %10
%15 = add <2 x i64> %7, <i64 4, i64 4>
%16 = lshr <2 x i64> %3, %15
%17 = and <2 x i64> %16, <i64 1, i64 1>
%18 = add <2 x i64> %17, %14
%19 = add <2 x i64> %7, <i64 6, i64 6>
%20 = lshr <2 x i64> %3, %19
%21 = and <2 x i64> %20, <i64 1, i64 1>
%22 = add <2 x i64> %21, %18
%23 = add nuw nsw i64 %5, 8
%24 = add <2 x i64> %7, <i64 8, i64 8>
%25 = icmp eq i64 %23, 64
br i1 %25, label %26, label %4
26: ; preds = %4
%27 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %22)
ret i64 %27
}