#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 /*<<< orphan*/ uint64_t;

/* Variables and functions */
scalar_t__ gbit_index(int /*<<< orphan*/ *, int *);
int get_occupation(int *occ, uint64_t str) {
  int id = -1;
  int count = 0;
  while (gbit_index(&str, &id)) {
    occ[count++] = id;
  }
  return count;
}


x86 assembly (clang, -O0):
<get_occupation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0xffffffff,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <gbit_index@plt>
cmp    $0x0,%rax
je     1161 <get_occupation+0x51>
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    112d <get_occupation+0x1d>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_occupation>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %esi,0x4(%rsp)
movl   $0xffffffff,(%rsp)
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <gbit_index@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     116b <get_occupation+0x5b>
lea    0x4(%rsp),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp),%eax
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <gbit_index@plt>
test   %rax,%rax
jne    1150 <get_occupation+0x40>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @get_occupation(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 -1, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %10, %2
%8 = call i64 @gbit_index(i32* %4, i32* %5)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load i32, i32* %5
%12 = load i32*, i32** %3
%13 = load i32, i32* %6
%14 = add nsw i32 %13, 1
store i32 %14, i32* %6
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds i32, i32* %12, i64 %15
store i32 %11, i32* %16
br label %7
17: ; preds = %7
%18 = load i32, i32* %6
ret i32 %18
}

LLVM IR (-O2):
define i32 @get_occupation(i32* nocapture writeonly %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %1, i32* %3
%5 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
%6 = call i64 @gbit_index(i32* %3, i32* %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %11, %8 ], [ 0, %2 ]
%10 = load i32, i32* %4
%11 = add nuw i64 %9, 1
%12 = getelementptr inbounds i32, i32* %0, i64 %9
store i32 %10, i32* %12
%13 = call i64 @gbit_index(i32* %3, i32* %4)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %8
15: ; preds = %8
%16 = trunc i64 %11 to i32
br label %17
17: ; preds = %15, %2
%18 = phi i32 [ 0, %2 ], [ %16, %15 ]
ret i32 %18
}