#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 */
scalar_t__ isprime(int);
int /*<<< orphan*/ printf(char *, ...);
int strtol(char *, int /*<<< orphan*/ *, int);
int main(int ac, char *av[]) {
  int n, min_n, max_n;
  if (ac < 3) {
    printf("prime1 min_n max_n\n");
    return (1);
  }
  min_n = strtol(av[1], NULL, 10);
  max_n = strtol(av[2], NULL, 10);
  for (n = min_n; n <= max_n; n++) {
    if (isprime(n))
      printf("%d\n", n);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    116a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11eb <main+0xbb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11e4 <main+0xb4>
mov    -0x14(%rbp),%edi
call   1040 <isprime@plt>
cmp    $0x0,%rax
je     11d1 <main+0xa1>
mov    -0x14(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d6 <main+0xa6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a2 <main+0x72>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%edi
jg     115d <main+0x1d>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
jmp    11c4 <main+0x84>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
cmp    %eax,%ebx
jg     11c4 <main+0x84>
mov    %eax,%ebp
add    $0x1,%ebp
lea    0xe6b(%rip),%r14
jmp    11a7 <main+0x67>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %ebx,%ebp
je     11c1 <main+0x81>
mov    %ebx,%edi
call   1050 <isprime@plt>
test   %rax,%rax
je     11a0 <main+0x60>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <main+0x60>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"prime1 min_n max_n\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %39
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strtol(i8* %16, i32* null, i32 10)
store i32 %17, i32* %7
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @strtol(i8* %20, i32* null, i32 10)
store i32 %21, i32* %8
%22 = load i32, i32* %7
store i32 %22, i32* %6
br label %23
23: ; preds = %35, %13
%24 = load i32, i32* %6
%25 = load i32, i32* %8
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %38
27: ; preds = %23
%28 = load i32, i32* %6
%29 = call i64 @isprime(i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* %6
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %27
br label %35
35: ; preds = %34
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %23
38: ; preds = %23
store i32 0, i32* %3
br label %39
39: ; preds = %38, %11
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [19 x i8] c"prime1 min_n max_n\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %23
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strtol(i8* nocapture %8, i32* null, i32 10)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @strtol(i8* nocapture %11, i32* null, i32 10)
%13 = icmp sgt i32 %9, %12
br i1 %13, label %23, label %14
14: ; preds = %6, %20
%15 = phi i32 [ %21, %20 ], [ %9, %6 ]
%16 = tail call i64 @isprime(i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %20
20: ; preds = %14, %18
%21 = add i32 %15, 1
%22 = icmp eq i32 %15, %12
br i1 %22, label %23, label %14
23: ; preds = %20, %6, %4
%24 = phi i32 [ 1, %4 ], [ 0, %6 ], [ 0, %20 ]
ret i32 %24
}