#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 d, n;
  printf("Enter a integer:");
  scanf("%d", &n);
  for (d = 2; d < n; d++) {
    if (n % d == 0)
      break;
  }
  if (d * d <= n) {
    printf("%d is divisible by %d\n", n, d);
  } else {
    printf("%d is a prime\n", n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1188 <main+0x68>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    1175 <main+0x55>
jmp    1188 <main+0x68>
jmp    117a <main+0x5a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x34>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11b1 <main+0x91>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c2 <main+0xa2>
mov    -0xc(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    $0x2,%ecx
cmp    $0x3,%esi
jl     1172 <main+0x52>
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     1172 <main+0x52>
add    $0x1,%ecx
cmp    %ecx,%esi
jne    1160 <main+0x40>
mov    %esi,%ecx
mov    %ecx,%eax
imul   %ecx,%eax
cmp    %esi,%eax
jle    118b <main+0x6b>
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    119b <main+0x7b>
lea    0xe82(%rip),%rdi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter a integer:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"%d is divisible by %d\0A\00"
@.str.3 = [15 x i8] c"%d is a prime\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 2, i32* %2
br label %6
6: ; preds = %17, %0
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = srem i32 %11, %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
br label %20
16: ; preds = %10
br label %17
17: ; preds = %16
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %6
20: ; preds = %15, %6
%21 = load i32, i32* %2
%22 = load i32, i32* %2
%23 = mul nsw i32 %21, %22
%24 = load i32, i32* %3
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28)
br label %33
30: ; preds = %20
%31 = load i32, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %26
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter a integer:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"%d is divisible by %d\0A\00"
@.str.3 = [15 x i8] c"%d is a prime\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 2
br i1 %6, label %7, label %14
7: ; preds = %0, %11
%8 = phi i32 [ %12, %11 ], [ 2, %0 ]
%9 = srem i32 %5, %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %12, %5
br i1 %13, label %14, label %7
14: ; preds = %11, %7, %0
%15 = phi i32 [ 2, %0 ], [ %8, %7 ], [ %5, %11 ]
%16 = mul nsw i32 %15, %15
%17 = icmp sgt i32 %16, %5
br i1 %17, label %20, label %18
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %5, i32 %15)
br label %22
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %5)
br label %22
22: ; preds = %20, %18
ret i32 0
}