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


x86 assembly (clang, -O0):
<pcount_for_goto_jtm>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
jmp    1146 <pcount_for_goto_jtm+0x46>
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    1156 <pcount_for_goto_jtm+0x56>
jmp    111d <pcount_for_goto_jtm+0x1d>
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcount_for_goto_jtm>:
movq   %rdi,%xmm0
pshufd $0x44,%xmm0,%xmm5
pxor   %xmm7,%xmm7
movdqa 0xeea(%rip),%xmm1
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_jtm+0x50>
pshufd $0xee,%xmm7,%xmm0
paddq  %xmm7,%xmm0
movq   %xmm0,%rax
ret

LLVM IR (-O0):
define i64 @pcount_for_goto_jtm(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
br label %18
6: ; preds = %21
%7 = load i64, i64* %2
%8 = load i64, i64* %3
%9 = lshr i64 %7, %8
%10 = and i64 %9, 1
%11 = trunc i64 %10 to i32
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = zext i32 %12 to i64
%14 = load i64, i64* %4
%15 = add nsw i64 %14, %13
store i64 %15, i64* %4
%16 = load i64, i64* %3
%17 = add i64 %16, 1
store i64 %17, i64* %3
br label %18
18: ; preds = %6, %1
%19 = load i64, i64* %3
%20 = icmp ult i64 %19, 64
br i1 %20, label %21, label %22
21: ; preds = %18
br label %6
22: ; preds = %18
%23 = load i64, i64* %4
ret i64 %23
}

LLVM IR (-O2):
define i64 @pcount_for_goto_jtm(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> [ <i64 0, i64 1>, %1 ], [ %24, %4 ]
%7 = phi <2 x i64> [ zeroinitializer, %1 ], [ %22, %4 ]
%8 = lshr <2 x i64> %3, %6
%9 = and <2 x i64> %8, <i64 1, i64 1>
%10 = add <2 x i64> %9, %7
%11 = add <2 x i64> %6, <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> %6, <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> %6, <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> %6, <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
}