#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 atoi(char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int i;
  int a, b;
  if (argc > 2) {
    a = atoi(argv[1]);
    b = atoi(argv[2]);
  } else {
    a = 1;
    b = 10;
  }
  printf("sum from %d to %d = ", a, b);
  for (i = a; i < b;) {
    ++i;
    a = a + i;
  }
  printf("%d\n", a);
  printf("Press any key to continue . . .");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1175 <main+0x45>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    1183 <main+0x53>
movl   $0x1,-0x18(%rbp)
movl   $0xa,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c0 <main+0x90>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    119d <main+0x6d>
mov    -0x18(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jle    116d <main+0x3d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
lea    0xea6(%rip),%rdi
mov    %r14d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
cmp    %ebx,%r14d
jl     1190 <main+0x60>
jmp    11b7 <main+0x87>
lea    0xe8c(%rip),%rdi
mov    $0x1,%r14d
mov    $0xa,%ebx
mov    $0x1,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14d,%eax
not    %eax
add    %ebx,%eax
lea    0x2(%r14),%ecx
imul   %eax,%ecx
lea    (%rcx,%r14,2),%ecx
sub    %r14d,%ebx
add    $0xfffffffe,%ebx
imul   %rax,%rbx
shr    %rbx
lea    (%rbx,%rcx,1),%r14d
add    $0x1,%r14d
lea    0xe57(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"sum from %d to %d = \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [32 x i8] c"Press any key to continue . . .\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 2
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %7
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %8
br label %21
20: ; preds = %2
store i32 1, i32* %7
store i32 10, i32* %8
br label %21
21: ; preds = %20, %11
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23)
%25 = load i32, i32* %7
store i32 %25, i32* %6
br label %26
26: ; preds = %30, %21
%27 = load i32, i32* %6
%28 = load i32, i32* %8
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
%33 = load i32, i32* %7
%34 = load i32, i32* %6
%35 = add nsw i32 %33, %34
store i32 %35, i32* %7
br label %26
36: ; preds = %26
%37 = load i32, i32* %7
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"sum from %d to %d = \00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [32 x i8] c"Press any key to continue . . .\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 1, i32 10)
br label %15
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12)
%14 = icmp slt i32 %9, %12
br i1 %14, label %15, label %33
15: ; preds = %4, %6
%16 = phi i32 [ 10, %4 ], [ %12, %6 ]
%17 = phi i32 [ 1, %4 ], [ %9, %6 ]
%18 = xor i32 %17, -1
%19 = add i32 %16, %18
%20 = add i32 %17, 2
%21 = mul i32 %19, %20
%22 = shl i32 %17, 1
%23 = add i32 %21, %22
%24 = zext i32 %19 to i33
%25 = add i32 %16, -2
%26 = sub i32 %25, %17
%27 = zext i32 %26 to i33
%28 = mul i33 %24, %27
%29 = lshr i33 %28, 1
%30 = trunc i33 %29 to i32
%31 = add i32 %23, %30
%32 = add i32 %31, 1
br label %33
33: ; preds = %15, %6
%34 = phi i32 [ %9, %6 ], [ %32, %15 ]
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%37 = tail call i32 (...) @getchar()
ret i32 0
}