#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*/ printf(char *, int);
int totalForRange(int, int);
int main(int argc, char **argv) {
  int total;
  if (argc == 3) {
    total = totalForRange(atoi(argv[1]), atoi(argv[2]));
  } else {
    total = totalForRange(1, 999);
  }
  total += 11;
  printf("letters used: %d\n", total);
}


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   $0x3,-0x8(%rbp)
jne    117f <main+0x4f>
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    -0x18(%rbp),%edi
mov    %eax,%esi
call   1040 <totalForRange@plt>
mov    %eax,-0x14(%rbp)
jmp    1191 <main+0x61>
mov    $0x1,%edi
mov    $0x3e7,%esi
call   1040 <totalForRange@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xb,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    1155 <main+0x25>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %ebp,%edi
mov    %eax,%esi
jmp    115f <main+0x2f>
mov    $0x1,%edi
mov    $0x3e7,%esi
call   1040 <totalForRange@plt>
add    $0xb,%eax
lea    0xe92(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"letters used: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 3
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
%18 = call i32 @totalForRange(i32 %13, i32 %17)
store i32 %18, i32* %6
br label %21
19: ; preds = %2
%20 = call i32 @totalForRange(i32 1, i32 999)
store i32 %20, i32* %6
br label %21
21: ; preds = %19, %9
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 11
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [18 x i8] c"letters used: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32 @totalForRange(i32 %7, i32 %10)
br label %14
12: ; preds = %2
%13 = tail call i32 @totalForRange(i32 1, i32 999)
br label %14
14: ; preds = %12, %4
%15 = phi i32 [ %11, %4 ], [ %13, %12 ]
%16 = add nsw i32 %15, 11
%17 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %16)
ret i32 0
}