#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 is_divisible_by_3(int);
int is_divisible_by_5(int);
int sum_of_numbers_below(int number) {
  int i = 0;
  int sum = 0;
  for (i = 0; i < number; i++) {
    bool isDivisibleBy5 = is_divisible_by_5(i);
    bool isDivisibleBy3 = is_divisible_by_3(i);
    if (isDivisibleBy5) {
      sum += i;
    } else if (isDivisibleBy3) {
      sum += i;
    }
  }
  return sum;
}


x86 assembly (clang, -O0):
<sum_of_numbers_below>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a5 <sum_of_numbers_below+0x85>
mov    -0x8(%rbp),%edi
call   1030 <is_divisible_by_5@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <is_divisible_by_3@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     117a <sum_of_numbers_below+0x5a>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <sum_of_numbers_below+0x72>
cmpl   $0x0,-0x14(%rbp)
je     118d <sum_of_numbers_below+0x6d>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <sum_of_numbers_below+0x72>
jmp    1197 <sum_of_numbers_below+0x77>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1140 <sum_of_numbers_below+0x20>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum_of_numbers_below>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1169 <sum_of_numbers_below+0x49>
mov    %edi,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    114a <sum_of_numbers_below+0x2a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %eax,%ebp
add    $0x1,%ebx
cmp    %ebx,%r14d
je     116b <sum_of_numbers_below+0x4b>
mov    %ebx,%edi
call   1030 <is_divisible_by_5@plt>
mov    %eax,%r15d
mov    %ebx,%edi
call   1040 <is_divisible_by_3@plt>
or     %r15d,%eax
mov    $0x0,%eax
je     1140 <sum_of_numbers_below+0x20>
mov    %ebx,%eax
jmp    1140 <sum_of_numbers_below+0x20>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sum_of_numbers_below(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %3
br label %7
7: ; preds = %31, %1
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %34
11: ; preds = %7
%12 = load i32, i32* %3
%13 = call i32 @is_divisible_by_5(i32 %12)
store i32 %13, i32* %5
%14 = load i32, i32* %3
%15 = call i32 @is_divisible_by_3(i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %5
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = add nsw i32 %20, %19
store i32 %21, i32* %4
br label %30
22: ; preds = %11
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = add nsw i32 %27, %26
store i32 %28, i32* %4
br label %29
29: ; preds = %25, %22
br label %30
30: ; preds = %29, %18
br label %31
31: ; preds = %30
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %7
34: ; preds = %7
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
define i32 @sum_of_numbers_below(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %15
3: ; preds = %1, %3
%4 = phi i32 [ %13, %3 ], [ 0, %1 ]
%5 = phi i32 [ %12, %3 ], [ 0, %1 ]
%6 = tail call i32 @is_divisible_by_5(i32 %4)
%7 = tail call i32 @is_divisible_by_3(i32 %4)
%8 = icmp eq i32 %6, 0
%9 = icmp eq i32 %7, 0
%10 = select i1 %8, i1 %9, i1 false
%11 = select i1 %10, i32 0, i32 %4
%12 = add nuw nsw i32 %11, %5
%13 = add nuw nsw i32 %4, 1
%14 = icmp eq i32 %13, %0
br i1 %14, label %15, label %3
15: ; preds = %3, %1
%16 = phi i32 [ 0, %1 ], [ %12, %3 ]
ret i32 %16
}