#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 atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ is_prime(long);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  long int bot, top, i, j;
  long int temp, count = 0;
  if (argc != 3) {
    printf("Exactly 2 arguments are expected\n");
    printf("o-prime from to\n");
    exit(0);
  }
  bot = atoi(argv[1]);
  top = atoi(argv[2]);
  if (bot > top) {
    temp = bot;
    bot = top;
    top = temp;
  }
  for (i = bot; i <= top; i++) {
    if (is_prime(i)) {
      count++;
      printf("%ld\t", i);
    }
  }
  printf("\nThere are  %ld primes int given range ", count);
  printf("\n=============== Obuntu by OSAC ===================\n");
  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)
movq   $0x0,-0x40(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     118b <main+0x4b>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jle    11d3 <main+0x93>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jg     1230 <main+0xf0>
mov    -0x28(%rbp),%rdi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     121a <main+0xda>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121f <main+0xdf>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11db <main+0x9b>
mov    -0x40(%rbp),%rsi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    11f4 <main+0xa4>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %rax,%rbx
mov    0x10(%r14),%rdi
call   1060 <atoi@plt>
cmp    %rax,%rbx
mov    %rax,%r12
cmovg  %rbx,%r12
cmovg  %rax,%rbx
add    $0x1,%r12
lea    0xe6e(%rip),%r15
xor    %r14d,%r14d
jmp    11a9 <main+0x59>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r12
je     11c9 <main+0x79>
mov    %rbx,%rdi
call   1050 <is_prime@plt>
test   %rax,%rax
je     11a0 <main+0x50>
add    $0x1,%r14
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <main+0x50>
lea    0xe35(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"Exactly 2 arguments are expected\0A\00"
@.str.1 = [17 x i8] c"o-prime from to\0A\00"
@.str.2 = [5 x i8] c"%ld\09\00"
@.str.3 = [40 x i8] c"\0AThere are %ld primes int given range \00"
@.str.4 = [53 x i8] c"\0A=============== Obuntu by OSAC ===================\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 i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %11
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @atoi(i8* %21)
store i64 %22, i64* %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i64 @atoi(i8* %25)
store i64 %26, i64* %7
%27 = load i64, i64* %6
%28 = load i64, i64* %7
%29 = icmp sgt i64 %27, %28
br i1 %29, label %30, label %34
30: ; preds = %18
%31 = load i64, i64* %6
store i64 %31, i64* %10
%32 = load i64, i64* %7
store i64 %32, i64* %6
%33 = load i64, i64* %10
store i64 %33, i64* %7
br label %34
34: ; preds = %30, %18
%35 = load i64, i64* %6
store i64 %35, i64* %8
br label %36
36: ; preds = %50, %34
%37 = load i64, i64* %8
%38 = load i64, i64* %7
%39 = icmp sle i64 %37, %38
br i1 %39, label %40, label %53
40: ; preds = %36
%41 = load i64, i64* %8
%42 = call i64 @is_prime(i64 %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i64, i64* %11
%46 = add nsw i64 %45, 1
store i64 %46, i64* %11
%47 = load i64, i64* %8
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %47)
br label %49
49: ; preds = %44, %40
br label %50
50: ; preds = %49
%51 = load i64, i64* %8
%52 = add nsw i64 %51, 1
store i64 %52, i64* %8
br label %36
53: ; preds = %36
%54 = load i64, i64* %11
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i64 %54)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [5 x i8] c"%ld\09\00"
@.str.3 = [40 x i8] c"\0AThere are %ld primes int given range \00"
@str = [52 x i8] c"\0A=============== Obuntu by OSAC ===================\00"
@str.5 = [33 x i8] c"Exactly 2 arguments are expected\00"
@str.6 = [16 x i8] c"o-prime from to\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.5, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i64 @atoi(i8* %13)
%15 = icmp sgt i64 %11, %14
%16 = select i1 %15, i64 %11, i64 %14
%17 = select i1 %15, i64 %14, i64 %11
br label %18
18: ; preds = %8, %26
%19 = phi i64 [ 0, %8 ], [ %27, %26 ]
%20 = phi i64 [ %17, %8 ], [ %28, %26 ]
%21 = tail call i64 @is_prime(i64 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = add nsw i64 %19, 1
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %20)
br label %26
26: ; preds = %18, %23
%27 = phi i64 [ %24, %23 ], [ %19, %18 ]
%28 = add i64 %20, 1
%29 = icmp eq i64 %20, %16
br i1 %29, label %30, label %18
30: ; preds = %26
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i64 %27)
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
ret i32 0
}