#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 /*<<< orphan*/ quotient;
typedef int /*<<< orphan*/ b;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ bzero(unsigned char *, int);
int compare(unsigned char *, int, unsigned char *, int);
int deduct(unsigned char *, int, unsigned char *);
int get_highbit(unsigned char *, int);
int /*<<< orphan*/ printf(char *, ...);
int shiftleft(unsigned char *, int);
int shiftright(unsigned char *, int);
int division(unsigned char *dividend, int a_len, unsigned char *divisor,
             int b_len) {
  int i, j = 0, comp, number = 0, b_shift_len = b_len, quo_len = 0,
         quo_total_len;
  int a_highbit, b_highbit;
  unsigned char a[10], b[10], quotient[10];
  bzero(quotient, sizeof(quotient));
  bzero(a, sizeof(a));
  bzero(b, sizeof(b));
  for (i = 0; i <= a_len; i++)
    a[i] = dividend[i];
  for (i = 0; i <= b_len; i++)
    b[i] = divisor[i];
  if ((b[0] == 0) && (b_len == 0)) {
    printf("Please don't let divisor = 0\n");
    return 1;
  }
  comp = compare(a, a_len, b, b_len);
  switch (comp) {
  case 1:
    printf("quotient is 0\n");
    for (i = 0; i <= a_len; i++)
      printf("m[ %d ] = + %d * 256^%d\n", i, a[i], i);
    return 1;
  case 3:
    printf("quotient is 1\n");
    printf("remainder is 0\n");
    return 1;
  }
  a_highbit = get_highbit(a, a_len);
  b_highbit = get_highbit(b, b_len);
  if (a_len - b_len >= 2) {
    number = (a_len - b_len - 1) << 3;
    number += a_highbit - b_highbit + 8;
  } else if (a_len - b_len)
    number = a_highbit - b_highbit + 8;
  else
    number = a_highbit - b_highbit;
  for (i = 0; i < number; i++)
    b_shift_len = shiftleft(b, b_shift_len);
  quo_total_len = ((a_len - b_len) << 3) + a_highbit - b_highbit;
  for (i = 0; i <= quo_total_len; i++) {
    comp = compare(a, a_len, b, b_shift_len);
    quo_len = shiftleft(quotient, quo_len);
    switch (comp) {
    case 1:
      break;
    case 2:
    case 3:
      quotient[0] |= 0x1;
      a_len = deduct(a, a_len, b);
      break;
    }
    b_shift_len = shiftright(b, b_shift_len);
  }
  printf("\n\n");
  printf("binary:  \n");
  printf("quotient:  ");
  for (i = 0; i <= quo_len; i++)
    printf("+ %d *256^%d", quotient[i], i);
  printf("\n");
  printf("reminder:  ");
  for (i = 0; i <= a_len; i++)
    printf("+ %d *256^%d", a[i], i);
  printf("\n");
  return 1;
}


