#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 main() {
  int m, n, sum, i, count;
  int prime(int i);
  printf("Input m: ");
  scanf("%d", &m);
  printf("Input n: ");
  scanf("%d", &n);
  sum = count = 0;
  for (i = m; i <= n; i++) {
    if (prime(i) == 1) {
      sum = sum + i;
      count++;
    }
  }
  printf("count=%d, sum=%d", count, sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11d1 <main+0xa1>
mov    -0x14(%rbp),%edi
call   1050 <prime@plt>
cmp    $0x1,%eax
jne    11be <main+0x8e>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c3 <main+0x93>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <main+0x5f>
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed2(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ebx
mov    $0x0,%ebp
cmp    0x8(%rsp),%ebx
jg     11b7 <main+0x87>
xor    %ebp,%ebp
xor    %r14d,%r14d
nopl   0x0(%rax)
mov    %ebx,%edi
call   1050 <prime@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
mov    $0x0,%eax
cmove  %ebx,%eax
add    %eax,%r14d
add    %ecx,%ebp
lea    0x1(%rbx),%eax
cmp    0x8(%rsp),%ebx
mov    %eax,%ebx
jl     1190 <main+0x60>
lea    0xe56(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Input m: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"Input n: \00"
@.str.3 = [17 x i8] c"count=%d, sum=%d\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
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 0, i32* %6
store i32 0, i32* %4
%11 = load i32, i32* %2
store i32 %11, i32* %5
br label %12
12: ; preds = %27, %0
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load i32, i32* %5
%18 = call i32 @prime(i32 %17)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = add nsw i32 %21, %22
store i32 %23, i32* %4
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %26
26: ; preds = %20, %16
br label %27
27: ; preds = %26
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %12
30: ; preds = %12
%31 = load i32, i32* %6
%32 = load i32, i32* %4
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"Input m: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"Input n: \00"
@.str.3 = [17 x i8] c"count=%d, sum=%d\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp sgt i32 %9, %10
br i1 %11, label %25, label %12
12: ; preds = %0, %12
%13 = phi i32 [ %21, %12 ], [ 0, %0 ]
%14 = phi i32 [ %22, %12 ], [ %9, %0 ]
%15 = phi i32 [ %19, %12 ], [ 0, %0 ]
%16 = call i32 @prime(i32 %14)
%17 = icmp eq i32 %16, 1
%18 = select i1 %17, i32 %14, i32 0
%19 = add nsw i32 %18, %15
%20 = zext i1 %17 to i32
%21 = add nuw nsw i32 %13, %20
%22 = add nsw i32 %14, 1
%23 = load i32, i32* %2
%24 = icmp slt i32 %14, %23
br i1 %24, label %12, label %25
25: ; preds = %12, %0
%26 = phi i32 [ 0, %0 ], [ %19, %12 ]
%27 = phi i32 [ 0, %0 ], [ %21, %12 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %26)
ret i32 0
}