#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 *, ...);
unsigned long long sqrt(unsigned long long);
int /*<<< orphan*/ sscanf(char *, char *, unsigned long long *);
int main(int argc, char *argv[]) {
  unsigned long long biggest, tsqrt, i;
  int prime = 1;
  int this_num = 0;
  if ((argc != 2) || (!sscanf(argv[1], "%llu", &biggest)) || (biggest < 2)) {
    printf("You lose, you lose, you lose!\n");
    return 2;
  }
  tsqrt = sqrt(biggest);
  for (i = 2; i < tsqrt; i++) {
    this_num = 0;
    while (biggest % i == 0) {
      this_num++;
      biggest = biggest / i;
      tsqrt = sqrt(biggest);
      prime = 0;
    }
    if (this_num) {
      printf("Divisor: %llu^%d\n", i, this_num);
    }
  }
  if (prime) {
    printf("Prime\n");
  } else {
    printf("Divisor: %llu^1\n", biggest);
  }
  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)
movl   $0x1,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    118a <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe93(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x0,%eax
je     118a <main+0x5a>
cmpq   $0x2,-0x18(%rbp)
jae    11a4 <main+0x74>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1281 <main+0x151>
mov    -0x18(%rbp),%rdi
call   1050 <sqrt@plt>
mov    %rax,-0x20(%rbp)
movq   $0x2,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    124b <main+0x11b>
movl   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x28(%rbp)
cmp    $0x0,%rdx
jne    1216 <main+0xe6>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x28(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <sqrt@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
jmp    11ce <main+0x9e>
cmpl   $0x0,-0x30(%rbp)
je     1235 <main+0x105>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%edx
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <main+0x10a>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11b9 <main+0x89>
cmpl   $0x0,-0x2c(%rbp)
je     1268 <main+0x138>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127a <main+0x14a>
mov    -0x18(%rbp),%rsi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    125e <main+0x11e>
mov    0x8(%rsi),%rdi
lea    0xea0(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1050 <sscanf@plt>
test   %eax,%eax
je     125e <main+0x11e>
mov    0x8(%rsp),%rdi
cmp    $0x1,%rdi
jbe    125e <main+0x11e>
call   1060 <sqrt@plt>
cmp    $0x3,%rax
jb     1276 <main+0x136>
mov    %rax,%r15
mov    $0x2,%ebx
mov    $0x1,%r12d
lea    0xe60(%rip),%r14
jmp    11cf <main+0x8f>
nopw   0x0(%rax,%rax,1)
xor    %r12d,%r12d
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %r15,%rbx
jae    1271 <main+0x131>
mov    0x8(%rsp),%rcx
mov    %rcx,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11f0 <main+0xb0>
mov    %rcx,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    11c2 <main+0x82>
jmp    11fb <main+0xbb>
nop
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
jne    11c2 <main+0x82>
xor    %ebp,%ebp
jmp    1210 <main+0xd0>
nop
mov    %rcx,%rax
xor    %edx,%edx
div    %rbx
add    $0x1,%ebp
test   %rdx,%rdx
jne    11b0 <main+0x70>
mov    %rcx,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1230 <main+0xf0>
mov    %rcx,%rax
xor    %edx,%edx
div    %rbx
mov    %rax,%rdi
jmp    1238 <main+0xf8>
nopl   0x0(%rax)
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%edi
mov    %rdi,0x8(%rsp)
call   1060 <sqrt@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rcx
mov    %rcx,%rax
or     %rbx,%rax
shr    $0x20,%rax
jne    1200 <main+0xc0>
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
jmp    1208 <main+0xc8>
lea    0xdc9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%ebx
jmp    129b <main+0x15b>
test   %r12d,%r12d
je     1286 <main+0x146>
lea    0xdab(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    129b <main+0x15b>
mov    0x8(%rsp),%rsi
lea    0xd85(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%llu\00"
@.str.1 = [31 x i8] c"You lose, you lose, you lose!\0A\00"
@.str.2 = [18 x i8] c"Divisor: %llu^%d\0A\00"
@.str.3 = [7 x i8] c"Prime\0A\00"
@.str.4 = [17 x i8] c"Divisor: %llu^1\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 i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %9
store i32 0, i32* %10
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %22, label %13
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %6)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i64, i64* %6
%21 = icmp ult i64 %20, 2
br i1 %21, label %22, label %24
22: ; preds = %19, %13, %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 2, i32* %3
br label %65
24: ; preds = %19
%25 = load i64, i64* %6
%26 = call i64 @sqrt(i64 %25)
store i64 %26, i64* %7
store i64 2, i64* %8
br label %27
27: ; preds = %53, %24
%28 = load i64, i64* %8
%29 = load i64, i64* %7
%30 = icmp ult i64 %28, %29
br i1 %30, label %31, label %56
31: ; preds = %27
store i32 0, i32* %10
br label %32
32: ; preds = %37, %31
%33 = load i64, i64* %6
%34 = load i64, i64* %8
%35 = urem i64 %33, %34
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %45
37: ; preds = %32
%38 = load i32, i32* %10
%39 = add nsw i32 %38, 1
store i32 %39, i32* %10
%40 = load i64, i64* %6
%41 = load i64, i64* %8
%42 = udiv i64 %40, %41
store i64 %42, i64* %6
%43 = load i64, i64* %6
%44 = call i64 @sqrt(i64 %43)
store i64 %44, i64* %7
store i32 0, i32* %9
br label %32
45: ; preds = %32
%46 = load i32, i32* %10
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load i64, i64* %8
%50 = load i32, i32* %10
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i64 %49, i32 %50)
br label %52
52: ; preds = %48, %45
br label %53
53: ; preds = %52
%54 = load i64, i64* %8
%55 = add i64 %54, 1
store i64 %55, i64* %8
br label %27
56: ; preds = %27
%57 = load i32, i32* %9
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %64
61: ; preds = %56
%62 = load i64, i64* %6
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 %62)
br label %64
64: ; preds = %61, %59
store i32 0, i32* %3
br label %65
65: ; preds = %64, %22
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [5 x i8] c"%llu\00"
@.str.2 = [18 x i8] c"Divisor: %llu^%d\0A\00"
@.str.4 = [17 x i8] c"Divisor: %llu^1\0A\00"
@str = [6 x i8] c"Prime\00"
@str.5 = [30 x i8] c"You lose, you lose, you lose!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %3)
%10 = icmp eq i32 %9, 0
%11 = load i64, i64* %3
%12 = icmp ult i64 %11, 2
%13 = select i1 %10, i1 true, i1 %12
br i1 %13, label %14, label %16
14: ; preds = %6, %2
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0))
br label %49
16: ; preds = %6
%17 = call i64 @sqrt(i64 %11)
%18 = icmp ugt i64 %17, 2
br i1 %18, label %19, label %44
19: ; preds = %16, %37
%20 = phi i32 [ %38, %37 ], [ 1, %16 ]
%21 = phi i64 [ %40, %37 ], [ 2, %16 ]
%22 = phi i64 [ %39, %37 ], [ %17, %16 ]
%23 = load i64, i64* %3
%24 = urem i64 %23, %21
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %37
26: ; preds = %19, %26
%27 = phi i64 [ %32, %26 ], [ %23, %19 ]
%28 = phi i32 [ %29, %26 ], [ 0, %19 ]
%29 = add nuw nsw i32 %28, 1
%30 = udiv i64 %27, %21
store i64 %30, i64* %3
%31 = call i64 @sqrt(i64 %30)
%32 = load i64, i64* %3
%33 = urem i64 %32, %21
%34 = icmp eq i64 %33, 0
br i1 %34, label %26, label %35
35: ; preds = %26
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i64 %21, i32 %29)
br label %37
37: ; preds = %19, %35
%38 = phi i32 [ 0, %35 ], [ %20, %19 ]
%39 = phi i64 [ %31, %35 ], [ %22, %19 ]
%40 = add nuw i64 %21, 1
%41 = icmp ult i64 %40, %39
br i1 %41, label %19, label %42
42: ; preds = %37
%43 = icmp eq i32 %38, 0
br i1 %43, label %46, label %44
44: ; preds = %16, %42
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %49
46: ; preds = %42
%47 = load i64, i64* %3
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 %47)
br label %49
49: ; preds = %44, %46, %14
%50 = phi i32 [ 2, %14 ], [ 0, %46 ], [ 0, %44 ]
ret i32 %50
}