#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 */
scalar_t__ mpz_cmp_ui(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_fac_ui(int /*<<< orphan*/, int);
scalar_t__ mpz_get_ui(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_tdiv_qr_ui(int /*<<< orphan*/, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  mpz_t a, r;
  mpz_init(a);
  mpz_init(r);
  int digsum = 0;
  mpz_fac_ui(a, 100);
  while (mpz_cmp_ui(a, 0)) {
    mpz_tdiv_qr_ui(a, r, a, 10);
    digsum += mpz_get_ui(r);
  }
  printf("%d\n", digsum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <mpz_init@plt>
mov    -0xc(%rbp),%edi
call   1040 <mpz_init@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x64,%esi
call   1060 <mpz_fac_ui@plt>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1080 <mpz_cmp_ui@plt>
cmp    $0x0,%rax
je     11d4 <main+0x74>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    $0xa,%ecx
call   1050 <mpz_tdiv_qr_ui@plt>
mov    -0xc(%rbp),%edi
call   1070 <mpz_get_ui@plt>
mov    %rax,%rcx
movslq -0x10(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x10(%rbp)
jmp    1193 <main+0x33>
mov    -0x10(%rbp),%esi
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
call   1040 <mpz_init@plt>
call   1040 <mpz_init@plt>
mov    $0x64,%esi
call   1060 <mpz_fac_ui@plt>
xor    %ebx,%ebx
xor    %esi,%esi
call   1080 <mpz_cmp_ui@plt>
test   %rax,%rax
je     11ad <main+0x4d>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%ecx
call   1050 <mpz_tdiv_qr_ui@plt>
call   1070 <mpz_get_ui@plt>
add    %eax,%ebx
xor    %esi,%esi
call   1080 <mpz_cmp_ui@plt>
test   %rax,%rax
jne    1190 <main+0x30>
lea    0xe4c(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* %2
%6 = call i32 @mpz_init(i32 %5)
%7 = load i32, i32* %3
%8 = call i32 @mpz_init(i32 %7)
store i32 0, i32* %4
%9 = load i32, i32* %2
%10 = call i32 @mpz_fac_ui(i32 %9, i32 100)
br label %11
11: ; preds = %15, %0
%12 = load i32, i32* %2
%13 = call i64 @mpz_cmp_ui(i32 %12, i32 0)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = call i32 @mpz_tdiv_qr_ui(i32 %16, i32 %17, i32 %18, i32 10)
%20 = load i32, i32* %3
%21 = call i64 @mpz_get_ui(i32 %20)
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = add nsw i64 %23, %21
%25 = trunc i64 %24 to i32
store i32 %25, i32* %4
br label %11
26: ; preds = %11
%27 = load i32, i32* %4
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 @mpz_init(i32 undef)
%2 = tail call i32 @mpz_init(i32 undef)
%3 = tail call i32 @mpz_fac_ui(i32 undef, i32 100)
%4 = tail call i64 @mpz_cmp_ui(i32 undef, i32 0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %0, %6
%7 = phi i32 [ %11, %6 ], [ 0, %0 ]
%8 = tail call i32 @mpz_tdiv_qr_ui(i32 undef, i32 undef, i32 undef, i32 10)
%9 = tail call i64 @mpz_get_ui(i32 undef)
%10 = trunc i64 %9 to i32
%11 = add i32 %7, %10
%12 = tail call i64 @mpz_cmp_ui(i32 undef, i32 0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %6
14: ; preds = %6, %0
%15 = phi i32 [ 0, %0 ], [ %11, %6 ]
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
ret i32 0
}