#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 */
scalar_t__ log10(int);
void construct_groups(int *group) {
  group[0] = 0;
  int i;
  int acc = 0;
  for (i = 1; acc >= 0; i++) {
    group[i] = group[i - 1] + (int)log10(i * 1.0) + 1;
    acc += group[i];
  }
}


x86 assembly (clang, -O0):
<construct_groups>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     119d <construct_groups+0x8d>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xea2(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log10@plt>
mov    -0x14(%rbp),%edx
add    %eax,%edx
add    $0x1,%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <construct_groups+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<construct_groups>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movl   $0x0,(%rdi)
mov    $0x1,%r15d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1030 <log10@plt>
add    %eax,%ebx
add    $0x1,%ebx
mov    %ebx,(%r14,%r15,4)
add    $0x1,%r15
add    %ebx,%ebp
jns    1130 <construct_groups+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @construct_groups(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = getelementptr inbounds i32, i32* %5, i64 0
store i32 0, i32* %6
store i32 0, i32* %4
store i32 1, i32* %3
br label %7
7: ; preds = %36, %1
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %39
10: ; preds = %7
%11 = load i32*, i32** %2
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %11, i64 %14
%16 = load i32, i32* %15
%17 = load i32, i32* %3
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 1.000000e+00
%20 = fptosi double %19 to i32
%21 = call i64 @log10(i32 %20)
%22 = trunc i64 %21 to i32
%23 = add nsw i32 %16, %22
%24 = add nsw i32 %23, 1
%25 = load i32*, i32** %2
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
store i32 %24, i32* %28
%29 = load i32*, i32** %2
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, %33
store i32 %35, i32* %4
br label %36
36: ; preds = %10
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %7
39: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @construct_groups(i32* nocapture %0) {
store i32 0, i32* %0
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 0, %1 ], [ %10, %2 ]
%4 = phi i64 [ 1, %1 ], [ %13, %2 ]
%5 = phi i32 [ 0, %1 ], [ %12, %2 ]
%6 = trunc i64 %4 to i32
%7 = tail call i64 @log10(i32 %6)
%8 = trunc i64 %7 to i32
%9 = add i32 %3, 1
%10 = add i32 %9, %8
%11 = getelementptr inbounds i32, i32* %0, i64 %4
store i32 %10, i32* %11
%12 = add nsw i32 %10, %5
%13 = add nuw i64 %4, 1
%14 = icmp sgt i32 %12, -1
br i1 %14, label %2, label %15
15: ; preds = %2
ret void
}