#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*/ calculateSumFactorSieve(int *);
int /*<<< orphan*/ memset(int *, int, int);
void prepareMapSumFactorToNum(int mapSumFactorToNum[]) {
  int sumFactorSieve[1000 + 1], n;
  memset(mapSumFactorToNum, -1, (1000 + 1) * sizeof(int));
  calculateSumFactorSieve(sumFactorSieve);
  for (n = 1; n <= 1000; n++) {
    if (sumFactorSieve[n] <= 1000 && n > mapSumFactorToNum[sumFactorSieve[n]])
      mapSumFactorToNum[sumFactorSieve[n]] = n;
  }
}


x86 assembly (clang, -O0):
<prepareMapSumFactorToNum>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xffffffff,%esi
mov    $0xfa4,%edx
call   1030 <memset@plt>
lea    -0xfb0(%rbp),%rdi
call   1040 <calculateSumFactorSieve@plt>
movl   $0x1,-0xfb4(%rbp)
cmpl   $0x3e8,-0xfb4(%rbp)
jg     11d7 <prepareMapSumFactorToNum+0xb7>
movslq -0xfb4(%rbp),%rax
cmpl   $0x3e8,-0xfb0(%rbp,%rax,4)
jg     11be <prepareMapSumFactorToNum+0x9e>
mov    -0xfb4(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0xfb4(%rbp),%rdx
movslq -0xfb0(%rbp,%rdx,4),%rdx
ff
cmp    (%rcx,%rdx,4),%eax
jle    11be <prepareMapSumFactorToNum+0x9e>
mov    -0xfb4(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0xfb4(%rbp),%rcx
movslq -0xfb0(%rbp,%rcx,4),%rcx
ff
mov    %edx,(%rax,%rcx,4)
jmp    11c3 <prepareMapSumFactorToNum+0xa3>
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    1158 <prepareMapSumFactorToNum+0x38>
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepareMapSumFactorToNum>:
push   %rbx
sub    $0xfb0,%rsp
mov    %rdi,%rbx
mov    $0xffffffff,%esi
mov    $0xfa4,%edx
call   1030 <memset@plt>
mov    %rsp,%rdi
call   1040 <calculateSumFactorSieve@plt>
mov    $0x2,%eax
jmp    115c <prepareMapSumFactorToNum+0x3c>
nopl   0x0(%rax)
add    $0x2,%rax
cmp    $0x3ea,%rax
je     1198 <prepareMapSumFactorToNum+0x78>
lea    -0x1(%rax),%rcx
movslq -0x4(%rsp,%rax,4),%rdx
cmp    $0x3e8,%rdx
jg     117d <prepareMapSumFactorToNum+0x5d>
movslq (%rbx,%rdx,4),%rsi
cmp    %rsi,%rcx
jle    117d <prepareMapSumFactorToNum+0x5d>
lea    -0x1(%rax),%esi
mov    %esi,(%rbx,%rdx,4)
movslq (%rsp,%rax,4),%rdx
cmp    $0x3e8,%rdx
jg     1150 <prepareMapSumFactorToNum+0x30>
movslq (%rbx,%rdx,4),%rsi
cmp    %rsi,%rcx
jl     1150 <prepareMapSumFactorToNum+0x30>
mov    %eax,(%rbx,%rdx,4)
jmp    1150 <prepareMapSumFactorToNum+0x30>
add    $0xfb0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @prepareMapSumFactorToNum(i32* %0) {
%2 = alloca i32*
%3 = alloca [1001 x i32]
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @memset(i32* %5, i32 -1, i32 4004)
%7 = getelementptr inbounds [1001 x i32], [1001 x i32]* %3, i64 0, i64 0
%8 = call i32 @calculateSumFactorSieve(i32* %7)
store i32 1, i32* %4
br label %9
9: ; preds = %39, %1
%10 = load i32, i32* %4
%11 = icmp sle i32 %10, 1000
br i1 %11, label %12, label %42
12: ; preds = %9
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [1001 x i32], [1001 x i32]* %3, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = icmp sle i32 %16, 1000
br i1 %17, label %18, label %38
18: ; preds = %12
%19 = load i32, i32* %4
%20 = load i32*, i32** %2
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1001 x i32], [1001 x i32]* %3, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %20, i64 %25
%27 = load i32, i32* %26
%28 = icmp sgt i32 %19, %27
br i1 %28, label %29, label %38
29: ; preds = %18
%30 = load i32, i32* %4
%31 = load i32*, i32** %2
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1001 x i32], [1001 x i32]* %3, i64 0, i64 %33
%35 = load i32, i32* %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %31, i64 %36
store i32 %30, i32* %37
br label %38
38: ; preds = %29, %18, %12
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %9
42: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @prepareMapSumFactorToNum(i32* %0) {
%2 = alloca [1001 x i32]
%3 = bitcast [1001 x i32]* %2 to i8*
%4 = tail call i32 @memset(i32* %0, i32 -1, i32 4004)
%5 = getelementptr inbounds [1001 x i32], [1001 x i32]* %2, i64 0, i64 0
%6 = call i32 @calculateSumFactorSieve(i32* %5)
br label %7
7: ; preds = %33, %1
%8 = phi i64 [ 1, %1 ], [ %34, %33 ]
%9 = getelementptr inbounds [1001 x i32], [1001 x i32]* %2, i64 0, i64 %8
%10 = load i32, i32* %9
%11 = icmp slt i32 %10, 1001
br i1 %11, label %12, label %20
12: ; preds = %7
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = load i32, i32* %14
%16 = sext i32 %15 to i64
%17 = icmp sgt i64 %8, %16
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = trunc i64 %8 to i32
store i32 %19, i32* %14
br label %20
20: ; preds = %7, %12, %18
%21 = add nuw nsw i64 %8, 1
%22 = getelementptr inbounds [1001 x i32], [1001 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp slt i32 %23, 1001
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = sext i32 %23 to i64
%27 = getelementptr inbounds i32, i32* %0, i64 %26
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %8, %29
br i1 %30, label %33, label %31
31: ; preds = %25
%32 = trunc i64 %21 to i32
store i32 %32, i32* %27
br label %33
33: ; preds = %31, %25, %20
%34 = add nuw nsw i64 %8, 2
%35 = icmp eq i64 %34, 1001
br i1 %35, label %36, label %7
36: ; preds = %33
ret void
}