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

/* Variables and functions */
int /*<<< orphan*/ mpz_fdiv_q_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_set(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ mpz_sgn(int /*<<< orphan*/);
unsigned int num_digits(mpz_t num, mpz_t tmpa, mpz_t tmpb) {
  unsigned int n = 0;
  mpz_set(tmpb, num);
  while (1) {
    mpz_fdiv_q_ui(tmpa, tmpb, 100);
    mpz_set(tmpb, tmpa);
    if (0 == mpz_sgn(tmpa))
      break;
    n += 2;
  }
  return n;
}


x86 assembly (clang, -O0):
<num_digits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1030 <mpz_set@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x64,%edx
call   1040 <mpz_fdiv_q_ui@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <mpz_set@plt>
mov    -0x8(%rbp),%edi
call   1050 <mpz_sgn@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1189 <num_digits+0x59>
jmp    1197 <num_digits+0x67>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    1153 <num_digits+0x23>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_digits>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%esi
mov    %edx,%edi
call   1030 <mpz_set@plt>
mov    $0xfffffffe,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14d,%esi
mov    $0x64,%edx
call   1040 <mpz_fdiv_q_ui@plt>
mov    %r14d,%edi
mov    %ebp,%esi
call   1030 <mpz_set@plt>
mov    %ebp,%edi
call   1050 <mpz_sgn@plt>
add    $0x2,%ebx
test   %rax,%rax
jne    1150 <num_digits+0x20>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @num_digits(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = call i32 @mpz_set(i32 %8, i32 %9)
br label %11
11: ; preds = %3, %22
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = call i32 @mpz_fdiv_q_ui(i32 %12, i32 %13, i32 100)
%15 = load i32, i32* %6
%16 = load i32, i32* %5
%17 = call i32 @mpz_set(i32 %15, i32 %16)
%18 = load i32, i32* %5
%19 = call i64 @mpz_sgn(i32 %18)
%20 = icmp eq i64 0, %19
br i1 %20, label %21, label %22
21: ; preds = %11
br label %25
22: ; preds = %11
%23 = load i32, i32* %7
%24 = add i32 %23, 2
store i32 %24, i32* %7
br label %11
25: ; preds = %21
%26 = load i32, i32* %7
ret i32 %26
}

LLVM IR (-O2):
define i32 @num_digits(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @mpz_set(i32 %2, i32 %0)
br label %5
5: ; preds = %5, %3
%6 = phi i32 [ 0, %3 ], [ %11, %5 ]
%7 = tail call i32 @mpz_fdiv_q_ui(i32 %1, i32 %2, i32 100)
%8 = tail call i32 @mpz_set(i32 %2, i32 %1)
%9 = tail call i64 @mpz_sgn(i32 %1)
%10 = icmp eq i64 %9, 0
%11 = add i32 %6, 2
br i1 %10, label %12, label %5
12: ; preds = %5
ret i32 %6
}