#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 */
struct ltable_key {
  int dummy;
};
struct ltable {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ _resize(struct ltable *, int, int);
int computesizes(int *, int *);
scalar_t__ countint(struct ltable_key const *, int *);
int numusearray(struct ltable *, int *);
scalar_t__ numusehash(struct ltable *, int *, int *);
void _rehash(struct ltable *t, const struct ltable_key *ek) {
  int nasize, na;
  int nums[30 + 1];
  int i;
  int totaluse;
  for (i = 0; i <= 30; i++)
    nums[i] = 0;
  nasize = numusearray(t, nums);
  totaluse = nasize;
  totaluse += numusehash(t, nums, &nasize);
  nasize += countint(ek, nums);
  totaluse++;
  na = computesizes(nums, &nasize);
  _resize(t, nasize, totaluse - na);
}


x86 assembly (clang, -O0):
<_rehash>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xa4(%rbp)
cmpl   $0x1e,-0xa4(%rbp)
jg     11a0 <_rehash+0x50>
movslq -0xa4(%rbp),%rax
movl   $0x0,-0xa0(%rbp,%rax,4)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    116d <_rehash+0x1d>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1070 <numusearray@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <numusehash@plt>
mov    %rax,%rcx
movslq -0xa8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0xa8(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1050 <countint@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
lea    -0xa0(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <computesizes@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0xa8(%rbp),%edx
sub    -0x18(%rbp),%edx
call   1060 <_resize@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_rehash>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%r14
mov    %rdi,%r13
xorps  %xmm0,%xmm0
movups %xmm0,0x7c(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%r15
mov    %r15,%rsi
call   1070 <numusearray@plt>
mov    %eax,%ebp
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%r12
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <numusehash@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <countint@plt>
add    %eax,0xc(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <computesizes@plt>
mov    0xc(%rsp),%esi
add    %ebp,%ebx
sub    %eax,%ebx
add    $0x1,%ebx
mov    %r13,%rdi
mov    %ebx,%edx
call   1060 <_resize@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ltable = type { i32 }
%struct.ltable_key = type { i32 }
define void @_rehash(%struct.ltable* %0, %struct.ltable_key* %1) {
%3 = alloca %struct.ltable*
%4 = alloca %struct.ltable_key*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [31 x i32]
%8 = alloca i32
%9 = alloca i32
store %struct.ltable* %0, %struct.ltable** %3
store %struct.ltable_key* %1, %struct.ltable_key** %4
store i32 0, i32* %8
br label %10
10: ; preds = %17, %2
%11 = load i32, i32* %8
%12 = icmp sle i32 %11, 30
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %8
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [31 x i32], [31 x i32]* %7, i64 0, i64 %15
store i32 0, i32* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* %8
%19 = add nsw i32 %18, 1
store i32 %19, i32* %8
br label %10
20: ; preds = %10
%21 = load %struct.ltable*, %struct.ltable** %3
%22 = getelementptr inbounds [31 x i32], [31 x i32]* %7, i64 0, i64 0
%23 = call i32 @numusearray(%struct.ltable* %21, i32* %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
store i32 %24, i32* %9
%25 = load %struct.ltable*, %struct.ltable** %3
%26 = getelementptr inbounds [31 x i32], [31 x i32]* %7, i64 0, i64 0
%27 = call i64 @numusehash(%struct.ltable* %25, i32* %26, i32* %5)
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = add nsw i64 %29, %27
%31 = trunc i64 %30 to i32
store i32 %31, i32* %9
%32 = load %struct.ltable_key*, %struct.ltable_key** %4
%33 = getelementptr inbounds [31 x i32], [31 x i32]* %7, i64 0, i64 0
%34 = call i64 @countint(%struct.ltable_key* %32, i32* %33)
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = add nsw i64 %36, %34
%38 = trunc i64 %37 to i32
store i32 %38, i32* %5
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
%41 = getelementptr inbounds [31 x i32], [31 x i32]* %7, i64 0, i64 0
%42 = call i32 @computesizes(i32* %41, i32* %5)
store i32 %42, i32* %6
%43 = load %struct.ltable*, %struct.ltable** %3
%44 = load i32, i32* %5
%45 = load i32, i32* %9
%46 = load i32, i32* %6
%47 = sub nsw i32 %45, %46
%48 = call i32 @_resize(%struct.ltable* %43, i32 %44, i32 %47)
ret void
}

LLVM IR (-O2):
%struct.ltable = type { i32 }
%struct.ltable_key = type { i32 }
define void @_rehash(%struct.ltable* %0, %struct.ltable_key* %1) {
%3 = alloca i32
%4 = alloca [31 x i32]
%5 = bitcast [31 x i32]* %4 to i8*
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [31 x i32], [31 x i32]* %4, i64 0, i64 0
%8 = call i32 @numusearray(%struct.ltable* %0, i32* %7)
store i32 %8, i32* %3
%9 = call i64 @numusehash(%struct.ltable* %0, i32* %7, i32* %3)
%10 = trunc i64 %9 to i32
%11 = call i64 @countint(%struct.ltable_key* %1, i32* %7)
%12 = load i32, i32* %3
%13 = trunc i64 %11 to i32
%14 = add i32 %12, %13
store i32 %14, i32* %3
%15 = call i32 @computesizes(i32* %7, i32* %3)
%16 = load i32, i32* %3
%17 = add i32 %8, 1
%18 = add i32 %17, %10
%19 = sub i32 %18, %15
%20 = call i32 @_resize(%struct.ltable* %0, i32 %16, i32 %19)
ret void
}