#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 atoi(char *);
char *calloc(int, int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ printPrimeFactorsAsString(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(void) {
  char *buffer = calloc(sizeof(char), 11);
  if (fgets(buffer, sizeof(char) * 11, stdin)) {
    for (int i = 0; i < 11; ++i) {
      if (*(buffer + i) != 0 && *(buffer + i) != '\n' && *(buffer + i) != '-' &&
          !isdigit(*(buffer + i))) {
        printf("Invalid input\n");
        return 1;
      }
    }
    int number = atoi(buffer);
    if (number <= 1) {
      printf("%d has no prime factors", number);
      return 1;
    }
    printPrimeFactorsAsString(number);
    return 0;
  }
  printf("Invalid input\n");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
mov    $0xb,%esi
call   1060 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
mov    $0xb,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1281 <main+0x121>
movl   $0x0,-0x14(%rbp)
cmpl   $0xb,-0x14(%rbp)
jge    123a <main+0xda>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1227 <main+0xc7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1227 <main+0xc7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     1227 <main+0xc7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1227 <main+0xc7>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1296 <main+0x136>
jmp    122c <main+0xcc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11aa <main+0x4a>
mov    -0x10(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jg     126d <main+0x10d>
mov    -0x18(%rbp),%esi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1296 <main+0x136>
mov    -0x18(%rbp),%edi
call   1070 <printPrimeFactorsAsString@plt>
movl   $0x0,-0x4(%rbp)
jmp    1296 <main+0x136>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebp
mov    $0x1,%edi
mov    $0xb,%esi
call   1070 <calloc@plt>
mov    %rax,%rbx
mov    0x2e57(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xb,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     12e0 <main+0x170>
movzbl (%rbx),%eax
movabs $0x200000000401,%rbp
cmp    $0x2d,%rax
ja     12f1 <main+0x181>
bt     %rax,%rbp
jae    12f1 <main+0x181>
movzbl 0x1(%rbx),%eax
cmp    $0x2d,%rax
ja     1306 <main+0x196>
bt     %rax,%rbp
jae    1306 <main+0x196>
movzbl 0x2(%rbx),%eax
cmp    $0x2d,%rax
ja     131b <main+0x1ab>
bt     %rax,%rbp
jae    131b <main+0x1ab>
movzbl 0x3(%rbx),%eax
cmp    $0x2d,%rax
ja     1330 <main+0x1c0>
bt     %rax,%rbp
jae    1330 <main+0x1c0>
movzbl 0x4(%rbx),%eax
cmp    $0x2d,%rax
ja     1345 <main+0x1d5>
bt     %rax,%rbp
jae    1345 <main+0x1d5>
movzbl 0x5(%rbx),%eax
cmp    $0x2d,%rax
ja     1362 <main+0x1f2>
bt     %rax,%rbp
jae    1362 <main+0x1f2>
movzbl 0x6(%rbx),%eax
cmp    $0x2d,%rax
ja     1374 <main+0x204>
bt     %rax,%rbp
jae    1374 <main+0x204>
movzbl 0x7(%rbx),%eax
cmp    $0x2d,%rax
ja     1386 <main+0x216>
bt     %rax,%rbp
jae    1386 <main+0x216>
movzbl 0x8(%rbx),%eax
cmp    $0x2d,%rax
ja     1398 <main+0x228>
bt     %rax,%rbp
jae    1398 <main+0x228>
movzbl 0x9(%rbx),%eax
cmp    $0x2d,%rax
ja     13aa <main+0x23a>
bt     %rax,%rbp
jae    13aa <main+0x23a>
movzbl 0xa(%rbx),%eax
cmp    $0x2d,%rax
ja     13bc <main+0x24c>
bt     %rax,%rbp
jae    13bc <main+0x24c>
mov    %rbx,%rdi
call   1090 <atoi@plt>
cmp    $0x1,%eax
jg     1357 <main+0x1e7>
lea    0xd2e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    13d8 <main+0x268>
lea    0xd31(%rip),%rdi
call   1040 <puts@plt>
jmp    13dd <main+0x26d>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    11ca <main+0x5a>
jmp    13cc <main+0x25c>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    11e2 <main+0x72>
jmp    13cc <main+0x25c>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    11fa <main+0x8a>
jmp    13cc <main+0x25c>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1212 <main+0xa2>
jmp    13cc <main+0x25c>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    122a <main+0xba>
jmp    13cc <main+0x25c>
mov    %eax,%edi
call   1080 <printPrimeFactorsAsString@plt>
xor    %ebp,%ebp
jmp    13dd <main+0x26d>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1242 <main+0xd2>
jmp    13cc <main+0x25c>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    125a <main+0xea>
jmp    13cc <main+0x25c>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1272 <main+0x102>
jmp    13cc <main+0x25c>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    128a <main+0x11a>
jmp    13cc <main+0x25c>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    12a2 <main+0x132>
jmp    13cc <main+0x25c>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    12ba <main+0x14a>
lea    0xc45(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [15 x i8] c"Invalid input\0A\00"
@.str.1 = [24 x i8] c"%d has no prime factors\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i8* @calloc(i32 1, i32 11)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = load i32, i32* @stdin
%8 = call i64 @fgets(i8* %6, i32 11, i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %63
10: ; preds = %0
store i32 0, i32* %3
br label %11
11: ; preds = %49, %10
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 11
br i1 %13, label %14, label %52
14: ; preds = %11
%15 = load i8*, i8** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %48
22: ; preds = %14
%23 = load i8*, i8** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %48
30: ; preds = %22
%31 = load i8*, i8** %2
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 45
br i1 %37, label %38, label %48
38: ; preds = %30
%39 = load i8*, i8** %2
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = call i32 @isdigit(i8 signext %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %38
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %65
48: ; preds = %38, %30, %22, %14
br label %49
49: ; preds = %48
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
br label %11
52: ; preds = %11
%53 = load i8*, i8** %2
%54 = call i32 @atoi(i8* %53)
store i32 %54, i32* %4
%55 = load i32, i32* %4
%56 = icmp sle i32 %55, 1
br i1 %56, label %57, label %60
57: ; preds = %52
%58 = load i32, i32* %4
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %58)
store i32 1, i32* %1
br label %65
60: ; preds = %52
%61 = load i32, i32* %4
%62 = call i32 @printPrimeFactorsAsString(i32 %61)
store i32 0, i32* %1
br label %65
63: ; preds = %0
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %65
65: ; preds = %63, %60, %57, %46
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [24 x i8] c"%d has no prime factors\00"
@str.2 = [14 x i8] c"Invalid input\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(11) i8* @calloc(i32 1, i32 11)
%2 = load i32, i32* @stdin
%3 = tail call i64 @fgets(i8* %1, i32 11, i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %79, label %5
5: ; preds = %0
%6 = load i8, i8* %1
switch i8 %6, label %7 [
i8 0, label %12
i8 10, label %12
i8 45, label %12
]
7: ; preds = %5
%8 = tail call i32 @isdigit(i8 signext %6)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %69, %63, %57, %51, %45, %39, %33, %27, %21, %15, %7
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.2, i64 0, i64 0))
br label %81
12: ; preds = %5, %5, %5, %7
%13 = getelementptr inbounds i8, i8* %1, i64 1
%14 = load i8, i8* %13
switch i8 %14, label %15 [
i8 0, label %18
i8 10, label %18
i8 45, label %18
]
15: ; preds = %12
%16 = tail call i32 @isdigit(i8 signext %14)
%17 = icmp eq i32 %16, 0
br i1 %17, label %10, label %18
18: ; preds = %15, %12, %12, %12
%19 = getelementptr inbounds i8, i8* %1, i64 2
%20 = load i8, i8* %19
switch i8 %20, label %21 [
i8 0, label %24
i8 10, label %24
i8 45, label %24
]
21: ; preds = %18
%22 = tail call i32 @isdigit(i8 signext %20)
%23 = icmp eq i32 %22, 0
br i1 %23, label %10, label %24
24: ; preds = %21, %18, %18, %18
%25 = getelementptr inbounds i8, i8* %1, i64 3
%26 = load i8, i8* %25
switch i8 %26, label %27 [
i8 0, label %30
i8 10, label %30
i8 45, label %30
]
27: ; preds = %24
%28 = tail call i32 @isdigit(i8 signext %26)
%29 = icmp eq i32 %28, 0
br i1 %29, label %10, label %30
30: ; preds = %27, %24, %24, %24
%31 = getelementptr inbounds i8, i8* %1, i64 4
%32 = load i8, i8* %31
switch i8 %32, label %33 [
i8 0, label %36
i8 10, label %36
i8 45, label %36
]
33: ; preds = %30
%34 = tail call i32 @isdigit(i8 signext %32)
%35 = icmp eq i32 %34, 0
br i1 %35, label %10, label %36
36: ; preds = %33, %30, %30, %30
%37 = getelementptr inbounds i8, i8* %1, i64 5
%38 = load i8, i8* %37
switch i8 %38, label %39 [
i8 0, label %42
i8 10, label %42
i8 45, label %42
]
39: ; preds = %36
%40 = tail call i32 @isdigit(i8 signext %38)
%41 = icmp eq i32 %40, 0
br i1 %41, label %10, label %42
42: ; preds = %39, %36, %36, %36
%43 = getelementptr inbounds i8, i8* %1, i64 6
%44 = load i8, i8* %43
switch i8 %44, label %45 [
i8 0, label %48
i8 10, label %48
i8 45, label %48
]
45: ; preds = %42
%46 = tail call i32 @isdigit(i8 signext %44)
%47 = icmp eq i32 %46, 0
br i1 %47, label %10, label %48
48: ; preds = %45, %42, %42, %42
%49 = getelementptr inbounds i8, i8* %1, i64 7
%50 = load i8, i8* %49
switch i8 %50, label %51 [
i8 0, label %54
i8 10, label %54
i8 45, label %54
]
51: ; preds = %48
%52 = tail call i32 @isdigit(i8 signext %50)
%53 = icmp eq i32 %52, 0
br i1 %53, label %10, label %54
54: ; preds = %51, %48, %48, %48
%55 = getelementptr inbounds i8, i8* %1, i64 8
%56 = load i8, i8* %55
switch i8 %56, label %57 [
i8 0, label %60
i8 10, label %60
i8 45, label %60
]
57: ; preds = %54
%58 = tail call i32 @isdigit(i8 signext %56)
%59 = icmp eq i32 %58, 0
br i1 %59, label %10, label %60
60: ; preds = %57, %54, %54, %54
%61 = getelementptr inbounds i8, i8* %1, i64 9
%62 = load i8, i8* %61
switch i8 %62, label %63 [
i8 0, label %66
i8 10, label %66
i8 45, label %66
]
63: ; preds = %60
%64 = tail call i32 @isdigit(i8 signext %62)
%65 = icmp eq i32 %64, 0
br i1 %65, label %10, label %66
66: ; preds = %63, %60, %60, %60
%67 = getelementptr inbounds i8, i8* %1, i64 10
%68 = load i8, i8* %67
switch i8 %68, label %69 [
i8 0, label %72
i8 10, label %72
i8 45, label %72
]
69: ; preds = %66
%70 = tail call i32 @isdigit(i8 signext %68)
%71 = icmp eq i32 %70, 0
br i1 %71, label %10, label %72
72: ; preds = %69, %66, %66, %66
%73 = tail call i32 @atoi(i8* %1)
%74 = icmp slt i32 %73, 2
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %73)
br label %81
77: ; preds = %72
%78 = tail call i32 @printPrimeFactorsAsString(i32 %73)
br label %81
79: ; preds = %0
%80 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.2, i64 0, i64 0))
br label %81
81: ; preds = %10, %75, %77, %79
%82 = phi i32 [ 1, %79 ], [ 1, %75 ], [ 0, %77 ], [ 1, %10 ]
ret i32 %82
}