#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 getNumRawDataModules(int version) {
  assert(1 <= version && version <= 40);
  int result = (16 * version + 128) * version + 64;
  if (version >= 2) {
    int numAlign = version / 7 + 2;
    result -= (25 * numAlign - 10) * numAlign - 55;
    if (version >= 7)
      result -= 18 * 2;
  }
  return result;
}


x86 assembly (clang, -O0):
<getNumRawDataModules>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    $0x1,%ecx
cmp    -0x4(%rbp),%ecx
mov    %al,-0xd(%rbp)
jg     1138 <getNumRawDataModules+0x28>
cmpl   $0x28,-0x4(%rbp)
setle  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
shl    $0x4,%eax
add    $0x80,%eax
imul   -0x4(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x2,-0x4(%rbp)
jl     11a3 <getNumRawDataModules+0x93>
mov    -0x4(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
imul   $0x19,-0xc(%rbp),%ecx
sub    $0xa,%ecx
imul   -0xc(%rbp),%ecx
sub    $0x37,%ecx
mov    -0x8(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x7,-0x4(%rbp)
jl     119e <getNumRawDataModules+0x8e>
mov    -0x8(%rbp),%eax
sub    $0x24,%eax
mov    %eax,-0x8(%rbp)
jmp    11a3 <getNumRawDataModules+0x93>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNumRawDataModules>:
push   %rbx
mov    %edi,%ebx
lea    -0x1(%rbx),%eax
xor    %edi,%edi
cmp    $0x28,%eax
setb   %dil
call   1030 <assert@plt>
mov    %ebx,%eax
shl    $0x4,%eax
sub    $0xffffff80,%eax
imul   %ebx,%eax
cmp    $0x2,%ebx
jl     1168 <getNumRawDataModules+0x58>
mov    %ebx,%ecx
imul   $0x24924925,%rcx,%rcx
shr    $0x20,%rcx
mov    %ebx,%edx
sub    %ecx,%edx
shr    %edx
add    %ecx,%edx
shr    $0x2,%edx
add    $0x2,%edx
imul   $0xffffffe7,%edx,%ecx
add    $0xa,%ecx
imul   %edx,%ecx
cmp    $0x7,%ebx
lea    0x53(%rax,%rcx,1),%edx
lea    0x77(%rax,%rcx,1),%eax
cmovae %edx,%eax
pop    %rbx
ret
add    $0x40,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @getNumRawDataModules(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = icmp sle i32 1, %5
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 40
br label %10
10: ; preds = %7, %1
%11 = phi i1 [ false, %1 ], [ %9, %7 ]
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %2
%15 = mul nsw i32 16, %14
%16 = add nsw i32 %15, 128
%17 = load i32, i32* %2
%18 = mul nsw i32 %16, %17
%19 = add nsw i32 %18, 64
store i32 %19, i32* %3
%20 = load i32, i32* %2
%21 = icmp sge i32 %20, 2
br i1 %21, label %22, label %40
22: ; preds = %10
%23 = load i32, i32* %2
%24 = sdiv i32 %23, 7
%25 = add nsw i32 %24, 2
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = mul nsw i32 25, %26
%28 = sub nsw i32 %27, 10
%29 = load i32, i32* %4
%30 = mul nsw i32 %28, %29
%31 = sub nsw i32 %30, 55
%32 = load i32, i32* %3
%33 = sub nsw i32 %32, %31
store i32 %33, i32* %3
%34 = load i32, i32* %2
%35 = icmp sge i32 %34, 7
br i1 %35, label %36, label %39
36: ; preds = %22
%37 = load i32, i32* %3
%38 = sub nsw i32 %37, 36
store i32 %38, i32* %3
br label %39
39: ; preds = %36, %22
br label %40
40: ; preds = %39, %10
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
define i32 @getNumRawDataModules(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 40
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = shl nsw i32 %0, 4
%7 = add nsw i32 %6, 128
%8 = mul nsw i32 %7, %0
%9 = add nsw i32 %8, 64
%10 = icmp sgt i32 %0, 1
br i1 %10, label %11, label %22
11: ; preds = %1
%12 = udiv i32 %0, 7
%13 = add nuw nsw i32 %12, 2
%14 = mul i32 %13, -25
%15 = add i32 %14, 10
%16 = mul i32 %15, %13
%17 = add i32 %8, 119
%18 = add i32 %17, %16
%19 = icmp ugt i32 %0, 6
%20 = add nsw i32 %18, -36
%21 = select i1 %19, i32 %20, i32 %18
br label %22
22: ; preds = %11, %1
%23 = phi i32 [ %21, %11 ], [ %9, %1 ]
ret i32 %23
}