#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 */
long getTotient(int);
int /*<<< orphan*/ printf(char *, long, long, long);
int /*<<< orphan*/ sscanf(char *, char *, long *);
int main(int argc, char **argv) {
  long lower, upper;
  sscanf(argv[1], "%ld", &lower);
  sscanf(argv[2], "%ld", &upper);
  int i;
  long result = 0.0;
  if (lower == 1) {
    result = 1.0;
    lower = 2;
  }
#pragma omp parallel for default(shared) private(i) schedule(auto) reduction(+:result) num_threads(5)
  for (i = lower; i <= upper; i++) {
    result = result + getTotient(i);
  }
  printf("Sum of Totients between [%ld..%ld] is %ld \n", lower, upper, result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeab(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe93(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1050 <sscanf@plt>
movq   $0x0,-0x30(%rbp)
cmpq   $0x1,-0x18(%rbp)
jne    1199 <main+0x69>
movq   $0x1,-0x30(%rbp)
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x20(%rbp),%rax
jg     11da <main+0xaa>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <getTotient@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a0 <main+0x70>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xebb(%rip),%r14
lea    0x8(%rsp),%rdx
mov    %r14,%rsi
call   1050 <sscanf@plt>
mov    0x10(%rbx),%rdi
lea    0x10(%rsp),%rdx
mov    %r14,%rsi
call   1050 <sscanf@plt>
mov    0x8(%rsp),%rsi
cmp    $0x1,%rsi
jne    1184 <main+0x54>
movq   $0x2,0x8(%rsp)
mov    $0x1,%r14d
mov    $0x2,%esi
jmp    1187 <main+0x57>
xor    %r14d,%r14d
movslq %esi,%rax
mov    0x10(%rsp),%rdx
cmp    %rax,%rdx
jl     11bd <main+0x8d>
movslq %esi,%rbx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1040 <getTotient@plt>
add    %rax,%r14
add    $0x1,%rbx
mov    0x10(%rsp),%rdx
cmp    %rbx,%rdx
jge    11a0 <main+0x70>
mov    0x8(%rsp),%rsi
lea    0xe40(%rip),%rdi
mov    %r14,%rcx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [44 x i8] c"Sum of Totients between [%ld..%ld] is %ld \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %6)
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %7)
store i64 0, i64* %9
%18 = load i64, i64* %6
%19 = icmp eq i64 %18, 1
br i1 %19, label %20, label %21
20: ; preds = %2
store i64 1, i64* %9
store i64 2, i64* %6
br label %21
21: ; preds = %20, %2
%22 = load i64, i64* %6
%23 = trunc i64 %22 to i32
store i32 %23, i32* %8
br label %24
24: ; preds = %34, %21
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = load i64, i64* %7
%28 = icmp sle i64 %26, %27
br i1 %28, label %29, label %37
29: ; preds = %24
%30 = load i64, i64* %9
%31 = load i32, i32* %8
%32 = call i64 @getTotient(i32 %31)
%33 = add nsw i64 %30, %32
store i64 %33, i64* %9
br label %34
34: ; preds = %29
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %24
37: ; preds = %24
%38 = load i64, i64* %6
%39 = load i64, i64* %7
%40 = load i64, i64* %9
%41 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i64 %38, i64 %39, i64 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [44 x i8] c"Sum of Totients between [%ld..%ld] is %ld \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = alloca i64
%5 = bitcast i64* %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %4)
%13 = load i64, i64* %3
%14 = icmp eq i64 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %2
store i64 2, i64* %3
br label %16
16: ; preds = %15, %2
%17 = phi i64 [ 2, %15 ], [ %13, %2 ]
%18 = phi i64 [ 1, %15 ], [ 0, %2 ]
%19 = shl i64 %17, 32
%20 = ashr exact i64 %19, 32
%21 = load i64, i64* %4
%22 = icmp slt i64 %21, %20
br i1 %22, label %37, label %23
23: ; preds = %16
%24 = shl i64 %17, 32
%25 = ashr exact i64 %24, 32
br label %26
26: ; preds = %23, %26
%27 = phi i64 [ %25, %23 ], [ %32, %26 ]
%28 = phi i64 [ %18, %23 ], [ %31, %26 ]
%29 = trunc i64 %27 to i32
%30 = call i64 @getTotient(i32 %29)
%31 = add nsw i64 %30, %28
%32 = add i64 %27, 1
%33 = load i64, i64* %4
%34 = icmp slt i64 %33, %32
br i1 %34, label %35, label %26
35: ; preds = %26
%36 = load i64, i64* %3
br label %37
37: ; preds = %35, %16
%38 = phi i64 [ %17, %16 ], [ %36, %35 ]
%39 = phi i64 [ %18, %16 ], [ %31, %35 ]
%40 = phi i64 [ %21, %16 ], [ %33, %35 ]
%41 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i64 %38, i64 %40, i64 %39)
ret i32 0
}