#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int n, m, kont;
  char str[128];
  printf("Emaizkidazu bi zenbaki arrunt: ");
  fgets(str, 128, stdin);
  sscanf(str, "%d %d", &n, &m);
  kont = 0;
  while (n % m == 0) {
    n = n / m;
    kont++;
  }
  printf("%d aldiz zatitu daiteke %d-gatik\n", m, kont);
  printf("Sakatu \"return\" amaitzeko .....");
  fgets(str, 128, stdin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1040 <fgets@plt>
lea    -0xa0(%rbp),%rdi
lea    0xea1(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1050 <sscanf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    $0x0,%edx
jne    11bb <main+0x8b>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1193 <main+0x63>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    0x2dfd(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1040 <fgets@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
lea    0xebd(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e95(%rip),%r15
mov    (%r15),%edx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x80,%esi
call   1040 <fgets@plt>
lea    0xeb1(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %r14,%rdi
call   1050 <sscanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%ecx
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    11b5 <main+0x85>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,%eax
cltd
idiv   %esi
add    $0x1,%ebx
mov    %eax,%ecx
cltd
idiv   %esi
test   %edx,%edx
je     11a0 <main+0x70>
mov    %ecx,0x8(%rsp)
lea    0xe6a(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r15),%edx
lea    0x10(%rsp),%rdi
mov    $0x80,%esi
call   1040 <fgets@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Emaizkidazu bi zenbaki arrunt: \00"
@stdin = global i32 0
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [34 x i8] c"%d aldiz zatitu daiteke %d-gatik\0A\00"
@.str.3 = [32 x i8] c"Sakatu \22return\22 amaitzeko .....\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %11, i32 128, i32 %12)
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
store i32 0, i32* %8
br label %16
16: ; preds = %21, %2
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = srem i32 %17, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %16
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = sdiv i32 %22, %23
store i32 %24, i32* %6
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %16
27: ; preds = %16
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %28, i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%33 = load i32, i32* @stdin
%34 = call i32 @fgets(i8* %32, i32 128, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Emaizkidazu bi zenbaki arrunt: \00"
@stdin = global i32 0
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [34 x i8] c"%d aldiz zatitu daiteke %d-gatik\0A\00"
@.str.3 = [32 x i8] c"Sakatu \22return\22 amaitzeko .....\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [128 x i8]
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %8, i32 128, i32 %10)
%12 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = srem i32 %14, %13
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %2, %17
%18 = phi i32 [ %21, %17 ], [ 0, %2 ]
%19 = phi i32 [ %20, %17 ], [ %14, %2 ]
%20 = sdiv i32 %19, %13
%21 = add nuw nsw i32 %18, 1
%22 = srem i32 %20, %13
%23 = icmp eq i32 %22, 0
br i1 %23, label %17, label %24
24: ; preds = %17
store i32 %20, i32* %3
br label %25
25: ; preds = %24, %2
%26 = phi i32 [ %21, %24 ], [ 0, %2 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32, i32* @stdin
%30 = call i32 @fgets(i8* %8, i32 128, i32 %29)
ret i32 0
}