int MAIN() {
  int i, num1, num2;
  write("enter a range, for example, 5<ENTER> 23<ENTER>:");
  num1 = read();
  num2 = read();
  for (i = num1; i < num2; i = i + 1) {
    if (is_prime(i)) {
      write(i);
      write("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<MAIN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <write@plt>
mov    $0x0,%al
call   1040 <read@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <read@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11aa <MAIN+0x7a>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1050 <is_prime@plt>
cmp    $0x0,%eax
je     1197 <MAIN+0x67>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1030 <write@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <write@plt>
jmp    119c <MAIN+0x6c>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1160 <MAIN+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MAIN>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <write@plt>
xor    %eax,%eax
call   1040 <read@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <read@plt>
cmp    %eax,%ebx
jge    1199 <MAIN+0x69>
mov    %eax,%ebp
lea    0xed1(%rip),%r14
jmp    1177 <MAIN+0x47>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%ebp
je     1199 <MAIN+0x69>
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <is_prime@plt>
test   %eax,%eax
je     1170 <MAIN+0x40>
mov    %ebx,%edi
xor    %eax,%eax
call   1030 <write@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <write@plt>
jmp    1170 <MAIN+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"enter a range, for example, 5<ENTER> 23<ENTER>:\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @MAIN() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) bitcast (i32 (...)* @write to i32 (i8*, ...)*)(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @read()
store i32 %5, i32* %2
%6 = call i32 (...) @read()
store i32 %6, i32* %3
%7 = load i32, i32* %2
store i32 %7, i32* %1
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i32, i32* %1
%14 = call i32 (i32, ...) bitcast (i32 (...)* @is_prime to i32 (i32, ...)*)(i32 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* %1
%18 = call i32 (i32, ...) bitcast (i32 (...)* @write to i32 (i32, ...)*)(i32 %17)
%19 = call i32 (i8*, ...) bitcast (i32 (...)* @write to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %16, %12
br label %21
21: ; preds = %20
%22 = load i32, i32* %1
%23 = add nsw i32 %22, 1
store i32 %23, i32* %1
br label %8
24: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [48 x i8] c"enter a range, for example, 5<ENTER> 23<ENTER>:\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @MAIN() {
%1 = tail call i32 (i8*, ...) bitcast (i32 (...)* @write to i32 (i8*, ...)*)(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @read()
%3 = tail call i32 (...) @read()
%4 = icmp slt i32 %2, %3
br i1 %4, label %5, label %15
5: ; preds = %0, %12
%6 = phi i32 [ %13, %12 ], [ %2, %0 ]
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @is_prime to i32 (i32, ...)*)(i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @write to i32 (i32, ...)*)(i32 %6)
%11 = tail call i32 (i8*, ...) bitcast (i32 (...)* @write to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %5, %9
%13 = add i32 %6, 1
%14 = icmp eq i32 %13, %3
br i1 %14, label %15, label %5
15: ; preds = %12, %0
ret i32 0
}