#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ _ladd(int *, int *);
int /*<<< orphan*/ _llshift(int *);
int /*<<< orphan*/ _lrshift(int *);
void _ldiv5(uint32_t value[]) {
  uint32_t result[2];
  register int shift;
  uint32_t temp1[2];
  uint32_t temp2[2];
  result[0] = 0;
  result[1] = value[1] / 5;
  temp1[0] = value[0];
  temp1[1] = value[1] % 5;
  temp2[1] = 0;
  while (1) {
    for (shift = 0; temp1[1] != 0; shift++)
      _lrshift(temp1);
    temp2[0] = temp1[0] / 5;
    if (temp2[0] == 0) {
      if (temp1[0] % 5 > (5 / 2)) {
        temp1[0] = 1;
        _ladd(result, temp1);
      }
      break;
    }
    temp1[0] = temp2[0];
    while (shift-- != 0)
      _llshift(temp1);
    _ladd(result, temp1);
    temp1[0] = result[0];
    temp1[1] = result[1];
    _llshift(temp1);
    _llshift(temp1);
    _ladd(temp1, result);
    temp1[0] = ~temp1[0];
    temp1[1] = ~temp1[1];
    temp2[0] = 1;
    _ladd(temp1, temp2);
    _ladd(temp1, value);
  }
  value[0] = result[0];
  value[1] = result[1];
}


