#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__ isEven(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int firstNumber = 1;
  int secondNumber = 2;
  int meja;
  int vsota = 2;
  printf("Please insert upper bound:\n");
  scanf("%d", &meja);
  while (secondNumber <= meja) {
    int nextNumber = firstNumber + secondNumber;
    if (isEven(nextNumber)) {
      vsota += nextNumber;
    }
    firstNumber = secondNumber;
    secondNumber = nextNumber;
  }
  printf(
      "The sum of the even-valued terms whose values does not exceed %d is:\n",
      meja);
  printf("%d\n", vsota);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x2,-0x14(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11b3 <main+0x83>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <isEven@plt>
cmp    $0x0,%rax
je     11a2 <main+0x72>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <main+0x42>
mov    -0x10(%rbp),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
mov    $0x2,%r15d
cmp    $0x2,%esi
jl     11b3 <main+0x73>
mov    $0x2,%r15d
mov    $0x1,%eax
xor    %r14d,%r14d
mov    $0x2,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%ebp
add    %ebx,%ebp
mov    %ebp,%edi
call   1060 <isEven@plt>
test   %rax,%rax
mov    %ebp,%eax
cmove  %r14d,%eax
add    %eax,%r15d
mov    0x4(%rsp),%esi
mov    %ebx,%eax
mov    %ebp,%ebx
cmp    %esi,%ebp
jle    1190 <main+0x50>
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe81(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
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 = [70 x i8] c"The sum of the even-valued terms whose values does not exceed %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
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 2, i32* %3
store i32 2, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %9
9: ; preds = %24, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = add nsw i32 %14, %15
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = call i64 @isEven(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %13
%21 = load i32, i32* %6
%22 = load i32, i32* %5
%23 = add nsw i32 %22, %21
store i32 %23, i32* %5
br label %24
24: ; preds = %20, %13
%25 = load i32, i32* %3
store i32 %25, i32* %2
%26 = load i32, i32* %6
store i32 %26, i32* %3
br label %9
27: ; preds = %9
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [70 x i8] c"The sum of the even-valued terms whose values does not exceed %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 slt i32 %5, 2
br i1 %6, label %18, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %10, %7 ], [ 1, %0 ]
%9 = phi i32 [ %15, %7 ], [ 2, %0 ]
%10 = phi i32 [ %11, %7 ], [ 2, %0 ]
%11 = add nsw i32 %8, %10
%12 = call i64 @isEven(i32 %11)
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i32 0, i32 %11
%15 = add nsw i32 %14, %9
%16 = load i32, i32* %1
%17 = icmp sgt i32 %11, %16
br i1 %17, label %18, label %7
18: ; preds = %7, %0
%19 = phi i32 [ 2, %0 ], [ %15, %7 ]
%20 = phi i32 [ %5, %0 ], [ %16, %7 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %19)
ret i32 0
}