#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 *);
main() {
  int inicial, final, A, B;
  int i = 0;
  int soma = 0;
  printf("||==================================================================="
         "||\n");
  printf("|| Para iniciar o somatorio, primeiramente deve inserir um "
         "intervalo,||\n");
  printf("|| como, por exemplo o valor inicial e final para iniciar a "
         "contagem.||\n");
  printf("||==================================================================="
         "||\n\n");
  printf("Insira o valor inteiro inicial: ");
  scanf("%d", &inicial);
  printf("\nInsira o valor inteiro final: ");
  scanf("%d", &final);
  if (inicial < final) {
    A = inicial;
    B = final;
  } else {
    A = final;
    B = inicial;
  }
  printf("\n\n");
  for (i = A; i <= B; i++) {
    soma = soma + 2 * i;
    printf("2*(%d) ", i);
  }
  printf("\nSoma = %d\n\n", soma);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfa9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfbc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xfaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf9e(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ce <main+0xae>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11da <main+0xba>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0xf9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1227 <main+0x107>
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
lea    0xf57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ee <main+0xce>
mov    -0x1c(%rbp),%esi
lea    0xf40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xf16(%rip),%rdi
call   1030 <puts@plt>
lea    0xf52(%rip),%rdi
call   1030 <puts@plt>
lea    0xf8e(%rip),%rdi
call   1030 <puts@plt>
lea    0xfca(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea0(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%r15d
mov    0x8(%rsp),%eax
cmp    %eax,%r15d
mov    %eax,%ebx
cmovl  %r15d,%ebx
cmovl  %eax,%r15d
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r15d
lea    (%rbx,%rbx,1),%ebp
lea    0xe6b(%rip),%r14
xor    %r12d,%r12d
nopl   0x0(%rax)
add    %ebp,%r12d
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
add    $0x2,%ebp
cmp    %ebx,%r15d
jne    11e0 <main+0xb0>
lea    0xe4b(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [73 x i8] c"||===================================================================||\0A\00"
@.str.1 = [73 x i8] c"|| Para iniciar o somatorio, primeiramente deve inserir um intervalo,||\0A\00"
@.str.2 = [73 x i8] c"|| como, por exemplo o valor inicial e final para iniciar a contagem.||\0A\00"
@.str.3 = [74 x i8] c"||===================================================================||\0A\0A\00"
@.str.4 = [33 x i8] c"Insira o valor inteiro inicial: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [32 x i8] c"\0AInsira o valor inteiro final: \00"
@.str.7 = [3 x i8] c"\0A\0A\00"
@.str.8 = [8 x i8] c"2*(%d) \00"
@.str.9 = [13 x i8] c"\0ASoma = %d\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = load i32, i32* %2
store i32 %20, i32* %4
%21 = load i32, i32* %3
store i32 %21, i32* %5
br label %25
22: ; preds = %0
%23 = load i32, i32* %3
store i32 %23, i32* %4
%24 = load i32, i32* %2
store i32 %24, i32* %5
br label %25
25: ; preds = %22, %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%27 = load i32, i32* %4
store i32 %27, i32* %6
br label %28
28: ; preds = %39, %25
%29 = load i32, i32* %6
%30 = load i32, i32* %5
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i32, i32* %7
%34 = load i32, i32* %6
%35 = mul nsw i32 2, %34
%36 = add nsw i32 %33, %35
store i32 %36, i32* %7
%37 = load i32, i32* %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %28
42: ; preds = %28
%43 = load i32, i32* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@.str.4 = [33 x i8] c"Insira o valor inteiro inicial: \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [32 x i8] c"\0AInsira o valor inteiro final: \00"
@.str.8 = [8 x i8] c"2*(%d) \00"
@.str.9 = [13 x i8] c"\0ASoma = %d\0A\0A\00"
@str = [72 x i8] c"||===================================================================||\00"
@str.10 = [72 x i8] c"|| Para iniciar o somatorio, primeiramente deve inserir um intervalo,||\00"
@str.11 = [72 x i8] c"|| como, por exemplo o valor inicial e final para iniciar a contagem.||\00"
@str.12 = [73 x i8] c"||===================================================================||\0A\00"
@str.13 = [2 x i8] c"\0A\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 ([72 x i8], [72 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str.11, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.12, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
%16 = select i1 %15, i32 %13, i32 %14
%17 = select i1 %15, i32 %14, i32 %13
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.13, i64 0, i64 0))
br label %19
19: ; preds = %0, %19
%20 = phi i32 [ 0, %0 ], [ %23, %19 ]
%21 = phi i32 [ %16, %0 ], [ %25, %19 ]
%22 = shl nsw i32 %21, 1
%23 = add nsw i32 %20, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %21)
%25 = add i32 %21, 1
%26 = icmp eq i32 %21, %17
br i1 %26, label %27, label %19
27: ; preds = %19
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i32 %23)
ret i32 0
}