#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__ is_prime(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int i, a, b, tmp;
  printf("입력받은 수 사이에 있는 소수의 개수를 출력합니다.\n");
  printf("수를 반복해서 입력하시면 그 수가 소수인지를 판별해 드립니다.\n\n");
  while (1) {
    int prime_count = 0;
    printf("첫번째 수를 입력하세요.");
    scanf(" %d", &a);
    printf("두번째 수를 입력하세요.");
    scanf(" %d", &b);
    if (a == b) {
      if (is_prime(a))
        printf("%d는 소수입니다.\n\n", a);
      else
        printf("%d는 소수가 아닙니다.\n\n", a);
      continue;
    } else if (b < a) {
      tmp = a;
      a = b;
      b = tmp;
    }
    for (i = a; i <= b; i++)
      if (is_prime(i))
        prime_count++;
    printf("%d에서 %d사이에 있는 소수는 총 %d개 입니다.\n\n", a, b,
           prime_count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
lea    0xf38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xf40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf2e(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11e8 <main+0xb8>
mov    -0xc(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     11d2 <main+0xa2>
mov    -0xc(%rbp),%esi
lea    0xf23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <main+0xb3>
mov    -0xc(%rbp),%esi
lea    0xf26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115b <main+0x2b>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1206 <main+0xd6>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    120b <main+0xdb>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     124b <main+0x11b>
mov    -0x8(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     1238 <main+0x108>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    123d <main+0x10d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1211 <main+0xe1>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115b <main+0x2b>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf6c(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe96(%rip),%r14
lea    0xeb1(%rip),%r15
mov    %rsp,%rbx
lea    0xeab(%rip),%r12
lea    0x4(%rsp),%r13
jmp    11b0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp),%ebp
lea    0xee7(%rip),%rdi
mov    %ebp,%esi
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe53(%rip),%r14
mov    %rsp,%rbx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%edi
mov    0x4(%rsp),%ebp
cmp    %ebp,%edi
jne    1200 <main+0xc0>
call   1050 <is_prime@plt>
mov    (%rsp),%esi
test   %rax,%rax
je     1251 <main+0x111>
lea    0xe4f(%rip),%rdi
jmp    1258 <main+0x118>
nopl   0x0(%rax,%rax,1)
jle    1210 <main+0xd0>
mov    %ebp,(%rsp)
mov    %edi,0x4(%rsp)
mov    %edi,%edx
jmp    1214 <main+0xd4>
nopl   (%rax)
mov    %ebp,%edx
mov    %edi,%ebp
xor    %r14d,%r14d
cmp    %edx,%ebp
jg     1193 <main+0x53>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
call   1050 <is_prime@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%r14d
lea    0x1(%rbp),%eax
mov    0x4(%rsp),%edx
cmp    %edx,%ebp
mov    %eax,%ebp
jl     1230 <main+0xf0>
jmp    1190 <main+0x50>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b0 <main+0x70>

LLVM IR (-O0):
@.str = [72 x i8] c"\EC\9E\85\EB\A0\A5\EB\B0\9B\EC\9D\80 \EC\88\98 \EC\82\AC\EC\9D\B4\EC\97\90 \EC\9E\88\EB\8A\94 \EC\86\8C\EC\88\98\EC\9D\98 \EA\B0\9C\EC\88\98\EB\A5\BC \EC\B6\9C\EB\A0\A5\ED\95\A9\EB\8B\88\EB\8B\A4.\0A\00"
@.str.1 = [89 x i8] c"\EC\88\98\EB\A5\BC \EB\B0\98\EB\B3\B5\ED\95\B4\EC\84\9C \EC\9E\85\EB\A0\A5\ED\95\98\EC\8B\9C\EB\A9\B4 \EA\B7\B8 \EC\88\98\EA\B0\80 \EC\86\8C\EC\88\98\EC\9D\B8\EC\A7\80\EB\A5\BC \ED\8C\90\EB\B3\84\ED\95\B4 \EB\93\9C\EB\A6\BD\EB\8B\88\EB\8B\A4.\0A\0A\00"
@.str.2 = [34 x i8] c"\EC\B2\AB\EB\B2\88\EC\A7\B8 \EC\88\98\EB\A5\BC \EC\9E\85\EB\A0\A5\ED\95\98\EC\84\B8\EC\9A\94.\00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [34 x i8] c"\EB\91\90\EB\B2\88\EC\A7\B8 \EC\88\98\EB\A5\BC \EC\9E\85\EB\A0\A5\ED\95\98\EC\84\B8\EC\9A\94.\00"
@.str.5 = [25 x i8] c"%d\EB\8A\94 \EC\86\8C\EC\88\98\EC\9E\85\EB\8B\88\EB\8B\A4.\0A\0A\00"
@.str.6 = [32 x i8] c"%d\EB\8A\94 \EC\86\8C\EC\88\98\EA\B0\80 \EC\95\84\EB\8B\99\EB\8B\88\EB\8B\A4.\0A\0A\00"
@.str.7 = [61 x i8] c"%d\EC\97\90\EC\84\9C %d\EC\82\AC\EC\9D\B4\EC\97\90 \EC\9E\88\EB\8A\94 \EC\86\8C\EC\88\98\EB\8A\94 \EC\B4\9D %d\EA\B0\9C \EC\9E\85\EB\8B\88\EB\8B\A4.\0A\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 ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %0, %27, %54
store i32 0, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %28
17: ; preds = %9
%18 = load i32, i32* %3
%19 = call i64 @is_prime(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %22)
br label %27
24: ; preds = %17
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %21
br label %9
28: ; preds = %9
%29 = load i32, i32* %4
%30 = load i32, i32* %3
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i32, i32* %3
store i32 %33, i32* %5
%34 = load i32, i32* %4
store i32 %34, i32* %3
%35 = load i32, i32* %5
store i32 %35, i32* %4
br label %36
36: ; preds = %32, %28
br label %37
37: ; preds = %36
%38 = load i32, i32* %3
store i32 %38, i32* %2
br label %39
39: ; preds = %51, %37
%40 = load i32, i32* %2
%41 = load i32, i32* %4
%42 = icmp sle i32 %40, %41
br i1 %42, label %43, label %54
43: ; preds = %39
%44 = load i32, i32* %2
%45 = call i64 @is_prime(i32 %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
br label %50
50: ; preds = %47, %43
br label %51
51: ; preds = %50
%52 = load i32, i32* %2
%53 = add nsw i32 %52, 1
store i32 %53, i32* %2
br label %39
54: ; preds = %39
%55 = load i32, i32* %3
%56 = load i32, i32* %4
%57 = load i32, i32* %6
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0), i32 %55, i32 %56, i32 %57)
br label %9
}

LLVM IR (-O2):
@.str.2 = [34 x i8] c"\EC\B2\AB\EB\B2\88\EC\A7\B8 \EC\88\98\EB\A5\BC \EC\9E\85\EB\A0\A5\ED\95\98\EC\84\B8\EC\9A\94.\00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [34 x i8] c"\EB\91\90\EB\B2\88\EC\A7\B8 \EC\88\98\EB\A5\BC \EC\9E\85\EB\A0\A5\ED\95\98\EC\84\B8\EC\9A\94.\00"
@.str.5 = [25 x i8] c"%d\EB\8A\94 \EC\86\8C\EC\88\98\EC\9E\85\EB\8B\88\EB\8B\A4.\0A\0A\00"
@.str.6 = [32 x i8] c"%d\EB\8A\94 \EC\86\8C\EC\88\98\EA\B0\80 \EC\95\84\EB\8B\99\EB\8B\88\EB\8B\A4.\0A\0A\00"
@.str.7 = [61 x i8] c"%d\EC\97\90\EC\84\9C %d\EC\82\AC\EC\9D\B4\EC\97\90 \EC\9E\88\EB\8A\94 \EC\86\8C\EC\88\98\EB\8A\94 \EC\B4\9D %d\EA\B0\9C \EC\9E\85\EB\8B\88\EB\8B\A4.\0A\0A\00"
@str = [71 x i8] c"\EC\9E\85\EB\A0\A5\EB\B0\9B\EC\9D\80 \EC\88\98 \EC\82\AC\EC\9D\B4\EC\97\90 \EC\9E\88\EB\8A\94 \EC\86\8C\EC\88\98\EC\9D\98 \EA\B0\9C\EC\88\98\EB\A5\BC \EC\B6\9C\EB\A0\A5\ED\95\A9\EB\8B\88\EB\8B\A4.\00"
@str.8 = [88 x i8] c"\EC\88\98\EB\A5\BC \EB\B0\98\EB\B3\B5\ED\95\B4\EC\84\9C \EC\9E\85\EB\A0\A5\ED\95\98\EC\8B\9C\EB\A9\B4 \EA\B7\B8 \EC\88\98\EA\B0\80 \EC\86\8C\EC\88\98\EC\9D\B8\EC\A7\80\EB\A5\BC \ED\8C\90\EB\B3\84\ED\95\B4 \EB\93\9C\EB\A6\BD\EB\8B\88\EB\8B\A4.\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([88 x i8], [88 x i8]* @str.8, i64 0, i64 0))
br label %7
7: ; preds = %21, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %24
15: ; preds = %7
%16 = call i64 @is_prime(i32 %12)
%17 = icmp eq i64 %16, 0
%18 = load i32, i32* %1
br i1 %17, label %22, label %19
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %18)
br label %21
21: ; preds = %19, %22, %43
br label %7
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %18)
br label %21
24: ; preds = %7
%25 = icmp slt i32 %13, %12
br i1 %25, label %26, label %27
26: ; preds = %24
store i32 %13, i32* %1
store i32 %12, i32* %2
br label %27
27: ; preds = %24, %26
%28 = phi i32 [ %13, %24 ], [ %12, %26 ]
%29 = phi i32 [ %12, %24 ], [ %13, %26 ]
%30 = icmp sgt i32 %29, %28
br i1 %30, label %43, label %31
31: ; preds = %27, %31
%32 = phi i32 [ %37, %31 ], [ 0, %27 ]
%33 = phi i32 [ %38, %31 ], [ %29, %27 ]
%34 = call i64 @is_prime(i32 %33)
%35 = icmp ne i64 %34, 0
%36 = zext i1 %35 to i32
%37 = add nuw nsw i32 %32, %36
%38 = add nsw i32 %33, 1
%39 = load i32, i32* %2
%40 = icmp slt i32 %33, %39
br i1 %40, label %31, label %41
41: ; preds = %31
%42 = load i32, i32* %1
br label %43
43: ; preds = %41, %27
%44 = phi i32 [ %29, %27 ], [ %42, %41 ]
%45 = phi i32 [ 0, %27 ], [ %37, %41 ]
%46 = phi i32 [ %28, %27 ], [ %39, %41 ]
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0), i32 %44, i32 %46, i32 %45)
br label %21
}