#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 i, j, a, b;
  int count;
  printf("Start?: ");
  scanf("%d", &a);
  printf("End?: ");
  scanf("%d", &b);
  for (i = a; i < b; i++) {
    for (j = 2; j < i; j++) {
      if (i % j == 0)
        break;
    }
    if (i == j) {
      count++;
      printf("\n%d", j);
    }
  }
  printf("\n");
  printf("Total: %i prime numbers\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f1 <main+0xd1>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b8 <main+0x98>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11a5 <main+0x85>
jmp    11b8 <main+0x98>
jmp    11aa <main+0x8a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1184 <main+0x64>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11de <main+0xbe>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <main+0xc3>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1171 <main+0x51>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe0b(%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    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%ecx
cmp    %ecx,%ebp
jge    11db <main+0xab>
lea    0xe88(%rip),%r14
jmp    1197 <main+0x67>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    %ecx,%ebp
jge    11db <main+0xab>
mov    $0x2,%esi
cmp    $0x3,%ebp
jl     11c2 <main+0x92>
mov    $0x2,%esi
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%eax
cltd
idiv   %esi
test   %edx,%edx
je     11c2 <main+0x92>
add    $0x1,%esi
cmp    %esi,%ebp
jne    11b0 <main+0x80>
mov    %ebp,%esi
cmp    %esi,%ebp
jne    1190 <main+0x60>
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%ecx
jmp    1190 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe28(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Start?: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"End?: \00"
@.str.3 = [4 x i8] c"\0A%d\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [25 x i8] c"Total: %i prime numbers\0A\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 ([9 x i8], [9 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* %4)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 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* %5)
%11 = load i32, i32* %4
store i32 %11, i32* %2
br label %12
12: ; preds = %41, %0
%13 = load i32, i32* %2
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %44
16: ; preds = %12
store i32 2, i32* %3
br label %17
17: ; preds = %28, %16
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%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* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %17
31: ; preds = %26, %17
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
%38 = load i32, i32* %3
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %35, %31
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %12
44: ; preds = %12
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* %6
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"Start?: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"End?: \00"
@.str.3 = [4 x i8] c"\0A%d\00"
@.str.5 = [25 x i8] c"Total: %i prime numbers\0A\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 ([9 x i8], [9 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 ([7 x i8], [7 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 slt i32 %9, %10
br i1 %11, label %12, label %36
12: ; preds = %0, %31
%13 = phi i32 [ %32, %31 ], [ %10, %0 ]
%14 = phi i32 [ %33, %31 ], [ undef, %0 ]
%15 = phi i32 [ %34, %31 ], [ %9, %0 ]
%16 = icmp sgt i32 %15, 2
br i1 %16, label %17, label %24
17: ; preds = %12, %21
%18 = phi i32 [ %22, %21 ], [ 2, %12 ]
%19 = srem i32 %15, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = add nuw nsw i32 %18, 1
%23 = icmp eq i32 %22, %15
br i1 %23, label %24, label %17
24: ; preds = %21, %17, %12
%25 = phi i32 [ 2, %12 ], [ %18, %17 ], [ %15, %21 ]
%26 = icmp eq i32 %15, %25
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = add nsw i32 %14, 1
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%30 = load i32, i32* %2
br label %31
31: ; preds = %24, %27
%32 = phi i32 [ %30, %27 ], [ %13, %24 ]
%33 = phi i32 [ %28, %27 ], [ %14, %24 ]
%34 = add nsw i32 %15, 1
%35 = icmp slt i32 %34, %32
br i1 %35, label %12, label %36
36: ; preds = %31, %0
%37 = phi i32 [ undef, %0 ], [ %33, %31 ]
%38 = call i32 @putchar(i32 10)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %37)
ret i32 0
}