#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 *);
scalar_t__ ft_isprime(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc != 2) {
    printf("\n");
    return (0);
  }
  int nb;
  int i;
  i = 2;
  nb = atoi(argv[1]);
  if (atoi(argv[1]) == 1) {
    printf("1\n");
    return (0);
  }
  if (ft_isprime(nb)) {
    printf("%s\n", argv[1]);
    return (0);
  }
  while (nb / i >= 2) {
    if (nb % i == 0) {
      printf("%d*", i);
      nb /= i;
    } else {
      i++;
    }
  }
  printf("%d\n", nb);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     116a <main+0x3a>
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1252 <main+0x122>
movl   $0x2,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
cmp    $0x1,%eax
jne    11b1 <main+0x81>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1252 <main+0x122>
mov    -0x14(%rbp),%edi
call   1040 <ft_isprime@plt>
cmp    $0x0,%rax
je     11e5 <main+0xb5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1252 <main+0x122>
jmp    11ea <main+0xba>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    $0x2,%eax
jl     123a <main+0x10a>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    $0x0,%edx
jne    122c <main+0xfc>
mov    -0x18(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
jmp    1235 <main+0x105>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ea <main+0xba>
mov    -0x14(%rbp),%esi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    117e <main+0x2e>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
cmp    $0x1,%eax
jne    118a <main+0x3a>
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
jmp    11fc <main+0xac>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11fc <main+0xac>
mov    %eax,%r15d
mov    %eax,%edi
call   1060 <ft_isprime@plt>
test   %rax,%rax
je     11a4 <main+0x54>
mov    0x8(%rbx),%rdi
call   1040 <puts@plt>
jmp    11fc <main+0xac>
cmp    $0x4,%r15d
jl     11eb <main+0x9b>
mov    %r15d,%ebx
shr    %ebx
mov    $0x2,%ebp
lea    0xe45(%rip),%r14
jmp    11d0 <main+0x80>
nopl   (%rax)
add    $0x1,%ebp
mov    %r15d,%eax
cltd
idiv   %ebp
mov    %eax,%ebx
cmp    $0x1,%eax
jle    11eb <main+0x9b>
mov    %r15d,%eax
cltd
idiv   %ebp
test   %edx,%edx
jne    11c0 <main+0x70>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%r15d
jmp    11c3 <main+0x73>
lea    0xe12(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [3 x i8] c"1\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [4 x i8] c"%d*\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %57
12: ; preds = %2
store i32 2, i32* %7
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %12
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %57
24: ; preds = %12
%25 = load i32, i32* %6
%26 = call i64 @ft_isprime(i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %31)
store i32 0, i32* %3
br label %57
33: ; preds = %24
br label %34
34: ; preds = %53, %33
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = sdiv i32 %35, %36
%38 = icmp sge i32 %37, 2
br i1 %38, label %39, label %54
39: ; preds = %34
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = srem i32 %40, %41
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %50
44: ; preds = %39
%45 = load i32, i32* %7
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %7
%48 = load i32, i32* %6
%49 = sdiv i32 %48, %47
store i32 %49, i32* %6
br label %53
50: ; preds = %39
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %53
53: ; preds = %50, %44
br label %34
54: ; preds = %34
%55 = load i32, i32* %6
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %55)
store i32 0, i32* %3
br label %57
57: ; preds = %54, %28, %22, %10
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str.3 = [4 x i8] c"%d*\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [2 x i8] c"1\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @putchar(i32 10)
br label %41
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %41
13: ; preds = %6
%14 = tail call i64 @ft_isprime(i32 %9)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = icmp sgt i32 %9, 3
br i1 %17, label %18, label %38
18: ; preds = %16
%19 = lshr i32 %9, 1
br label %23
20: ; preds = %13
%21 = load i8*, i8** %7
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
br label %41
23: ; preds = %18, %33
%24 = phi i32 [ %36, %33 ], [ %19, %18 ]
%25 = phi i32 [ %35, %33 ], [ 2, %18 ]
%26 = phi i32 [ %34, %33 ], [ %9, %18 ]
%27 = srem i32 %26, %25
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %33
31: ; preds = %23
%32 = add nsw i32 %25, 1
br label %33
33: ; preds = %31, %29
%34 = phi i32 [ %24, %29 ], [ %26, %31 ]
%35 = phi i32 [ %25, %29 ], [ %32, %31 ]
%36 = sdiv i32 %34, %35
%37 = icmp sgt i32 %36, 1
br i1 %37, label %23, label %38
38: ; preds = %33, %16
%39 = phi i32 [ %9, %16 ], [ %34, %33 ]
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %11, %20, %38, %4
ret i32 0
}