#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 *, ...);
void down(unsigned long long int x) {
  int counter = 1;
  for (int i = 2; i > 1 & i <= x; i++) {
    while (x % i == 0) {
      if (counter == 1) {
        printf("%d", i);
      } else {
        printf("x%d", i);
      }
      counter++;
      x = x / i;
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<down>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
movslq -0x10(%rbp),%rcx
cmp    -0x8(%rbp),%rcx
setbe  %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11d1 <down+0xc1>
jmp    1157 <down+0x47>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    11be <down+0xae>
cmpl   $0x1,-0xc(%rbp)
jne    118e <down+0x7e>
mov    -0x10(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119f <down+0x8f>
mov    -0x10(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
jmp    1157 <down+0x47>
jmp    11c3 <down+0xb3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <down+0x1a>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<down>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%rdi
jae    1140 <down+0x20>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
mov    %rdi,%r14
mov    $0x1,%ebp
mov    $0x2,%ebx
lea    0xead(%rip),%r15
lea    0xea5(%rip),%r12
jmp    116c <down+0x4c>
nopl   (%rax)
lea    0x1(%rbx),%rax
cmp    %rbx,%r14
mov    %rax,%rbx
jbe    112e <down+0xe>
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     1190 <down+0x70>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
je     11af <down+0x8f>
jmp    1160 <down+0x40>
nopw   0x0(%rax,%rax,1)
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
je     11af <down+0x8f>
jmp    1160 <down+0x40>
xchg   %ax,%ax
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
add    $0x1,%ebp
test   %rdx,%rdx
jne    1160 <down+0x40>
cmp    $0x1,%ebp
jne    11c0 <down+0xa0>
mov    %r15,%rdi
jmp    11c3 <down+0xa3>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11f0 <down+0xd0>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
mov    %rax,%r14
jmp    11fa <down+0xda>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%r14d
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11a0 <down+0x80>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
add    $0x1,%ebp
test   %rdx,%rdx
je     11af <down+0x8f>
jmp    1160 <down+0x40>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"x%d\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @down(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
store i64 %0, i64* %2
store i32 1, i32* %3
store i32 2, i32* %4
br label %5
5: ; preds = %40, %1
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, 1
%8 = zext i1 %7 to i32
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = load i64, i64* %2
%12 = icmp ule i64 %10, %11
%13 = zext i1 %12 to i32
%14 = and i32 %8, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %43
16: ; preds = %5
br label %17
17: ; preds = %32, %16
%18 = load i64, i64* %2
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = urem i64 %18, %20
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %39
23: ; preds = %17
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %4
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %32
29: ; preds = %23
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29, %26
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
%35 = load i64, i64* %2
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = udiv i64 %35, %37
store i64 %38, i64* %2
br label %17
39: ; preds = %17
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %5
43: ; preds = %5
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"x%d\00"
define void @down(i64 %0) {
%2 = icmp ult i64 %0, 2
br i1 %2, label %12, label %3
3: ; preds = %1, %27
%4 = phi i64 [ %30, %27 ], [ 2, %1 ]
%5 = phi i32 [ %29, %27 ], [ 1, %1 ]
%6 = phi i64 [ %28, %27 ], [ %0, %1 ]
%7 = urem i64 %6, %4
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %3
%10 = trunc i64 %4 to i32
%11 = trunc i64 %4 to i32
br label %14
12: ; preds = %27, %1
%13 = tail call i32 @putchar(i32 10)
ret void
14: ; preds = %9, %22
%15 = phi i32 [ %23, %22 ], [ %5, %9 ]
%16 = phi i64 [ %24, %22 ], [ %6, %9 ]
%17 = icmp eq i32 %15, 1
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %22
20: ; preds = %14
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %22
22: ; preds = %20, %18
%23 = add nsw i32 %15, 1
%24 = udiv i64 %16, %4
%25 = urem i64 %24, %4
%26 = icmp eq i64 %25, 0
br i1 %26, label %14, label %27
27: ; preds = %22, %3
%28 = phi i64 [ %6, %3 ], [ %24, %22 ]
%29 = phi i32 [ %5, %3 ], [ %23, %22 ]
%30 = add nuw i64 %4, 1
%31 = icmp ugt i64 %28, %4
br i1 %31, label %3, label %12
}