x86 assembly (clang, -O0):
<_ldiv5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     119f <_ldiv5+0x6f>
lea    -0x1c(%rbp),%rdi
call   1050 <_lrshift@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117e <_ldiv5+0x4e>
mov    -0x1c(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    11e4 <_ldiv5+0xb4>
mov    -0x1c(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x2,%edx
jle    11df <_ldiv5+0xaf>
movl   $0x1,-0x1c(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1030 <_ladd@plt>
jmp    127c <_ldiv5+0x14c>
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     120c <_ldiv5+0xdc>
lea    -0x1c(%rbp),%rdi
call   1040 <_llshift@plt>
jmp    11ea <_ldiv5+0xba>
lea    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1030 <_ladd@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x1c(%rbp),%rdi
call   1040 <_llshift@plt>
lea    -0x1c(%rbp),%rdi
call   1040 <_llshift@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <_ladd@plt>
mov    -0x1c(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1030 <_ladd@plt>
lea    -0x1c(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <_ladd@plt>
jmp    1177 <_ldiv5+0x47>
mov    -0x10(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ldiv5>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
movl   $0x0,0x10(%rsp)
movslq 0x4(%rdi),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
mov    %ecx,0x14(%rsp)
mov    (%rdi),%edx
mov    %edx,0x8(%rsp)
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
movl   $0x0,0x1c(%rsp)
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%rbx
lea    0x18(%rsp),%r12
jmp    11ea <_ldiv5+0xba>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <_ladd@plt>
mov    0x10(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
call   1040 <_llshift@plt>
mov    %rbx,%rdi
call   1040 <_llshift@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <_ladd@plt>
notl   0x8(%rsp)
notl   0xc(%rsp)
movl   $0x1,0x18(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <_ladd@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <_ladd@plt>
mov    0xc(%rsp),%eax
xor    %ebp,%ebp
test   %eax,%eax
je     1202 <_ldiv5+0xd2>
mov    %rbx,%rdi
call   1050 <_lrshift@plt>
add    $0x1,%ebp
cmpl   $0x0,0xc(%rsp)
jne    11f0 <_ldiv5+0xc0>
movslq 0x8(%rsp),%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
mov    %ecx,0x18(%rsp)
lea    0x4(%rax),%edx
cmp    $0x8,%edx
jbe    1252 <_ldiv5+0x122>
mov    %ecx,0x8(%rsp)
test   %ebp,%ebp
je     1190 <_ldiv5+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <_llshift@plt>
add    $0xffffffff,%ebp
jne    1240 <_ldiv5+0x110>
jmp    1190 <_ldiv5+0x60>
movsbl %al,%ecx
imul   $0x67,%ecx,%ecx
movzwl %cx,%ecx
movswl %cx,%edx
shr    $0xf,%ecx
shr    $0x9,%edx
add    %cl,%dl
movzbl %dl,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
cmp    $0x3,%al
jl     1289 <_ldiv5+0x159>
movl   $0x1,0x8(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <_ladd@plt>
mov    0x10(%rsp),%eax
mov    %eax,(%r14)
mov    0x14(%rsp),%eax
mov    %eax,0x4(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_ldiv5(i32* %0) {
%2 = alloca i32*
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = alloca [2 x i32]
store i32* %0, i32** %2
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
store i32 0, i32* %7
%8 = load i32*, i32** %2
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = load i32, i32* %9
%11 = sdiv i32 %10, 5
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
store i32 %11, i32* %12
%13 = load i32*, i32** %2
%14 = getelementptr inbounds i32, i32* %13, i64 0
%15 = load i32, i32* %14
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 %15, i32* %16
%17 = load i32*, i32** %2
%18 = getelementptr inbounds i32, i32* %17, i64 1
%19 = load i32, i32* %18
%20 = srem i32 %19, 5
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
store i32 %20, i32* %21
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 0, i32* %22
br label %23
23: ; preds = %1, %64
store i32 0, i32* %4
br label %24
24: ; preds = %31, %23
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%26 = load i32, i32* %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %24
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%30 = call i32 @_lrshift(i32* %29)
br label %31
31: ; preds = %28
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %24
34: ; preds = %24
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%36 = load i32, i32* %35
%37 = sdiv i32 %36, 5
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 %37, i32* %38
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %53
42: ; preds = %34
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%44 = load i32, i32* %43
%45 = srem i32 %44, 5
%46 = icmp sgt i32 %45, 2
br i1 %46, label %47, label %52
47: ; preds = %42
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 1, i32* %48
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%51 = call i32 @_ladd(i32* %49, i32* %50)
br label %52
52: ; preds = %47, %42
br label %96
53: ; preds = %34
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%55 = load i32, i32* %54
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 %55, i32* %56
br label %57
57: ; preds = %61, %53
%58 = load i32, i32* %4
%59 = add nsw i32 %58, -1
store i32 %59, i32* %4
%60 = icmp ne i32 %58, 0
br i1 %60, label %61, label %64
61: ; preds = %57
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%63 = call i32 @_llshift(i32* %62)
br label %57
64: ; preds = %57
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%67 = call i32 @_ladd(i32* %65, i32* %66)
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%69 = load i32, i32* %68
%70 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 %69, i32* %70
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%72 = load i32, i32* %71
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
store i32 %72, i32* %73
%74 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%75 = call i32 @_llshift(i32* %74)
%76 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%77 = call i32 @_llshift(i32* %76)
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%80 = call i32 @_ladd(i32* %78, i32* %79)
%81 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%82 = load i32, i32* %81
%83 = xor i32 %82, -1
%84 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32 %83, i32* %84
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%86 = load i32, i32* %85
%87 = xor i32 %86, -1
%88 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
store i32 %87, i32* %88
%89 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 1, i32* %89
%90 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%91 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%92 = call i32 @_ladd(i32* %90, i32* %91)
%93 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%94 = load i32*, i32** %2
%95 = call i32 @_ladd(i32* %93, i32* %94)
br label %23
96: ; preds = %52
%97 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%98 = load i32, i32* %97
%99 = load i32*, i32** %2
%100 = getelementptr inbounds i32, i32* %99, i64 0
store i32 %98, i32* %100
%101 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%102 = load i32, i32* %101
%103 = load i32*, i32** %2
%104 = getelementptr inbounds i32, i32* %103, i64 1
store i32 %102, i32* %104
ret void
}

LLVM IR (-O2):
define void @_ldiv5(i32* %0) {
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = bitcast [2 x i32]* %2 to i8*
%6 = bitcast [2 x i32]* %3 to i8*
%7 = bitcast [2 x i32]* %4 to i8*
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
store i32 0, i32* %8
%9 = getelementptr inbounds i32, i32* %0, i64 1
%10 = load i32, i32* %9
%11 = sdiv i32 %10, 5
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
store i32 %11, i32* %12
%13 = load i32, i32* %0
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
store i32 %13, i32* %14
%15 = srem i32 %10, 5
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
store i32 %15, i32* %16
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
store i32 0, i32* %17
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
br label %19
19: ; preds = %47, %1
%20 = phi i32 [ %60, %47 ], [ %15, %1 ]
%21 = icmp eq i32 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %19, %22
%23 = phi i32 [ %25, %22 ], [ 0, %19 ]
%24 = call i32 @_lrshift(i32* %14)
%25 = add nuw nsw i32 %23, 1
%26 = load i32, i32* %16
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %22
28: ; preds = %22, %19
%29 = phi i32 [ 0, %19 ], [ %25, %22 ]
%30 = load i32, i32* %14
%31 = sdiv i32 %30, 5
store i32 %31, i32* %18
%32 = add i32 %30, 4
%33 = icmp ult i32 %32, 9
br i1 %33, label %34, label %40
34: ; preds = %28
%35 = trunc i32 %30 to i8
%36 = srem i8 %35, 5
%37 = icmp sgt i8 %36, 2
br i1 %37, label %38, label %61
38: ; preds = %34
store i32 1, i32* %14
%39 = call i32 @_ladd(i32* %8, i32* %14)
br label %61
40: ; preds = %28
store i32 %31, i32* %14
%41 = icmp eq i32 %29, 0
br i1 %41, label %47, label %42
42: ; preds = %40, %42
%43 = phi i32 [ %44, %42 ], [ %29, %40 ]
%44 = add nsw i32 %43, -1
%45 = call i32 @_llshift(i32* %14)
%46 = icmp eq i32 %44, 0
br i1 %46, label %47, label %42
47: ; preds = %42, %40
%48 = call i32 @_ladd(i32* %8, i32* %14)
%49 = load i32, i32* %8
store i32 %49, i32* %14
%50 = load i32, i32* %12
store i32 %50, i32* %16
%51 = call i32 @_llshift(i32* %14)
%52 = call i32 @_llshift(i32* %14)
%53 = call i32 @_ladd(i32* %14, i32* %8)
%54 = load i32, i32* %14
%55 = xor i32 %54, -1
store i32 %55, i32* %14
%56 = load i32, i32* %16
%57 = xor i32 %56, -1
store i32 %57, i32* %16
store i32 1, i32* %18
%58 = call i32 @_ladd(i32* %14, i32* %18)
%59 = call i32 @_ladd(i32* %14, i32* %0)
%60 = load i32, i32* %16
br label %19
61: ; preds = %34, %38
%62 = load i32, i32* %8
store i32 %62, i32* %0
%63 = load i32, i32* %12
store i32 %63, i32* %9
ret void
}