#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*/ exist(int *, int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ increase(int **, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
int sumlista(int *, int);
int main(void) {
  int *lista, lenght = 0;
  int multiples[3] = {3, 5, 0};
  lista = (int *)malloc(sizeof(int));
  for (int i = 0; i < 1000; i++) {
    for (int j = 0; multiples[j] != 0; j++) {
      int mult = multiples[j];
      if (i % mult == 0) {
        if (!exist(lista, lenght, i)) {
          lista[lenght] = i;
          increase(&lista, &lenght);
        }
      }
    }
  }
  int sum = sumlista(lista, lenght);
  printf("%d\n", sum);
  free(lista);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xe83(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe81(%rip),%eax
mov    %eax,-0x18(%rbp)
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3e8,-0x24(%rbp)
jge    123b <main+0xdb>
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmpl   $0x0,-0x20(%rbp,%rax,4)
je     1228 <main+0xc8>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
cltd
idivl  -0x2c(%rbp)
cmp    $0x0,%edx
jne    1215 <main+0xb5>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1040 <exist@plt>
cmp    $0x0,%eax
jne    1210 <main+0xb0>
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1080 <increase@plt>
jmp    1215 <main+0xb5>
jmp    121a <main+0xba>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b3 <main+0x53>
jmp    122d <main+0xcd>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119f <main+0x3f>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <sumlista@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0xdb8(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0xc(%rsp)
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,0x10(%rsp)
xor    %ebx,%ebx
mov    $0xcccccccd,%r12d
mov    $0xaaaaaaab,%r13d
lea    0xc(%rsp),%r15
xor    %ebp,%ebp
jmp    11b2 <main+0x52>
nopl   0x0(%rax)
add    $0x1,%ebp
add    $0xffffffff,%ebx
cmp    $0x3e8,%ebp
je     1243 <main+0xe3>
mov    %ebp,%eax
mov    %rax,%rcx
imul   %r12,%rcx
shr    $0x22,%rcx
lea    (%rcx,%rcx,4),%r14d
add    %ebx,%r14d
imul   %r13,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%eax
add    %ebx,%eax
jne    11e9 <main+0x89>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %ebp,%edx
call   1040 <exist@plt>
test   %eax,%eax
je     121e <main+0xbe>
test   %r14d,%r14d
jne    11a0 <main+0x40>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %ebp,%edx
call   1040 <exist@plt>
test   %eax,%eax
jne    11a0 <main+0x40>
mov    0x10(%rsp),%rax
movslq 0xc(%rsp),%rcx
mov    %ebp,(%rax,%rcx,4)
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
call   1080 <increase@plt>
jmp    11a0 <main+0x40>
mov    0x10(%rsp),%rax
movslq 0xc(%rsp),%rcx
mov    %ebp,(%rax,%rcx,4)
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
call   1080 <increase@plt>
test   %r14d,%r14d
jne    11a0 <main+0x40>
jmp    11ee <main+0x8e>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
call   1060 <sumlista@plt>
lea    0xda8(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.multiples = [3 x i32] [i32 3, i32 5, i32 0]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [3 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%9 = bitcast [3 x i32]* %4 to i8*
%10 = call i64 @malloc(i32 4)
%11 = inttoptr i64 %10 to i32*
store i32* %11, i32** %2
store i32 0, i32* %5
br label %12
12: ; preds = %50, %0
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 1000
br i1 %14, label %15, label %53
15: ; preds = %12
store i32 0, i32* %6
br label %16
16: ; preds = %46, %15
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %49
22: ; preds = %16
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 %24
%26 = load i32, i32* %25
store i32 %26, i32* %7
%27 = load i32, i32* %5
%28 = load i32, i32* %7
%29 = srem i32 %27, %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %45
31: ; preds = %22
%32 = load i32*, i32** %2
%33 = load i32, i32* %3
%34 = load i32, i32* %5
%35 = call i32 @exist(i32* %32, i32 %33, i32 %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %44, label %37
37: ; preds = %31
%38 = load i32, i32* %5
%39 = load i32*, i32** %2
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
store i32 %38, i32* %42
%43 = call i32 @increase(i32** %2, i32* %3)
br label %44
44: ; preds = %37, %31
br label %45
45: ; preds = %44, %22
br label %46
46: ; preds = %45
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %16
49: ; preds = %16
br label %50
50: ; preds = %49
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %12
53: ; preds = %12
%54 = load i32*, i32** %2
%55 = load i32, i32* %3
%56 = call i32 @sumlista(i32* %54, i32 %55)
store i32 %56, i32* %8
%57 = load i32, i32* %8
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %57)
%59 = load i32*, i32** %2
%60 = call i32 @free(i32* %59)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32
%3 = bitcast i32** %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i64 @malloc(i32 4)
%6 = inttoptr i64 %5 to i32*
store i32* %6, i32** %1
br label %7
7: ; preds = %0, %43
%8 = phi i32 [ 0, %0 ], [ %44, %43 ]
%9 = urem i32 %8, 3
%10 = icmp eq i32 %9, 0
br i1 %10, label %18, label %29
11: ; preds = %43
%12 = load i32*, i32** %1
%13 = load i32, i32* %2
%14 = call i32 @sumlista(i32* %12, i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %1
%17 = call i32 @free(i32* %16)
ret i32 0
18: ; preds = %7
%19 = load i32*, i32** %1
%20 = load i32, i32* %2
%21 = call i32 @exist(i32* %19, i32 %20, i32 %8)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = load i32*, i32** %1
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
store i32 %8, i32* %27
%28 = call i32 @increase(i32** %1, i32* %2)
br label %29
29: ; preds = %18, %23, %7
%30 = urem i32 %8, 5
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %43
32: ; preds = %29
%33 = load i32*, i32** %1
%34 = load i32, i32* %2
%35 = call i32 @exist(i32* %33, i32 %34, i32 %8)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %32
%38 = load i32*, i32** %1
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
store i32 %8, i32* %41
%42 = call i32 @increase(i32** %1, i32* %2)
br label %43
43: ; preds = %37, %32, %29
%44 = add nuw nsw i32 %8, 1
%45 = icmp eq i32 %44, 1000
br i1 %45, label %11, label %7
}