#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 */
scalar_t__ multiple(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int vsota = 0;
  int meja;
  printf("Please insert upper bound:\n");
  scanf("%d", &meja);
  for (int i = 1; i < meja; i++) {
    if (multiple(i)) {
      vsota += i;
    }
  }
  printf("The sum of all the multiples of 3 and 5 below %d is:\n", meja);
  printf("%d\n", vsota);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a5 <main+0x75>
mov    -0x10(%rbp),%edi
call   1030 <multiple@plt>
cmp    $0x0,%rax
je     1192 <main+0x62>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1197 <main+0x67>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116b <main+0x3b>
mov    -0xc(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xef3(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaa(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
xor    %ebx,%ebx
cmp    $0x2,%esi
jl     11a2 <main+0x62>
xor    %ebx,%ebx
mov    $0x1,%ebp
jmp    118d <main+0x4d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %ecx,%ebx
add    $0x1,%ebp
mov    0x4(%rsp),%esi
cmp    %esi,%ebp
jge    11a2 <main+0x62>
mov    %ebp,%edi
call   1030 <multiple@plt>
mov    $0x0,%ecx
test   %rax,%rax
je     1180 <main+0x40>
mov    %ebp,%ecx
jmp    1180 <main+0x40>
lea    0xe5a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe82(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Please insert upper bound:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [54 x i8] c"The sum of all the multiples of 3 and 5 below %d is:\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 1, i32* %4
br label %7
7: ; preds = %20, %0
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i32, i32* %4
%13 = call i64 @multiple(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = add nsw i32 %17, %16
store i32 %18, i32* %2
br label %19
19: ; preds = %15, %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %7
23: ; preds = %7
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [54 x i8] c"The sum of all the multiples of 3 and 5 below %d is:\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [27 x i8] c"Please insert upper bound:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 1
br i1 %6, label %12, label %7
7: ; preds = %12, %0
%8 = phi i32 [ 0, %0 ], [ %18, %12 ]
%9 = phi i32 [ %5, %0 ], [ %20, %12 ]
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %8)
ret i32 0
12: ; preds = %0, %12
%13 = phi i32 [ %19, %12 ], [ 1, %0 ]
%14 = phi i32 [ %18, %12 ], [ 0, %0 ]
%15 = call i64 @multiple(i32 %13)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i32 0, i32 %13
%18 = add nuw nsw i32 %17, %14
%19 = add nuw nsw i32 %13, 1
%20 = load i32, i32* %1
%21 = icmp slt i32 %19, %20
br i1 %21, label %12, label %7
}