#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 /*<<< orphan*/ assert(int);
int sphere_ico_point_count(int level) {
  int i, count;
  assert(level >= 1);
  count = 12;
  count += 30 * (level - 1);
  for (i = 1; i < level - 1; i++)
    count += 20 * i;
  return count;
}


x86 assembly (clang, -O0):
<sphere_ico_point_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0xc,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
imul   $0x1e,%eax,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1172 <sphere_ico_point_count+0x62>
imul   $0x14,-0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <sphere_ico_point_count+0x39>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sphere_ico_point_count>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
test   %ebx,%ebx
setg   %dil
call   1030 <assert@plt>
cmp    $0x3,%ebx
jl     1140 <sphere_ico_point_count+0x30>
imul   $0x46,%ebx,%eax
lea    -0x3(%rbx),%ecx
add    $0xfffffffc,%ebx
imul   %rcx,%rbx
shr    %rbx
lea    (%rbx,%rbx,4),%ecx
lea    (%rax,%rcx,4),%eax
add    $0xffffff8a,%eax
pop    %rbx
ret
mov    %ebx,%eax
shl    $0x5,%eax
sub    %ebx,%eax
sub    %ebx,%eax
add    $0xffffffee,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @sphere_ico_point_count(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp sge i32 %5, 1
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
store i32 12, i32* %4
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, 1
%11 = mul nsw i32 30, %10
%12 = load i32, i32* %4
%13 = add nsw i32 %12, %11
store i32 %13, i32* %4
store i32 1, i32* %3
br label %14
14: ; preds = %24, %1
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = sub nsw i32 %16, 1
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %27
19: ; preds = %14
%20 = load i32, i32* %3
%21 = mul nsw i32 20, %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, %21
store i32 %23, i32* %4
br label %24
24: ; preds = %19
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %14
27: ; preds = %14
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
define i32 @sphere_ico_point_count(i32 %0) {
%2 = icmp sgt i32 %0, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = mul i32 %0, 30
%6 = add i32 %5, -18
%7 = icmp sgt i32 %0, 2
br i1 %7, label %8, label %20
8: ; preds = %1
%9 = mul i32 %0, 70
%10 = add nsw i32 %0, -3
%11 = zext i32 %10 to i33
%12 = add nsw i32 %0, -4
%13 = zext i32 %12 to i33
%14 = mul i33 %11, %13
%15 = lshr i33 %14, 1
%16 = trunc i33 %15 to i32
%17 = mul i32 %16, 20
%18 = add i32 %9, %17
%19 = add i32 %18, -118
br label %20
20: ; preds = %8, %1
%21 = phi i32 [ %6, %1 ], [ %19, %8 ]
ret i32 %21
}