#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 */
int EXIT_SUCCESS;
int count(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int);
int main(int argc, char **argv) {
  unsigned int total = 0;
  for (unsigned int exp = 1;; ++exp) {
    int current = count(exp);
    if (current == 0) {
      break;
    } else {
      total += current;
    }
  }
  printf("%d\n", total);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <count@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    115e <main+0x3e>
jmp    117a <main+0x5a>
mov    -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    116c <main+0x4c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <main+0x24>
mov    -0x14(%rbp),%esi
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <count@plt>
add    %eax,%ebx
add    $0x1,%ebp
test   %eax,%eax
jne    1130 <main+0x10>
lea    0xeb9(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ 0, %2 ], [ %8, %3 ]
%5 = phi i32 [ 1, %2 ], [ %9, %3 ]
%6 = tail call i32 @count(i32 %5)
%7 = icmp eq i32 %6, 0
%8 = add i32 %6, %4
%9 = add i32 %5, 1
br i1 %7, label %10, label %3
10: ; preds = %3
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%12 = load i32, i32* @EXIT_SUCCESS
ret i32 %12
}