#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int vrniStevilo(int);
int main() {
  int vsota = 0;
  int i, steviloCrk;
  int spodnjaMeja, zgornjaMeja;
  printf("Please insert lower and upper bound(min 1 / max 1000):\n");
  printf("Lower bound:\n");
  scanf("%d", &spodnjaMeja);
  printf("Upper bound:\n");
  scanf("%d", &zgornjaMeja);
  for (i = spodnjaMeja; i <= zgornjaMeja; i++) {
    steviloCrk = vrniStevilo(i);
    vsota += steviloCrk;
  }
  printf("Number of letters used to write all the numbers between %d and %d in "
         "words: %d\n",
         spodnjaMeja, zgornjaMeja, vsota);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xedd(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11c4 <main+0x94>
mov    -0xc(%rbp),%edi
call   1030 <vrniStevilo@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x66>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xf09(%rip),%rdi
call   1040 <puts@plt>
lea    0xf34(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9e(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xf21(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    0x4(%rsp),%ebx
mov    (%rsp),%edx
xor    %ebp,%ebp
cmp    %edx,%ebx
jg     11b9 <main+0x79>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
call   1030 <vrniStevilo@plt>
add    %eax,%ebp
lea    0x1(%rbx),%eax
mov    (%rsp),%edx
cmp    %edx,%ebx
mov    %eax,%ebx
jl     11a0 <main+0x60>
mov    0x4(%rsp),%ebx
lea    0xe43(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"Please insert lower and upper bound(min 1 / max 1000):\0A\00"
@.str.1 = [14 x i8] c"Lower bound:\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"Upper bound:\0A\00"
@.str.4 = [80 x i8] c"Number of letters used to write all the numbers between %d and %d in words: %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 0, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%12 = load i32, i32* %5
store i32 %12, i32* %3
br label %13
13: ; preds = %23, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %6
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32, i32* %3
%19 = call i32 @vrniStevilo(i32 %18)
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = load i32, i32* %2
%22 = add nsw i32 %21, %20
store i32 %22, i32* %2
br label %23
23: ; preds = %17
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %13
26: ; preds = %13
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = load i32, i32* %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.4, i64 0, i64 0), i32 %27, i32 %28, i32 %29)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [80 x i8] c"Number of letters used to write all the numbers between %d and %d in words: %d\0A\00"
@str = [55 x i8] c"Please insert lower and upper bound(min 1 / max 1000):\00"
@str.5 = [13 x i8] c"Lower bound:\00"
@str.6 = [13 x i8] c"Upper bound:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.6, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = icmp sgt i32 %10, %11
br i1 %12, label %23, label %13
13: ; preds = %0, %13
%14 = phi i32 [ %17, %13 ], [ 0, %0 ]
%15 = phi i32 [ %18, %13 ], [ %10, %0 ]
%16 = call i32 @vrniStevilo(i32 %15)
%17 = add nsw i32 %16, %14
%18 = add nsw i32 %15, 1
%19 = load i32, i32* %2
%20 = icmp slt i32 %15, %19
br i1 %20, label %13, label %21
21: ; preds = %13
%22 = load i32, i32* %1
br label %23
23: ; preds = %21, %0
%24 = phi i32 [ %10, %0 ], [ %22, %21 ]
%25 = phi i32 [ 0, %0 ], [ %17, %21 ]
%26 = phi i32 [ %11, %0 ], [ %19, %21 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @.str.4, i64 0, i64 0), i32 %24, i32 %26, i32 %25)
ret i32 0
}