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

/* Variables and functions */
unsigned long long abs(int /*<<< orphan*/);
scalar_t__ factorial(unsigned long long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strtoull(char *);
void main(int argc, char **argv) {
  if (argc == 1) {
    printf("Usage:\neuler [count]\ncount - number of loops");
  }
  unsigned long long sum;
  unsigned long long i;
  for (i = 0; i < abs(strtoull(argv[1])); i++) {
    sum += factorial(i);
    printf("%llu", sum);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1167 <main+0x27>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strtoull@plt>
mov    %eax,%edi
call   1040 <abs@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jae    11cf <main+0x8f>
mov    -0x20(%rbp),%rdi
call   1030 <factorial@plt>
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    116f <main+0x2f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
cmp    $0x1,%edi
jne    115e <main+0x1e>
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%r15),%rdi
call   1060 <strtoull@plt>
mov    %eax,%edi
call   1040 <abs@plt>
test   %rax,%rax
je     11b1 <main+0x71>
lea    0xeb3(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <factorial@plt>
add    %rax,%r12
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
mov    0x8(%r15),%rdi
call   1060 <strtoull@plt>
mov    %eax,%edi
call   1040 <abs@plt>
cmp    %rax,%rbx
jb     1180 <main+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Usage:\0Aeuler [count]\0Acount - number of loops\00"
@.str.1 = [5 x i8] c"%llu\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64
%6 = alloca i64
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
store i64 0, i64* %6
br label %12
12: ; preds = %27, %11
%13 = load i64, i64* %6
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strtoull(i8* %16)
%18 = call i64 @abs(i32 %17)
%19 = icmp ult i64 %13, %18
br i1 %19, label %20, label %30
20: ; preds = %12
%21 = load i64, i64* %6
%22 = call i64 @factorial(i64 %21)
%23 = load i64, i64* %5
%24 = add i64 %23, %22
store i64 %24, i64* %5
%25 = load i64, i64* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %25)
br label %27
27: ; preds = %20
%28 = load i64, i64* %6
%29 = add i64 %28, 1
store i64 %29, i64* %6
br label %12
30: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [45 x i8] c"Usage:\0Aeuler [count]\0Acount - number of loops\00"
@.str.1 = [5 x i8] c"%llu\00"
define void @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strtoull(i8* %8)
%10 = tail call i64 @abs(i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %6, %12
%13 = phi i64 [ %18, %12 ], [ 0, %6 ]
%14 = phi i64 [ %16, %12 ], [ undef, %6 ]
%15 = tail call i64 @factorial(i64 %13)
%16 = add i64 %15, %14
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %16)
%18 = add nuw i64 %13, 1
%19 = load i8*, i8** %7
%20 = tail call i32 @strtoull(i8* %19)
%21 = tail call i64 @abs(i32 %20)
%22 = icmp ult i64 %18, %21
br i1 %22, label %12, label %23
23: ; preds = %12, %6
ret void
}