#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 maxRepetition(char *);
int divisionwithmodule(int dividend, int divisor) {
  int aux = dividend;
  int rep = 0;
  char decimals[4000] = {'\x0'};
  int i = 0;
  while (aux && !rep && i < 4000) {
    aux *= 10;
    decimals[i] = (aux / divisor + '0');
    decimals[i + 1] = '\x0';
    aux = aux % divisor;
    i++;
  }
  rep = maxRepetition(decimals);
  return rep;
}


x86 assembly (clang, -O0):
<divisionwithmodule>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0xfb0(%rbp),%rdi
xor    %esi,%esi
mov    $0xfa0,%edx
call   1030 <memset@plt>
movl   $0x0,-0xfb4(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xfb5(%rbp)
je     1192 <divisionwithmodule+0x72>
xor    %eax,%eax
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0xfb5(%rbp)
jne    1192 <divisionwithmodule+0x72>
cmpl   $0xfa0,-0xfb4(%rbp)
setl   %al
mov    %al,-0xfb5(%rbp)
mov    -0xfb5(%rbp),%al
test   $0x1,%al
jne    11a5 <divisionwithmodule+0x85>
jmp    11f7 <divisionwithmodule+0xd7>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
add    $0x30,%eax
mov    %al,%cl
movslq -0xfb4(%rbp),%rax
mov    %cl,-0xfb0(%rbp,%rax,1)
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0xfb0(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    115b <divisionwithmodule+0x3b>
lea    -0xfb0(%rbp),%rdi
call   1040 <maxRepetition@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<divisionwithmodule>:
push   %rbp
push   %rbx
sub    $0xfa8,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
mov    %rsp,%rdi
mov    $0xfa0,%edx
xor    %esi,%esi
call   1030 <memset@plt>
test   %ebx,%ebx
je     1178 <divisionwithmodule+0x58>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
cltd
idiv   %ebp
add    $0x30,%al
mov    %al,(%rsp,%rcx,1)
movb   $0x0,0x1(%rsp,%rcx,1)
test   %edx,%edx
je     1178 <divisionwithmodule+0x58>
mov    %edx,%ebx
lea    0x1(%rcx),%rax
cmp    $0xf9f,%rcx
mov    %rax,%rcx
jb     1150 <divisionwithmodule+0x30>
mov    %rsp,%rdi
call   1040 <maxRepetition@plt>
add    $0xfa8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @divisionwithmodule(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [4000 x i8]
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
store i32 %9, i32* %5
store i32 0, i32* %6
%10 = bitcast [4000 x i8]* %7 to i8*
store i32 0, i32* %8
br label %11
11: ; preds = %22, %2
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 4000
br label %20
20: ; preds = %17, %14, %11
%21 = phi i1 [ false, %14 ], [ false, %11 ], [ %19, %17 ]
br i1 %21, label %22, label %42
22: ; preds = %20
%23 = load i32, i32* %5
%24 = mul nsw i32 %23, 10
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = load i32, i32* %4
%27 = sdiv i32 %25, %26
%28 = add nsw i32 %27, 48
%29 = trunc i32 %28 to i8
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [4000 x i8], [4000 x i8]* %7, i64 0, i64 %31
store i8 %29, i8* %32
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [4000 x i8], [4000 x i8]* %7, i64 0, i64 %35
store i8 0, i8* %36
%37 = load i32, i32* %5
%38 = load i32, i32* %4
%39 = srem i32 %37, %38
store i32 %39, i32* %5
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %11
42: ; preds = %20
%43 = getelementptr inbounds [4000 x i8], [4000 x i8]* %7, i64 0, i64 0
%44 = call i32 @maxRepetition(i8* %43)
store i32 %44, i32* %6
%45 = load i32, i32* %6
ret i32 %45
}

LLVM IR (-O2):
define i32 @divisionwithmodule(i32 %0, i32 %1) {
%3 = alloca [4000 x i8]
%4 = getelementptr inbounds [4000 x i8], [4000 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 0
br i1 %5, label %20, label %6
6: ; preds = %2, %6
%7 = phi i64 [ %14, %6 ], [ 0, %2 ]
%8 = phi i32 [ %16, %6 ], [ %0, %2 ]
%9 = mul nsw i32 %8, 10
%10 = sdiv i32 %9, %1
%11 = trunc i32 %10 to i8
%12 = add i8 %11, 48
%13 = getelementptr inbounds [4000 x i8], [4000 x i8]* %3, i64 0, i64 %7
store i8 %12, i8* %13
%14 = add nuw nsw i64 %7, 1
%15 = getelementptr inbounds [4000 x i8], [4000 x i8]* %3, i64 0, i64 %14
store i8 0, i8* %15
%16 = srem i32 %9, %1
%17 = icmp ne i32 %16, 0
%18 = icmp ult i64 %7, 3999
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %6, label %20
20: ; preds = %6, %2
%21 = call i32 @maxRepetition(i8* %4)
ret i32 %21
}