#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__ malloc(int);
int /*<<< orphan*/ mpz_get_str(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_mul_si(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_set_si(int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
int main() {
  mpz_t n;
  int i;
  char *str = (char *)malloc(1024);
  int sum = 0;
  mpz_init(n);
  mpz_set_si(n, 1);
  for (i = 2; i <= 100; i++)
    mpz_mul_si(n, n, i);
  mpz_get_str(str, 10, n);
  for (i = 0; i < strlen(str); i++)
    sum += str[i] - '0';
  printf("%d\n", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1030 <mpz_set_si@plt>
movl   $0x2,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jg     11d6 <main+0x66>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <mpz_mul_si@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b0 <main+0x40>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0xa,%esi
call   1080 <mpz_get_str@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    122d <main+0xbd>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ee <main+0x7e>
mov    -0x1c(%rbp),%esi
lea    0xdc9(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
call   1070 <mpz_init@plt>
mov    $0x1,%esi
call   1030 <mpz_set_si@plt>
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%edx
call   1040 <mpz_mul_si@plt>
add    $0x1,%ebx
cmp    $0x65,%ebx
jne    11a0 <main+0x30>
mov    %r14,%rdi
mov    $0xa,%esi
call   1080 <mpz_get_str@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11f1 <main+0x81>
xor    %ebx,%ebx
xor    %r15d,%r15d
nopl   (%rax)
movsbl (%r14,%rbx,1),%eax
add    %eax,%r15d
add    $0xffffffd0,%r15d
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     11d0 <main+0x60>
jmp    11f4 <main+0x84>
xor    %r15d,%r15d
lea    0xe05(%rip),%rdi
mov    %r15d,%esi
call   1060 <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() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 0, i32* %1
%6 = call i64 @malloc(i32 1024)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %4
store i32 0, i32* %5
%8 = load i32, i32* %2
%9 = call i32 @mpz_init(i32 %8)
%10 = load i32, i32* %2
%11 = call i32 @mpz_set_si(i32 %10, i32 1)
store i32 2, i32* %3
br label %12
12: ; preds = %20, %0
%13 = load i32, i32* %3
%14 = icmp sle i32 %13, 100
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i32, i32* %2
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = call i32 @mpz_mul_si(i32 %16, i32 %17, i32 %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %12
23: ; preds = %12
%24 = load i8*, i8** %4
%25 = load i32, i32* %2
%26 = call i32 @mpz_get_str(i8* %24, i32 10, i32 %25)
store i32 0, i32* %3
br label %27
27: ; preds = %42, %23
%28 = load i32, i32* %3
%29 = load i8*, i8** %4
%30 = call i32 @strlen(i8* %29)
%31 = icmp slt i32 %28, %30
br i1 %31, label %32, label %45
32: ; preds = %27
%33 = load i8*, i8** %4
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 48
%40 = load i32, i32* %5
%41 = add nsw i32 %40, %39
store i32 %41, i32* %5
br label %42
42: ; preds = %32
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %27
45: ; preds = %27
%46 = load i32, i32* %5
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %46)
%48 = load i32, i32* %1
ret i32 %48
}

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