#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)) {
          printf("Multiply %d: %d\n", mult, i);
          lista[lenght] = i;
          increase(&lista, &lenght);
        }
      }
    }
  }
  int sum = sumlista(lista, lenght);
  printf("Sum: %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    124f <main+0xef>
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmpl   $0x0,-0x20(%rbp,%rax,4)
je     123c <main+0xdc>
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    1229 <main+0xc9>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1040 <exist@plt>
cmp    $0x0,%eax
jne    1224 <main+0xc4>
mov    -0x2c(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
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    1229 <main+0xc9>
jmp    122e <main+0xce>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b3 <main+0x53>
jmp    1241 <main+0xe1>
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    0xdb5(%rip),%rdi
mov    $0x0,%al
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)
mov    $0xcccccccd,%r13d
mov    $0xaaaaaaab,%ebx
lea    0xc(%rsp),%r12
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    11b3 <main+0x53>
nopl   0x0(%rax)
add    $0x1,%ebp
add    $0xffffffff,%r14d
cmp    $0x3e8,%ebp
je     1275 <main+0x115>
mov    %ebp,%eax
mov    %rax,%rcx
imul   %r13,%rcx
shr    $0x22,%rcx
lea    (%rcx,%rcx,4),%r15d
add    %r14d,%r15d
imul   %rbx,%rax
shr    $0x21,%rax
lea    (%rax,%rax,2),%eax
add    %r14d,%eax
jne    11eb <main+0x8b>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
mov    %ebp,%edx
call   1040 <exist@plt>
test   %eax,%eax
je     1238 <main+0xd8>
test   %r15d,%r15d
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>
lea    0xdf5(%rip),%rdi
mov    $0x5,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%rax
movslq 0xc(%rsp),%rcx
mov    %ebp,(%rax,%rcx,4)
lea    0x10(%rsp),%rdi
mov    %r12,%rsi
call   1080 <increase@plt>
jmp    11a0 <main+0x40>
lea    0xdc1(%rip),%rdi
mov    $0x3,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%rax
movslq 0xc(%rsp),%rcx
mov    %ebp,(%rax,%rcx,4)
lea    0x10(%rsp),%rdi
mov    %r12,%rsi
call   1080 <increase@plt>
test   %r15d,%r15d
jne    11a0 <main+0x40>
jmp    11f0 <main+0x90>
mov    0x10(%rsp),%rdi
mov    0xc(%rsp),%esi
call   1060 <sumlista@plt>
lea    0xd87(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
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 = [17 x i8] c"Multiply %d: %d\0A\00"
@.str.1 = [9 x i8] c"Sum: %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 = %53, %0
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 1000
br i1 %14, label %15, label %56
15: ; preds = %12
store i32 0, i32* %6
br label %16
16: ; preds = %49, %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 %52
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 %48
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 %47, label %37
37: ; preds = %31
%38 = load i32, i32* %7
%39 = load i32, i32* %5
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %38, i32 %39)
%41 = load i32, i32* %5
%42 = load i32*, i32** %2
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
store i32 %41, i32* %45
%46 = call i32 @increase(i32** %2, i32* %3)
br label %47
47: ; preds = %37, %31
br label %48
48: ; preds = %47, %22
br label %49
49: ; preds = %48
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %16
52: ; preds = %16
br label %53
53: ; preds = %52
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 1
store i32 %55, i32* %5
br label %12
56: ; preds = %12
%57 = load i32*, i32** %2
%58 = load i32, i32* %3
%59 = call i32 @sumlista(i32* %57, i32 %58)
store i32 %59, i32* %8
%60 = load i32, i32* %8
%61 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %60)
%62 = load i32*, i32** %2
%63 = call i32 @free(i32* %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Multiply %d: %d\0A\00"
@.str.1 = [9 x i8] c"Sum: %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, %45
%8 = phi i32 [ 0, %0 ], [ %46, %45 ]
%9 = urem i32 %8, 3
%10 = icmp eq i32 %9, 0
br i1 %10, label %18, label %30
11: ; preds = %45
%12 = load i32*, i32** %1
%13 = load i32, i32* %2
%14 = call i32 @sumlista(i32* %12, i32 %13)
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, 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 %30
23: ; preds = %18
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 3, i32 %8)
%25 = load i32*, i32** %1
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
store i32 %8, i32* %28
%29 = call i32 @increase(i32** %1, i32* %2)
br label %30
30: ; preds = %18, %23, %7
%31 = urem i32 %8, 5
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %45
33: ; preds = %30
%34 = load i32*, i32** %1
%35 = load i32, i32* %2
%36 = call i32 @exist(i32* %34, i32 %35, i32 %8)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %33
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 5, i32 %8)
%40 = load i32*, i32** %1
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
store i32 %8, i32* %43
%44 = call i32 @increase(i32** %1, i32* %2)
br label %45
45: ; preds = %38, %33, %30
%46 = add nuw nsw i32 %8, 1
%47 = icmp eq i32 %46, 1000
br i1 %47, label %11, label %7
}