#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, ...);
void prime(int start, int end) {
  int i;
  int j;
  int counter = 0;
  printf("\nPrime number from %d to %d:-\n", start, end);
  for (i = start; i < end; i++) {
    for (j = 2; j < i; j++) {
      if ((i % j) == 0) {
        break;
      }
    }
    if (i == j) {
      printf("%d\t", i);
      counter++;
    }
  }
  printf("\nTotal prime numbers between %d and %d is %d", start, end, counter);
}


x86 assembly (clang, -O0):
<prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bf <prime+0xaf>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1186 <prime+0x76>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1173 <prime+0x63>
jmp    1186 <prime+0x76>
jmp    1178 <prime+0x68>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1152 <prime+0x42>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11ac <prime+0x9c>
mov    -0xc(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b1 <prime+0xa1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113f <prime+0x2f>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prime>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %edi,%r14d
lea    0xedc(%rip),%rdi
xor    %r12d,%r12d
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
cmp    %ebx,%r14d
jge    1198 <prime+0x88>
lea    0xee0(%rip),%r15
xor    %r12d,%r12d
mov    %r14d,%ebp
jmp    1157 <prime+0x47>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    %ebx,%ebp
je     1198 <prime+0x88>
mov    $0x2,%ecx
cmp    $0x3,%ebp
jl     1182 <prime+0x72>
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     1182 <prime+0x72>
add    $0x1,%ecx
cmp    %ecx,%ebp
jne    1170 <prime+0x60>
mov    %ebp,%ecx
cmp    %ecx,%ebp
jne    1150 <prime+0x40>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r12d
jmp    1150 <prime+0x40>
lea    0xe84(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
mov    %r12d,%ecx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"\0APrime number from %d to %d:-\0A\00"
@.str.1 = [4 x i8] c"%d\09\00"
@.str.2 = [45 x i8] c"\0ATotal prime numbers between %d and %d is %d\00"
define void @prime(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %7
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %3
store i32 %11, i32* %5
br label %12
12: ; preds = %41, %2
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %44
16: ; preds = %12
store i32 2, i32* %6
br label %17
17: ; preds = %28, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = srem i32 %22, %23
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21
br label %31
27: ; preds = %21
br label %28
28: ; preds = %27
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %17
31: ; preds = %26, %17
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32, i32* %5
%37 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %40
40: ; preds = %35, %31
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %12
44: ; preds = %12
%45 = load i32, i32* %3
%46 = load i32, i32* %4
%47 = load i32, i32* %7
%48 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %45, i32 %46, i32 %47)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"\0APrime number from %d to %d:-\0A\00"
@.str.1 = [4 x i8] c"%d\09\00"
@.str.2 = [45 x i8] c"\0ATotal prime numbers between %d and %d is %d\00"
define void @prime(i32 %0, i32 %1) {
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%4 = icmp slt i32 %0, %1
br i1 %4, label %5, label %26
5: ; preds = %2, %22
%6 = phi i32 [ %23, %22 ], [ 0, %2 ]
%7 = phi i32 [ %24, %22 ], [ %0, %2 ]
%8 = icmp sgt i32 %7, 2
br i1 %8, label %9, label %16
9: ; preds = %5, %13
%10 = phi i32 [ %14, %13 ], [ 2, %5 ]
%11 = srem i32 %7, %10
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = add nuw nsw i32 %10, 1
%15 = icmp eq i32 %14, %7
br i1 %15, label %16, label %9
16: ; preds = %13, %9, %5
%17 = phi i32 [ 2, %5 ], [ %10, %9 ], [ %7, %13 ]
%18 = icmp eq i32 %7, %17
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%21 = add nsw i32 %6, 1
br label %22
22: ; preds = %16, %19
%23 = phi i32 [ %21, %19 ], [ %6, %16 ]
%24 = add i32 %7, 1
%25 = icmp eq i32 %24, %1
br i1 %25, label %26, label %5
26: ; preds = %22, %2
%27 = phi i32 [ 0, %2 ], [ %23, %22 ]
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %1, i32 %27)
ret void
}