#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*/ free(char *);
int /*<<< orphan*/ mpz_fac_ui(int /*<<< orphan*/, int);
char *mpz_get_str(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
int main(int argc, char **argv) {
  int i, s = 0;
  char *str = NULL;
  mpz_t f;
  mpz_init(f);
  mpz_fac_ui(f, 100);
  str = mpz_get_str(NULL, 10, f);
  for (i = 0; i < strlen(str); i++)
    s += str[i] - '0';
  free(str);
  printf("%d\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <mpz_init@plt>
mov    -0x24(%rbp),%edi
mov    $0x64,%esi
call   1080 <mpz_fac_ui@plt>
mov    -0x24(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%esi
call   1070 <mpz_get_str@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11f5 <main+0x95>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b6 <main+0x56>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%esi
lea    0xdf8(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
call   1060 <mpz_init@plt>
mov    $0x64,%esi
call   1080 <mpz_fac_ui@plt>
xor    %r15d,%r15d
xor    %edi,%edi
mov    $0xa,%esi
call   1070 <mpz_get_str@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11bf <main+0x5f>
xor    %ebx,%ebx
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%eax
add    %eax,%r15d
add    $0xffffffd0,%r15d
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11a0 <main+0x40>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xe32(%rip),%rdi
mov    %r15d,%esi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i8* null, i8** %8
%10 = load i32, i32* %9
%11 = call i32 @mpz_init(i32 %10)
%12 = load i32, i32* %9
%13 = call i32 @mpz_fac_ui(i32 %12, i32 100)
%14 = load i32, i32* %9
%15 = call i8* @mpz_get_str(i32* null, i32 10, i32 %14)
store i8* %15, i8** %8
store i32 0, i32* %6
br label %16
16: ; preds = %31, %2
%17 = load i32, i32* %6
%18 = load i8*, i8** %8
%19 = call i32 @strlen(i8* %18)
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %34
21: ; preds = %16
%22 = load i8*, i8** %8
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 48
%29 = load i32, i32* %7
%30 = add nsw i32 %29, %28
store i32 %30, i32* %7
br label %31
31: ; preds = %21
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %16
34: ; preds = %16
%35 = load i8*, i8** %8
%36 = call i32 @free(i8* %35)
%37 = load i32, i32* %7
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %37)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @mpz_init(i32 undef)
%4 = tail call i32 @mpz_fac_ui(i32 undef, i32 100)
%5 = tail call i8* @mpz_get_str(i32* null, i32 10, i32 undef)
%6 = tail call i32 @strlen(i8* %5)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %2, %8
%9 = phi i64 [ %16, %8 ], [ 0, %2 ]
%10 = phi i32 [ %15, %8 ], [ 0, %2 ]
%11 = getelementptr inbounds i8, i8* %5, i64 %9
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = add i32 %10, -48
%15 = add i32 %14, %13
%16 = add nuw nsw i64 %9, 1
%17 = tail call i32 @strlen(i8* %5)
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %8, label %20
20: ; preds = %8, %2
%21 = phi i32 [ 0, %2 ], [ %15, %8 ]
%22 = tail call i32 @free(i8* %5)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
ret i32 0
}