#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 scanf(char *, unsigned long *);
int main(int argc, char const *argv[]) {
  unsigned long num;
  unsigned long div;
  bool isPrime;
  printf("Please enter an integer for analysis: ");
  printf("Enter q to quit.\n");
  while (scanf("%lu", &num) == 1) {
    for (div = 2, isPrime = true; (div * div) <= num; div++) {
      if (num % div == 0) {
        if ((div * div) != num) {
          printf("%lu is divisible by %lu and %lu.\n", num, div, num / div);
        } else {
          printf("%lu is divisible by %lu.\n", num, div, isPrime);
        }
        isPrime = false;
      }
    }
    if (isPrime) {
      printf("%lu is prime.\n", num);
    }
    printf("Please enter another integer for analysis: ");
    printf("Enter q to quit.\n");
  }
  printf("Bye.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    125b <main+0x13b>
movq   $0x2,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%rax
imul   -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     121e <main+0xfe>
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x20(%rbp)
cmp    $0x0,%rdx
jne    1208 <main+0xe8>
mov    -0x20(%rbp),%rax
imul   -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     11e8 <main+0xc8>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x20(%rbp)
mov    -0x30(%rbp),%rdx
mov    %rax,%rcx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1201 <main+0xe1>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
jmp    120d <main+0xed>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    117a <main+0x5a>
cmpl   $0x0,-0x24(%rbp)
je     123a <main+0x11a>
mov    -0x18(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1152 <main+0x32>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf57(%rip),%rdi
call   1030 <puts@plt>
lea    0xecb(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1285 <main+0x155>
lea    0xf02(%rip),%r15
lea    0xf2c(%rip),%r12
lea    0xea5(%rip),%rbx
mov    %rsp,%rbp
lea    0xec1(%rip),%r13
lea    0xe98(%rip),%r14
jmp    11e9 <main+0xb9>
cs nopw 0x0(%rax,%rax,1)
nop
test   %r15d,%r15d
mov    %rbx,%r15
mov    %rbp,%r12
lea    0xe77(%rip),%rbx
mov    %rsp,%rbp
je     11c3 <main+0x93>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1285 <main+0x155>
mov    (%rsp),%rsi
cmp    $0x4,%rsi
jb     11b5 <main+0x85>
mov    %r12,%rbp
mov    %r15,%rbx
mov    $0x1,%r15d
mov    $0x4,%edi
mov    $0x3,%r12d
jmp    1238 <main+0x108>
mov    %r13,%rdi
mov    %rcx,%rdx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %r15d,%r15d
nop
mov    %r12,%rdi
imul   %r12,%rdi
mov    (%rsp),%rsi
add    $0x1,%r12
cmp    %rsi,%rdi
ja     11a0 <main+0x70>
lea    -0x1(%r12),%rcx
mov    %rsi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1260 <main+0x130>
mov    %rsi,%rax
xor    %edx,%edx
div    %rcx
test   %rdx,%rdx
jne    1220 <main+0xf0>
jmp    126b <main+0x13b>
nopl   0x0(%rax,%rax,1)
mov    %esi,%eax
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
jne    1220 <main+0xf0>
cmp    %rsi,%rdi
je     120c <main+0xdc>
xor    %r15d,%r15d
mov    %r14,%rdi
mov    %rcx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1220 <main+0xf0>
lea    0xe16(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Please enter an integer for analysis: \00"
@.str.1 = [18 x i8] c"Enter q to quit.\0A\00"
@.str.2 = [4 x i8] c"%lu\00"
@.str.3 = [34 x i8] c"%lu is divisible by %lu and %lu.\0A\00"
@.str.4 = [26 x i8] c"%lu is divisible by %lu.\0A\00"
@.str.5 = [15 x i8] c"%lu is prime.\0A\00"
@.str.6 = [44 x i8] c"Please enter another integer for analysis: \00"
@.str.7 = [6 x i8] c"Bye.\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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %55, %2
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %6)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %58
14: ; preds = %11
store i64 2, i64* %7
store i32 1, i32* %8
br label %15
15: ; preds = %46, %14
%16 = load i64, i64* %7
%17 = load i64, i64* %7
%18 = mul i64 %16, %17
%19 = load i64, i64* %6
%20 = icmp ule i64 %18, %19
br i1 %20, label %21, label %49
21: ; preds = %15
%22 = load i64, i64* %6
%23 = load i64, i64* %7
%24 = urem i64 %22, %23
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %45
26: ; preds = %21
%27 = load i64, i64* %7
%28 = load i64, i64* %7
%29 = mul i64 %27, %28
%30 = load i64, i64* %6
%31 = icmp ne i64 %29, %30
br i1 %31, label %32, label %39
32: ; preds = %26
%33 = load i64, i64* %6
%34 = load i64, i64* %7
%35 = load i64, i64* %6
%36 = load i64, i64* %7
%37 = udiv i64 %35, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i64 %33, i64 %34, i64 %37)
br label %44
39: ; preds = %26
%40 = load i64, i64* %6
%41 = load i64, i64* %7
%42 = load i32, i32* %8
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i64 %40, i64 %41, i32 %42)
br label %44
44: ; preds = %39, %32
store i32 0, i32* %8
br label %45
45: ; preds = %44, %21
br label %46
46: ; preds = %45
%47 = load i64, i64* %7
%48 = add i64 %47, 1
store i64 %48, i64* %7
br label %15
49: ; preds = %15
%50 = load i32, i32* %8
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i64, i64* %6
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i64 %53)
br label %55
55: ; preds = %52, %49
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %11
58: ; preds = %11
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"Please enter an integer for analysis: \00"
@.str.2 = [4 x i8] c"%lu\00"
@.str.3 = [34 x i8] c"%lu is divisible by %lu and %lu.\0A\00"
@.str.4 = [26 x i8] c"%lu is divisible by %lu.\0A\00"
@.str.5 = [15 x i8] c"%lu is prime.\0A\00"
@.str.6 = [44 x i8] c"Please enter another integer for analysis: \00"
@str.8 = [5 x i8] c"Bye.\00"
@str.9 = [17 x i8] c"Enter q to quit.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %3)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %42
9: ; preds = %2, %37
%10 = load i64, i64* %3
%11 = icmp ult i64 %10, 4
br i1 %11, label %34, label %12
12: ; preds = %9, %26
%13 = phi i64 [ %30, %26 ], [ %10, %9 ]
%14 = phi i64 [ %29, %26 ], [ 4, %9 ]
%15 = phi i32 [ %27, %26 ], [ 1, %9 ]
%16 = phi i64 [ %28, %26 ], [ 2, %9 ]
%17 = urem i64 %13, %16
%18 = udiv i64 %13, %16
%19 = icmp eq i64 %17, 0
br i1 %19, label %20, label %26
20: ; preds = %12
%21 = icmp eq i64 %14, %13
br i1 %21, label %24, label %22
22: ; preds = %20
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i64 %13, i64 %16, i64 %18)
br label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i64 %13, i64 %16, i32 %15)
br label %26
26: ; preds = %22, %24, %12
%27 = phi i32 [ %15, %12 ], [ 0, %24 ], [ 0, %22 ]
%28 = add i64 %16, 1
%29 = mul i64 %28, %28
%30 = load i64, i64* %3
%31 = icmp ugt i64 %29, %30
br i1 %31, label %32, label %12
32: ; preds = %26
%33 = icmp eq i32 %27, 0
br i1 %33, label %37, label %34
34: ; preds = %9, %32
%35 = phi i64 [ %30, %32 ], [ %10, %9 ]
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i64 %35)
br label %37
37: ; preds = %34, %32
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
%40 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64* %3)
%41 = icmp eq i32 %40, 1
br i1 %41, label %9, label %42
42: ; preds = %37, %2
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.8, i64 0, i64 0))
ret i32 0
}