x86 assembly (clang, -O0):
<division>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
lea    -0x66(%rbp),%rdi
mov    $0xa,%esi
call   1070 <bzero@plt>
lea    -0x52(%rbp),%rdi
mov    $0xa,%esi
call   1070 <bzero@plt>
lea    -0x5c(%rbp),%rdi
mov    $0xa,%esi
call   1070 <bzero@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11ff <division+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x52(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11d2 <division+0x62>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1233 <division+0xc3>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x5c(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1206 <division+0x96>
movzbl -0x5c(%rbp),%eax
cmp    $0x0,%eax
jne    1264 <division+0xf4>
cmpl   $0x0,-0x24(%rbp)
jne    1264 <division+0xf4>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    154f <division+0x3df>
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%ecx
lea    -0x52(%rbp),%rdi
lea    -0x5c(%rbp),%rdx
call   1080 <compare@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x1,%eax
je     129f <division+0x12f>
jmp    128e <division+0x11e>
mov    -0x6c(%rbp),%eax
sub    $0x3,%eax
je     12f7 <division+0x187>
jmp    131f <division+0x1af>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     12eb <division+0x17b>
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
movzbl -0x52(%rbp,%rax,1),%edx
mov    -0x28(%rbp),%ecx
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12b4 <division+0x144>
movl   $0x1,-0x4(%rbp)
jmp    154f <division+0x3df>
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    154f <division+0x3df>
lea    -0x52(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <get_highbit@plt>
mov    %eax,-0x44(%rbp)
lea    -0x5c(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1040 <get_highbit@plt>
mov    %eax,-0x48(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x24(%rbp),%eax
cmp    $0x2,%eax
jl     136f <division+0x1ff>
mov    -0x14(%rbp),%eax
sub    -0x24(%rbp),%eax
sub    $0x1,%eax
shl    $0x3,%eax
mov    %eax,-0x34(%rbp)
mov    -0x44(%rbp),%eax
sub    -0x48(%rbp),%eax
add    $0x8,%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    139d <division+0x22d>
mov    -0x14(%rbp),%eax
sub    -0x24(%rbp),%eax
cmp    $0x0,%eax
je     138f <division+0x21f>
mov    -0x44(%rbp),%eax
sub    -0x48(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x34(%rbp)
jmp    1398 <division+0x228>
mov    -0x44(%rbp),%eax
sub    -0x48(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    139d <division+0x22d>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    13cd <division+0x25d>
lea    -0x5c(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1090 <shiftleft@plt>
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    13a4 <division+0x234>
mov    -0x14(%rbp),%eax
sub    -0x24(%rbp),%eax
shl    $0x3,%eax
add    -0x44(%rbp),%eax
sub    -0x48(%rbp),%eax
mov    %eax,-0x40(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x40(%rbp),%eax
jg     147e <division+0x30e>
mov    -0x14(%rbp),%esi
mov    -0x38(%rbp),%ecx
lea    -0x52(%rbp),%rdi
lea    -0x5c(%rbp),%rdx
call   1080 <compare@plt>
mov    %eax,-0x30(%rbp)
mov    -0x3c(%rbp),%esi
lea    -0x66(%rbp),%rdi
call   1090 <shiftleft@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x70(%rbp)
sub    $0x1,%eax
je     143f <division+0x2cf>
jmp    142b <division+0x2bb>
mov    -0x70(%rbp),%eax
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     1444 <division+0x2d4>
jmp    1461 <division+0x2f1>
jmp    1461 <division+0x2f1>
movzbl -0x66(%rbp),%eax
or     $0x1,%eax
mov    %al,-0x66(%rbp)
lea    -0x52(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x5c(%rbp),%rdx
call   1030 <deduct@plt>
mov    %eax,-0x14(%rbp)
lea    -0x5c(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1060 <shiftright@plt>
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    13e6 <division+0x276>
lea    0xbe0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xbd5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xbd2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jg     14e3 <division+0x373>
movslq -0x28(%rbp),%rax
movzbl -0x66(%rbp,%rax,1),%esi
mov    -0x28(%rbp),%edx
lea    0xbb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    14af <division+0x33f>
lea    0xb7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xb94(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     153a <division+0x3ca>
movslq -0x28(%rbp),%rax
movzbl -0x52(%rbp,%rax,1),%esi
mov    -0x28(%rbp),%edx
lea    0xb5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1506 <division+0x396>
lea    0xb25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<division>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %esi,%ebx
mov    %rdi,%rbp
lea    0x26(%rsp),%rdi
mov    $0xa,%esi
call   10a0 <bzero@plt>
lea    0x1c(%rsp),%rdi
mov    $0xa,%esi
call   10a0 <bzero@plt>
lea    0x12(%rsp),%rdi
mov    $0xa,%esi
call   10a0 <bzero@plt>
test   %ebx,%ebx
js     11fd <division+0x5d>
mov    %ebx,%edx
add    $0x1,%rdx
lea    0x1c(%rsp),%rdi
mov    %rbp,%rsi
call   1080 <memcpy@plt>
test   %r12d,%r12d
js     1233 <division+0x93>
mov    %r12d,%edx
add    $0x1,%rdx
lea    0x12(%rsp),%rdi
mov    %r14,%rsi
call   1080 <memcpy@plt>
test   %r12d,%r12d
jne    1233 <division+0x93>
cmpb   $0x0,0x12(%rsp)
jne    1233 <division+0x93>
lea    0xe4a(%rip),%rdi
call   1040 <puts@plt>
jmp    1494 <division+0x2f4>
lea    0x1c(%rsp),%rdi
lea    0x12(%rsp),%rdx
mov    %ebx,%esi
mov    %r12d,%ecx
call   10b0 <compare@plt>
cmp    $0x3,%eax
je     12a1 <division+0x101>
cmp    $0x1,%eax
jne    12be <division+0x11e>
lea    0xe03(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
js     1494 <division+0x2f4>
add    $0x1,%ebx
lea    0xd91(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x1c(%rsp,%rbp,1),%edx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1280 <division+0xe0>
jmp    1494 <division+0x2f4>
lea    0xd96(%rip),%rdi
call   1040 <puts@plt>
lea    0xd98(%rip),%rdi
call   1040 <puts@plt>
jmp    1494 <division+0x2f4>
lea    0x1c(%rsp),%rdi
mov    %ebx,%esi
call   1060 <get_highbit@plt>
mov    %eax,%ebp
lea    0x12(%rsp),%rdi
mov    %r12d,%esi
call   1060 <get_highbit@plt>
mov    %eax,%r15d
mov    %ebx,%r14d
sub    %r12d,%r14d
cmp    $0x2,%r14d
mov    %rbp,0x8(%rsp)
mov    %rbx,0x30(%rsp)
jl     12f9 <division+0x159>
lea    0x0(%rbp,%r14,8),%r13d
jmp    1304 <division+0x164>
lea    0x8(%rbp),%r13d
test   %r14d,%r14d
cmove  %ebp,%r13d
sub    %r15d,%r13d
mov    %r12d,%ebp
test   %r13d,%r13d
jle    1332 <division+0x192>
lea    0x12(%rsp),%rbx
mov    %r12d,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %ebp,%esi
call   10c0 <shiftleft@plt>
mov    %eax,%ebp
add    $0xffffffff,%r13d
jne    1320 <division+0x180>
mov    0x8(%rsp),%rcx
lea    (%rcx,%r14,8),%eax
cmp    %r15d,%eax
js     13d1 <division+0x231>
mov    0x30(%rsp),%r13
lea    (%rcx,%r13,8),%r14d
sub    %r15d,%r14d
shl    $0x3,%r12d
sub    %r12d,%r14d
add    $0x1,%r14d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0x1c(%rsp),%r15
lea    0x12(%rsp),%rbx
jmp    1398 <division+0x1f8>
xchg   %ax,%ax
orb    $0x1,0x26(%rsp)
mov    %r15,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
call   1050 <deduct@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
mov    %ebp,%esi
call   1090 <shiftright@plt>
mov    %eax,%ebp
add    $0xffffffff,%r14d
je     13dd <division+0x23d>
mov    %r15,%rdi
mov    %r13d,%esi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   10b0 <compare@plt>
mov    %r13,%r12
mov    %eax,%r13d
lea    0x26(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   10c0 <shiftleft@plt>
mov    %rax,0x8(%rsp)
and    $0xfffffffe,%r13d
cmp    $0x2,%r13d
je     1370 <division+0x1d0>
mov    %r12,%r13
jmp    1386 <division+0x1e6>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    0x30(%rsp),%r13
lea    0xc33(%rip),%rdi
call   1040 <puts@plt>
lea    0xc79(%rip),%rdi
call   1040 <puts@plt>
lea    0xc1d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp),%rbx
test   %ebx,%ebx
js     143a <division+0x29a>
add    $0x1,%ebx
lea    0xc0f(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl 0x26(%rsp,%rbp,1),%esi
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1420 <division+0x280>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xbe7(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
test   %r13d,%r13d
js     148a <division+0x2ea>
add    $0x1,%r13d
lea    0xbc3(%rip),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl 0x1c(%rsp,%rbp,1),%esi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1470 <division+0x2d0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Please don't let divisor = 0\0A\00"
@.str.1 = [15 x i8] c"quotient is 0\0A\00"
@.str.2 = [25 x i8] c"m[ %d ] = + %d * 256^%d\0A\00"
@.str.3 = [15 x i8] c"quotient is 1\0A\00"
@.str.4 = [16 x i8] c"remainder is 0\0A\00"
@.str.5 = [3 x i8] c"\0A\0A\00"
@.str.6 = [11 x i8] c"binary: \0A\00"
@.str.7 = [12 x i8] c"quotient: \00"
@.str.8 = [13 x i8] c"+ %d *256^%d\00"
@.str.9 = [2 x i8] c"\0A\00"
@.str.10 = [12 x i8] c"reminder: \00"
define i32 @division(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca [10 x i8]
%20 = alloca [10 x i8]
%21 = alloca [10 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 0, i32* %11
store i32 0, i32* %13
%22 = load i32, i32* %9
store i32 %22, i32* %14
store i32 0, i32* %15
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 0
%24 = call i32 @bzero(i8* %23, i32 10)
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 0
%26 = call i32 @bzero(i8* %25, i32 10)
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%28 = call i32 @bzero(i8* %27, i32 10)
store i32 0, i32* %10
br label %29
29: ; preds = %42, %4
%30 = load i32, i32* %10
%31 = load i32, i32* %7
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %45
33: ; preds = %29
%34 = load i8*, i8** %6
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 %40
store i8 %38, i8* %41
br label %42
42: ; preds = %33
%43 = load i32, i32* %10
%44 = add nsw i32 %43, 1
store i32 %44, i32* %10
br label %29
45: ; preds = %29
store i32 0, i32* %10
br label %46
46: ; preds = %59, %45
%47 = load i32, i32* %10
%48 = load i32, i32* %9
%49 = icmp sle i32 %47, %48
br i1 %49, label %50, label %62
50: ; preds = %46
%51 = load i8*, i8** %8
%52 = load i32, i32* %10
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = load i32, i32* %10
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 %57
store i8 %55, i8* %58
br label %59
59: ; preds = %50
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1
store i32 %61, i32* %10
br label %46
62: ; preds = %46
%63 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %72
67: ; preds = %62
%68 = load i32, i32* %9
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %231
72: ; preds = %67, %62
%73 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 0
%74 = load i32, i32* %7
%75 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%76 = load i32, i32* %9
%77 = call i32 @compare(i8* %73, i32 %74, i8* %75, i32 %76)
store i32 %77, i32* %12
%78 = load i32, i32* %12
switch i32 %78, label %101 [
i32 1, label %79
i32 3, label %98
]
79: ; preds = %72
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %10
br label %81
81: ; preds = %94, %79
%82 = load i32, i32* %10
%83 = load i32, i32* %7
%84 = icmp sle i32 %82, %83
br i1 %84, label %85, label %97
85: ; preds = %81
%86 = load i32, i32* %10
%87 = load i32, i32* %10
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 %88
%90 = load i8, i8* %89
%91 = zext i8 %90 to i32
%92 = load i32, i32* %10
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %86, i32 %91, i32 %92)
br label %94
94: ; preds = %85
%95 = load i32, i32* %10
%96 = add nsw i32 %95, 1
store i32 %96, i32* %10
br label %81
97: ; preds = %81
store i32 1, i32* %5
br label %231
98: ; preds = %72
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %5
br label %231
101: ; preds = %72
%102 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 0
%103 = load i32, i32* %7
%104 = call i32 @get_highbit(i8* %102, i32 %103)
store i32 %104, i32* %17
%105 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%106 = load i32, i32* %9
%107 = call i32 @get_highbit(i8* %105, i32 %106)
store i32 %107, i32* %18
%108 = load i32, i32* %7
%109 = load i32, i32* %9
%110 = sub nsw i32 %108, %109
%111 = icmp sge i32 %110, 2
br i1 %111, label %112, label %124
112: ; preds = %101
%113 = load i32, i32* %7
%114 = load i32, i32* %9
%115 = sub nsw i32 %113, %114
%116 = sub nsw i32 %115, 1
%117 = shl i32 %116, 3
store i32 %117, i32* %13
%118 = load i32, i32* %17
%119 = load i32, i32* %18
%120 = sub nsw i32 %118, %119
%121 = add nsw i32 %120, 8
%122 = load i32, i32* %13
%123 = add nsw i32 %122, %121
store i32 %123, i32* %13
br label %139
124: ; preds = %101
%125 = load i32, i32* %7
%126 = load i32, i32* %9
%127 = sub nsw i32 %125, %126
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %134
129: ; preds = %124
%130 = load i32, i32* %17
%131 = load i32, i32* %18
%132 = sub nsw i32 %130, %131
%133 = add nsw i32 %132, 8
store i32 %133, i32* %13
br label %138
134: ; preds = %124
%135 = load i32, i32* %17
%136 = load i32, i32* %18
%137 = sub nsw i32 %135, %136
store i32 %137, i32* %13
br label %138
138: ; preds = %134, %129
br label %139
139: ; preds = %138, %112
store i32 0, i32* %10
br label %140
140: ; preds = %148, %139
%141 = load i32, i32* %10
%142 = load i32, i32* %13
%143 = icmp slt i32 %141, %142
br i1 %143, label %144, label %151
144: ; preds = %140
%145 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%146 = load i32, i32* %14
%147 = call i32 @shiftleft(i8* %145, i32 %146)
store i32 %147, i32* %14
br label %148
148: ; preds = %144
%149 = load i32, i32* %10
%150 = add nsw i32 %149, 1
store i32 %150, i32* %10
br label %140
151: ; preds = %140
%152 = load i32, i32* %7
%153 = load i32, i32* %9
%154 = sub nsw i32 %152, %153
%155 = shl i32 %154, 3
%156 = load i32, i32* %17
%157 = add nsw i32 %155, %156
%158 = load i32, i32* %18
%159 = sub nsw i32 %157, %158
store i32 %159, i32* %16
store i32 0, i32* %10
br label %160
160: ; preds = %189, %151
%161 = load i32, i32* %10
%162 = load i32, i32* %16
%163 = icmp sle i32 %161, %162
br i1 %163, label %164, label %192
164: ; preds = %160
%165 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 0
%166 = load i32, i32* %7
%167 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%168 = load i32, i32* %14
%169 = call i32 @compare(i8* %165, i32 %166, i8* %167, i32 %168)
store i32 %169, i32* %12
%170 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 0
%171 = load i32, i32* %15
%172 = call i32 @shiftleft(i8* %170, i32 %171)
store i32 %172, i32* %15
%173 = load i32, i32* %12
switch i32 %173, label %185 [
i32 1, label %174
i32 2, label %175
i32 3, label %175
]
174: ; preds = %164
br label %185
175: ; preds = %164, %164
%176 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 0
%177 = load i8, i8* %176
%178 = zext i8 %177 to i32
%179 = or i32 %178, 1
%180 = trunc i32 %179 to i8
store i8 %180, i8* %176
%181 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 0
%182 = load i32, i32* %7
%183 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%184 = call i32 @deduct(i8* %181, i32 %182, i8* %183)
store i32 %184, i32* %7
br label %185
185: ; preds = %164, %175, %174
%186 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%187 = load i32, i32* %14
%188 = call i32 @shiftright(i8* %186, i32 %187)
store i32 %188, i32* %14
br label %189
189: ; preds = %185
%190 = load i32, i32* %10
%191 = add nsw i32 %190, 1
store i32 %191, i32* %10
br label %160
192: ; preds = %160
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%194 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %10
br label %196
196: ; preds = %208, %192
%197 = load i32, i32* %10
%198 = load i32, i32* %15
%199 = icmp sle i32 %197, %198
br i1 %199, label %200, label %211
200: ; preds = %196
%201 = load i32, i32* %10
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 %202
%204 = load i8, i8* %203
%205 = zext i8 %204 to i32
%206 = load i32, i32* %10
%207 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %205, i32 %206)
br label %208
208: ; preds = %200
%209 = load i32, i32* %10
%210 = add nsw i32 %209, 1
store i32 %210, i32* %10
br label %196
211: ; preds = %196
%212 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %10
br label %214
214: ; preds = %226, %211
%215 = load i32, i32* %10
%216 = load i32, i32* %7
%217 = icmp sle i32 %215, %216
br i1 %217, label %218, label %229
218: ; preds = %214
%219 = load i32, i32* %10
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 %220
%222 = load i8, i8* %221
%223 = zext i8 %222 to i32
%224 = load i32, i32* %10
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %223, i32 %224)
br label %226
226: ; preds = %218
%227 = load i32, i32* %10
%228 = add nsw i32 %227, 1
store i32 %228, i32* %10
br label %214
229: ; preds = %214
%230 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %5
br label %231
231: ; preds = %229, %98, %97, %70
%232 = load i32, i32* %5
ret i32 %232
}

LLVM IR (-O2):
@.str.2 = [25 x i8] c"m[ %d ] = + %d * 256^%d\0A\00"
@.str.7 = [12 x i8] c"quotient: \00"
@.str.8 = [13 x i8] c"+ %d *256^%d\00"
@.str.10 = [12 x i8] c"reminder: \00"
@str = [14 x i8] c"quotient is 1\00"
@str.11 = [15 x i8] c"remainder is 0\00"
@str.12 = [14 x i8] c"quotient is 0\00"
@str.13 = [2 x i8] c"\0A\00"
@str.14 = [10 x i8] c"binary: \00"
@str.15 = [29 x i8] c"Please don't let divisor = 0\00"
define i32 @division(i8* nocapture %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = alloca [10 x i8]
%6 = alloca [10 x i8]
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%8 = alloca [10 x i8]
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%12 = call i32 @bzero(i8* %11, i32 10)
%13 = call i32 @bzero(i8* %9, i32 10)
%14 = call i32 @bzero(i8* %10, i32 10)
%15 = icmp slt i32 %1, 0
br i1 %15, label %20, label %16
16: ; preds = %4
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%18 = zext i32 %1 to i64
%19 = add nuw nsw i64 %18, 1
br label %20
20: ; preds = %16, %4
%21 = icmp slt i32 %3, 0
br i1 %21, label %31, label %22
22: ; preds = %20
%23 = zext i32 %3 to i64
%24 = add nuw nsw i64 %23, 1
%25 = load i8, i8* %10
%26 = icmp eq i8 %25, 0
%27 = icmp eq i32 %3, 0
%28 = and i1 %27, %26
br i1 %28, label %29, label %31
29: ; preds = %22
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.15, i64 0, i64 0))
br label %140
31: ; preds = %20, %22
%32 = call i32 @compare(i8* %9, i32 %1, i8* %10, i32 %3)
switch i32 %32, label %50 [
i32 1, label %33
i32 3, label %47
]
33: ; preds = %31
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0))
br i1 %15, label %140, label %35
35: ; preds = %33
%36 = add nuw i32 %1, 1
%37 = zext i32 %36 to i64
br label %38
38: ; preds = %35, %38
%39 = phi i64 [ 0, %35 ], [ %45, %38 ]
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = trunc i64 %39 to i32
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %42, i32 %43)
%45 = add nuw nsw i64 %39, 1
%46 = icmp eq i64 %45, %37
br i1 %46, label %140, label %38
47: ; preds = %31
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
br label %140
50: ; preds = %31
%51 = call i32 @get_highbit(i8* %9, i32 %1)
%52 = call i32 @get_highbit(i8* %10, i32 %3)
%53 = sub nsw i32 %1, %3
%54 = icmp sgt i32 %53, 1
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = shl i32 %53, 3
%57 = add i32 %51, %56
br label %62
58: ; preds = %50
%59 = icmp eq i32 %53, 0
%60 = add i32 %51, 8
%61 = select i1 %59, i32 %51, i32 %60
br label %62
62: ; preds = %58, %55
%63 = phi i32 [ %57, %55 ], [ %61, %58 ]
%64 = sub i32 %63, %52
%65 = icmp sgt i32 %64, 0
br i1 %65, label %66, label %72
66: ; preds = %62, %66
%67 = phi i32 [ %70, %66 ], [ 0, %62 ]
%68 = phi i32 [ %69, %66 ], [ %3, %62 ]
%69 = call i32 @shiftleft(i8* %10, i32 %68)
%70 = add nuw nsw i32 %67, 1
%71 = icmp eq i32 %70, %64
br i1 %71, label %72, label %66
72: ; preds = %66, %62
%73 = phi i32 [ %3, %62 ], [ %69, %66 ]
%74 = shl i32 %53, 3
%75 = add nsw i32 %51, %74
%76 = sub i32 %75, %52
%77 = icmp slt i32 %76, 0
br i1 %77, label %103, label %78
78: ; preds = %72
%79 = shl i32 %1, 3
%80 = add i32 %51, %79
%81 = add i32 %80, 1
%82 = sub i32 %81, %52
%83 = mul i32 %3, -8
%84 = add i32 %83, %82
br label %85
85: ; preds = %78, %98
%86 = phi i32 [ %99, %98 ], [ %1, %78 ]
%87 = phi i32 [ %101, %98 ], [ 0, %78 ]
%88 = phi i32 [ %91, %98 ], [ 0, %78 ]
%89 = phi i32 [ %100, %98 ], [ %73, %78 ]
%90 = call i32 @compare(i8* %9, i32 %86, i8* %10, i32 %89)
%91 = call i32 @shiftleft(i8* %11, i32 %88)
%92 = and i32 %90, -2
%93 = icmp eq i32 %92, 2
br i1 %93, label %94, label %98
94: ; preds = %85
%95 = load i8, i8* %11
%96 = or i8 %95, 1
store i8 %96, i8* %11
%97 = call i32 @deduct(i8* %9, i32 %86, i8* %10)
br label %98
98: ; preds = %85, %94
%99 = phi i32 [ %86, %85 ], [ %97, %94 ]
%100 = call i32 @shiftright(i8* %10, i32 %89)
%101 = add nuw i32 %87, 1
%102 = icmp eq i32 %101, %84
br i1 %102, label %103, label %85
103: ; preds = %98, %72
%104 = phi i32 [ 0, %72 ], [ %91, %98 ]
%105 = phi i32 [ %1, %72 ], [ %99, %98 ]
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.13, i64 0, i64 0))
%107 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.14, i64 0, i64 0))
%108 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%109 = icmp slt i32 %104, 0
br i1 %109, label %122, label %110
110: ; preds = %103
%111 = add nuw i32 %104, 1
%112 = zext i32 %111 to i64
br label %113
113: ; preds = %110, %113
%114 = phi i64 [ 0, %110 ], [ %120, %113 ]
%115 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 %114
%116 = load i8, i8* %115
%117 = zext i8 %116 to i32
%118 = trunc i64 %114 to i32
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %117, i32 %118)
%120 = add nuw nsw i64 %114, 1
%121 = icmp eq i64 %120, %112
br i1 %121, label %122, label %113
122: ; preds = %113, %103
%123 = call i32 @putchar(i32 10)
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%125 = icmp slt i32 %105, 0
br i1 %125, label %138, label %126
126: ; preds = %122
%127 = add nuw i32 %105, 1
%128 = zext i32 %127 to i64
br label %129
129: ; preds = %126, %129
%130 = phi i64 [ 0, %126 ], [ %136, %129 ]
%131 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 %130
%132 = load i8, i8* %131
%133 = zext i8 %132 to i32
%134 = trunc i64 %130 to i32
%135 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %133, i32 %134)
%136 = add nuw nsw i64 %130, 1
%137 = icmp eq i64 %136, %128
br i1 %137, label %138, label %129
138: ; preds = %129, %122
%139 = call i32 @putchar(i32 10)
br label %140
140: ; preds = %38, %33, %138, %47, %29
ret i32 1
}