#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*/ const mpz_t;

/* Variables and functions */
int /*<<< orphan*/ mpz_add_ui(int /*<<< orphan*/ const,
                              int /*<<< orphan*/ const, int);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/ const);
int mpz_count_divisors(int /*<<< orphan*/ const);
int /*<<< orphan*/ mpz_divexact_ui(int /*<<< orphan*/ const,
                                   int /*<<< orphan*/ const, int);
scalar_t__ mpz_even_p(int /*<<< orphan*/ const);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/ const);
int /*<<< orphan*/ mpz_set(int /*<<< orphan*/ const, int /*<<< orphan*/ const);
int count_divisors_of_triangular_num(const mpz_t nth) {
  int count;
  mpz_t n1, n2;
  mpz_init(n1);
  mpz_init(n2);
  if (mpz_even_p(nth)) {
    mpz_divexact_ui(n1, nth, 2);
    mpz_add_ui(n2, nth, 1);
  } else {
    mpz_set(n1, nth);
    mpz_add_ui(n2, nth, 1);
    mpz_divexact_ui(n2, n2, 2);
  }
  count = mpz_count_divisors(n1) * mpz_count_divisors(n2);
  mpz_clear(n1);
  mpz_clear(n2);
  return count;
}


x86 assembly (clang, -O0):
<count_divisors_of_triangular_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x10(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x4(%rbp),%edi
call   1070 <mpz_even_p@plt>
cmp    $0x0,%rax
je     11c2 <count_divisors_of_triangular_num+0x52>
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0x2,%edx
call   1030 <mpz_divexact_ui@plt>
mov    -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
call   1050 <mpz_add_ui@plt>
jmp    11ed <count_divisors_of_triangular_num+0x7d>
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <mpz_set@plt>
mov    -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
call   1050 <mpz_add_ui@plt>
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x2,%edx
call   1030 <mpz_divexact_ui@plt>
mov    -0xc(%rbp),%edi
call   1090 <mpz_count_divisors@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1090 <mpz_count_divisors@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%edi
call   1080 <mpz_clear@plt>
mov    -0x10(%rbp),%edi
call   1080 <mpz_clear@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_divisors_of_triangular_num>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
call   1060 <mpz_init@plt>
call   1060 <mpz_init@plt>
mov    %ebx,%edi
call   1070 <mpz_even_p@plt>
mov    %ebx,%esi
test   %rax,%rax
je     11a5 <count_divisors_of_triangular_num+0x35>
mov    $0x2,%edx
call   1030 <mpz_divexact_ui@plt>
mov    %ebx,%esi
mov    $0x1,%edx
call   1050 <mpz_add_ui@plt>
jmp    11c0 <count_divisors_of_triangular_num+0x50>
call   1040 <mpz_set@plt>
mov    %ebx,%esi
mov    $0x1,%edx
call   1050 <mpz_add_ui@plt>
mov    $0x2,%edx
call   1030 <mpz_divexact_ui@plt>
call   1090 <mpz_count_divisors@plt>
mov    %eax,%ebx
call   1090 <mpz_count_divisors@plt>
mov    %eax,%ebp
imul   %ebx,%ebp
call   1080 <mpz_clear@plt>
call   1080 <mpz_clear@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @count_divisors_of_triangular_num(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %4
%7 = call i32 @mpz_init(i32 %6)
%8 = load i32, i32* %5
%9 = call i32 @mpz_init(i32 %8)
%10 = load i32, i32* %2
%11 = call i64 @mpz_even_p(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %1
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = call i32 @mpz_divexact_ui(i32 %14, i32 %15, i32 2)
%17 = load i32, i32* %5
%18 = load i32, i32* %2
%19 = call i32 @mpz_add_ui(i32 %17, i32 %18, i32 1)
br label %30
20: ; preds = %1
%21 = load i32, i32* %4
%22 = load i32, i32* %2
%23 = call i32 @mpz_set(i32 %21, i32 %22)
%24 = load i32, i32* %5
%25 = load i32, i32* %2
%26 = call i32 @mpz_add_ui(i32 %24, i32 %25, i32 1)
%27 = load i32, i32* %5
%28 = load i32, i32* %5
%29 = call i32 @mpz_divexact_ui(i32 %27, i32 %28, i32 2)
br label %30
30: ; preds = %20, %13
%31 = load i32, i32* %4
%32 = call i32 @mpz_count_divisors(i32 %31)
%33 = load i32, i32* %5
%34 = call i32 @mpz_count_divisors(i32 %33)
%35 = mul nsw i32 %32, %34
store i32 %35, i32* %3
%36 = load i32, i32* %4
%37 = call i32 @mpz_clear(i32 %36)
%38 = load i32, i32* %5
%39 = call i32 @mpz_clear(i32 %38)
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @count_divisors_of_triangular_num(i32 %0) {
%2 = tail call i32 @mpz_init(i32 undef)
%3 = tail call i32 @mpz_init(i32 undef)
%4 = tail call i64 @mpz_even_p(i32 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = tail call i32 @mpz_divexact_ui(i32 undef, i32 %0, i32 2)
%8 = tail call i32 @mpz_add_ui(i32 undef, i32 %0, i32 1)
br label %13
9: ; preds = %1
%10 = tail call i32 @mpz_set(i32 undef, i32 %0)
%11 = tail call i32 @mpz_add_ui(i32 undef, i32 %0, i32 1)
%12 = tail call i32 @mpz_divexact_ui(i32 undef, i32 undef, i32 2)
br label %13
13: ; preds = %9, %6
%14 = tail call i32 @mpz_count_divisors(i32 undef)
%15 = tail call i32 @mpz_count_divisors(i32 undef)
%16 = mul nsw i32 %15, %14
%17 = tail call i32 @mpz_clear(i32 undef)
%18 = tail call i32 @mpz_clear(i32 undef)
ret i32 %16
}