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

/* Variables and functions */
int /*<<< orphan*/ bcopy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ bzero(unsigned char *, int);
int compare(unsigned char *, int, unsigned char *, int);
int deduct(unsigned char *, int, unsigned char *, int);
int get_highbit(unsigned char *);
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));
  bcopy(dividend, a, sizeof(dividend));
  bcopy(divisor, b, sizeof(divisor));
  if ((b[b_len] == 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");
    printf("reminder: \n");
    for (i = a_len, j = 0; i >= 0; i--, j++)
      printf("+ %d * 256^%d\n", a[i], j);
    return 1;
  case 3:
    printf("quotient is 1\n");
    printf("remainder is 0\n");
    return 1;
  }
  a_highbit = get_highbit(a);
  b_highbit = get_highbit(b);
  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[quo_len] |= 0x1;
      a_len = deduct(a, a_len, b, b_shift_len);
      break;
    }
    b_shift_len = shiftright(b, b_shift_len);
  }
  printf("\n\n");
  printf("quotient:  ");
  for (i = quo_len, j = 0; i >= 0; i--, j++)
    printf("+ %d *256^%d", quotient[i], j);
  printf("\n");
  printf("reminder:  ");
  for (i = a_len, j = 0; i >= 0; i--, j++)
    printf("+ %d *256^%d", a[i], j);
  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   1080 <bzero@plt>
lea    -0x52(%rbp),%rdi
mov    $0xa,%esi
call   1080 <bzero@plt>
lea    -0x5c(%rbp),%rdi
mov    $0xa,%esi
call   1080 <bzero@plt>
mov    -0x10(%rbp),%rdi
lea    -0x52(%rbp),%rsi
mov    $0x8,%edx
call   1060 <bcopy@plt>
mov    -0x20(%rbp),%rdi
lea    -0x5c(%rbp),%rsi
mov    $0x8,%edx
call   1060 <bcopy@plt>
movslq -0x24(%rbp),%rax
movzbl -0x5c(%rbp,%rax,1),%eax
cmp    $0x0,%eax
jne    1235 <division+0xb5>
cmpl   $0x0,-0x24(%rbp)
jne    1235 <division+0xb5>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1547 <division+0x3c7>
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%ecx
lea    -0x52(%rbp),%rdi
lea    -0x5c(%rbp),%rdx
call   1090 <compare@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x1,%eax
je     1270 <division+0xf0>
jmp    125f <division+0xdf>
mov    -0x6c(%rbp),%eax
sub    $0x3,%eax
je     12e0 <division+0x160>
jmp    1308 <division+0x188>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     12d4 <division+0x154>
movslq -0x28(%rbp),%rax
movzbl -0x52(%rbp,%rax,1),%esi
mov    -0x2c(%rbp),%edx
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1299 <division+0x119>
movl   $0x1,-0x4(%rbp)
jmp    1547 <division+0x3c7>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1547 <division+0x3c7>
lea    -0x52(%rbp),%rdi
call   1040 <get_highbit@plt>
mov    %eax,-0x44(%rbp)
lea    -0x5c(%rbp),%rdi
call   1040 <get_highbit@plt>
mov    %eax,-0x48(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x24(%rbp),%eax
cmp    $0x2,%eax
jl     1352 <division+0x1d2>
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    1380 <division+0x200>
mov    -0x14(%rbp),%eax
sub    -0x24(%rbp),%eax
cmp    $0x0,%eax
je     1372 <division+0x1f2>
mov    -0x44(%rbp),%eax
sub    -0x48(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x34(%rbp)
jmp    137b <division+0x1fb>
mov    -0x44(%rbp),%eax
sub    -0x48(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1380 <division+0x200>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    13b0 <division+0x230>
lea    -0x5c(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   10a0 <shiftleft@plt>
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1387 <division+0x207>
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     146a <division+0x2ea>
mov    -0x14(%rbp),%esi
mov    -0x38(%rbp),%ecx
lea    -0x52(%rbp),%rdi
lea    -0x5c(%rbp),%rdx
call   1090 <compare@plt>
mov    %eax,-0x30(%rbp)
mov    -0x3c(%rbp),%esi
lea    -0x66(%rbp),%rdi
call   10a0 <shiftleft@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x70(%rbp)
sub    $0x1,%eax
je     1422 <division+0x2a2>
jmp    140e <division+0x28e>
mov    -0x70(%rbp),%eax
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     1427 <division+0x2a7>
jmp    144d <division+0x2cd>
jmp    144d <division+0x2cd>
movslq -0x3c(%rbp),%rax
movzbl -0x66(%rbp,%rax,1),%ecx
or     $0x1,%ecx
mov    %cl,-0x66(%rbp,%rax,1)
lea    -0x52(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x5c(%rbp),%rdx
mov    -0x38(%rbp),%ecx
call   1030 <deduct@plt>
mov    %eax,-0x14(%rbp)
lea    -0x5c(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1070 <shiftright@plt>
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    13c9 <division+0x249>
lea    0xbf6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xbeb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     14ce <division+0x34e>
movslq -0x28(%rbp),%rax
movzbl -0x66(%rbp,%rax,1),%esi
mov    -0x2c(%rbp),%edx
lea    0xbc6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1493 <division+0x313>
lea    0xb93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xba0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     1532 <division+0x3b2>
movslq -0x28(%rbp),%rax
movzbl -0x52(%rbp,%rax,1),%esi
mov    -0x2c(%rbp),%edx
lea    0xb62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    14f7 <division+0x377>
lea    0xb2f(%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,%rbx
mov    %esi,%r15d
mov    %rdi,%rbp
lea    0x26(%rsp),%rdi
mov    $0xa,%esi
call   1090 <bzero@plt>
lea    0x8(%rsp),%rdi
mov    $0xa,%esi
call   1090 <bzero@plt>
lea    0x18(%rsp),%rdi
mov    $0xa,%esi
call   1090 <bzero@plt>
mov    0x0(%rbp),%rax
mov    %rax,0x8(%rsp)
mov    (%rbx),%rax
mov    %rax,0x18(%rsp)
test   %r12d,%r12d
jne    1208 <division+0x78>
movslq %r12d,%rax
cmpb   $0x0,0x18(%rsp,%rax,1)
jne    1208 <division+0x78>
lea    0xe6c(%rip),%rdi
call   1040 <puts@plt>
jmp    1485 <division+0x2f5>
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rdx
mov    %r15d,%esi
mov    %r12d,%ecx
call   10a0 <compare@plt>
cmp    $0x3,%eax
je     1280 <division+0xf0>
cmp    $0x1,%eax
jne    129d <division+0x10d>
lea    0xe23(%rip),%rdi
call   1040 <puts@plt>
lea    0xe25(%rip),%rdi
call   1040 <puts@plt>
test   %r15d,%r15d
js     1485 <division+0x2f5>
mov    %r15d,%eax
lea    (%rsp,%rax,1),%rbx
add    $0x8,%rbx
add    $0x1,%r15d
lea    0xda2(%rip),%r14
xor    %ebp,%ebp
movzbl (%rbx),%esi
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%ebp
add    $0xffffffffffffffff,%rbx
cmp    %ebp,%r15d
jne    1260 <division+0xd0>
jmp    1485 <division+0x2f5>
lea    0xdad(%rip),%rdi
call   1040 <puts@plt>
lea    0xdaf(%rip),%rdi
call   1040 <puts@plt>
jmp    1485 <division+0x2f5>
lea    0x8(%rsp),%rdi
call   1060 <get_highbit@plt>
mov    %eax,%ebx
lea    0x18(%rsp),%rdi
call   1060 <get_highbit@plt>
mov    %r15d,%r14d
sub    %r12d,%r14d
cmp    $0x2,%r14d
mov    %r15,0x30(%rsp)
jl     12cd <division+0x13d>
mov    %rbx,%r15
lea    (%rbx,%r14,8),%r13d
jmp    12db <division+0x14b>
lea    0x8(%rbx),%r13d
test   %r14d,%r14d
mov    %rbx,%r15
cmove  %ebx,%r13d
mov    %eax,0x4(%rsp)
sub    %eax,%r13d
mov    %r12d,%ebp
test   %r13d,%r13d
jle    1312 <division+0x182>
lea    0x18(%rsp),%rbx
mov    %r12d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
call   10b0 <shiftleft@plt>
mov    %eax,%ebp
add    $0xffffffff,%r13d
jne    1300 <division+0x170>
lea    (%r15,%r14,8),%eax
mov    0x4(%rsp),%ecx
cmp    %ecx,%eax
js     13b8 <division+0x228>
mov    %ecx,%eax
mov    0x30(%rsp),%r13
lea    (%r15,%r13,8),%r14d
sub    %ecx,%r14d
shl    $0x3,%r12d
sub    %r12d,%r14d
add    $0x1,%r14d
movl   $0x0,0x4(%rsp)
lea    0x8(%rsp),%r12
lea    0x18(%rsp),%rbx
jmp    1381 <division+0x1f1>
nop
cltq
orb    $0x1,0x26(%rsp,%rax,1)
mov    %r12,%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1050 <deduct@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
mov    %ebp,%esi
call   1080 <shiftright@plt>
mov    %eax,%ebp
add    $0xffffffff,%r14d
lea    0x8(%rsp),%r12
je     13c5 <division+0x235>
mov    %r12,%rdi
mov    %r13d,%esi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   10a0 <compare@plt>
mov    %r13,%r15
mov    %eax,%r13d
lea    0x26(%rsp),%rdi
mov    0x4(%rsp),%esi
call   10b0 <shiftleft@plt>
and    $0xfffffffe,%r13d
cmp    $0x2,%r13d
mov    %eax,0x4(%rsp)
je     1350 <division+0x1c0>
mov    %r15,%r13
jmp    136a <division+0x1da>
movl   $0x0,0x4(%rsp)
mov    0x30(%rsp),%r13
lea    0xc41(%rip),%rdi
call   1040 <puts@plt>
lea    0xc37(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rsp),%r15d
test   %r15d,%r15d
js     142b <division+0x29b>
mov    %r15d,%eax
lea    (%rsp,%rax,1),%rbx
add    $0x26,%rbx
add    $0x1,%r15d
lea    0xc1c(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%esi
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%ebp
add    $0xffffffffffffffff,%rbx
cmp    %ebp,%r15d
jne    1410 <division+0x280>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xbec(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
test   %r13d,%r13d
js     147b <division+0x2eb>
mov    %r13d,%eax
lea    (%rsp,%rax,1),%rbx
add    $0x8,%rbx
add    $0x1,%r13d
lea    0xbbd(%rip),%r14
xor    %ebp,%ebp
movzbl (%rbx),%esi
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%ebp
add    $0xffffffffffffffff,%rbx
cmp    %ebp,%r13d
jne    1460 <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 = [12 x i8] c"reminder: \0A\00"
@.str.3 = [15 x i8] c"+ %d * 256^%d\0A\00"
@.str.4 = [15 x i8] c"quotient is 1\0A\00"
@.str.5 = [16 x i8] c"remainder is 0\0A\00"
@.str.6 = [3 x i8] c"\0A\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)
%29 = load i8*, i8** %6
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 0
%31 = call i32 @bcopy(i8* %29, i8* %30, i32 8)
%32 = load i8*, i8** %8
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%34 = call i32 @bcopy(i8* %32, i8* %33, i32 8)
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %4
%42 = load i32, i32* %9
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = 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 %211
46: ; preds = %41, %4
%47 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 0
%48 = load i32, i32* %7
%49 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%50 = load i32, i32* %9
%51 = call i32 @compare(i8* %47, i32 %48, i8* %49, i32 %50)
store i32 %51, i32* %12
%52 = load i32, i32* %12
switch i32 %52, label %77 [
i32 1, label %53
i32 3, label %74
]
53: ; preds = %46
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%56 = load i32, i32* %7
store i32 %56, i32* %10
store i32 0, i32* %11
br label %57
57: ; preds = %68, %53
%58 = load i32, i32* %10
%59 = icmp sge i32 %58, 0
br i1 %59, label %60, label %73
60: ; preds = %57
%61 = load i32, i32* %10
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = load i32, i32* %11
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %65, i32 %66)
br label %68
68: ; preds = %60
%69 = load i32, i32* %10
%70 = add nsw i32 %69, -1
store i32 %70, i32* %10
%71 = load i32, i32* %11
%72 = add nsw i32 %71, 1
store i32 %72, i32* %11
br label %57
73: ; preds = %57
store i32 1, i32* %5
br label %211
74: ; preds = %46
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %5
br label %211
77: ; preds = %46
%78 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 0
%79 = call i32 @get_highbit(i8* %78)
store i32 %79, i32* %17
%80 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%81 = call i32 @get_highbit(i8* %80)
store i32 %81, i32* %18
%82 = load i32, i32* %7
%83 = load i32, i32* %9
%84 = sub nsw i32 %82, %83
%85 = icmp sge i32 %84, 2
br i1 %85, label %86, label %98
86: ; preds = %77
%87 = load i32, i32* %7
%88 = load i32, i32* %9
%89 = sub nsw i32 %87, %88
%90 = sub nsw i32 %89, 1
%91 = shl i32 %90, 3
store i32 %91, i32* %13
%92 = load i32, i32* %17
%93 = load i32, i32* %18
%94 = sub nsw i32 %92, %93
%95 = add nsw i32 %94, 8
%96 = load i32, i32* %13
%97 = add nsw i32 %96, %95
store i32 %97, i32* %13
br label %113
98: ; preds = %77
%99 = load i32, i32* %7
%100 = load i32, i32* %9
%101 = sub nsw i32 %99, %100
%102 = icmp ne i32 %101, 0
br i1 %102, label %103, label %108
103: ; preds = %98
%104 = load i32, i32* %17
%105 = load i32, i32* %18
%106 = sub nsw i32 %104, %105
%107 = add nsw i32 %106, 8
store i32 %107, i32* %13
br label %112
108: ; preds = %98
%109 = load i32, i32* %17
%110 = load i32, i32* %18
%111 = sub nsw i32 %109, %110
store i32 %111, i32* %13
br label %112
112: ; preds = %108, %103
br label %113
113: ; preds = %112, %86
store i32 0, i32* %10
br label %114
114: ; preds = %122, %113
%115 = load i32, i32* %10
%116 = load i32, i32* %13
%117 = icmp slt i32 %115, %116
br i1 %117, label %118, label %125
118: ; preds = %114
%119 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%120 = load i32, i32* %14
%121 = call i32 @shiftleft(i8* %119, i32 %120)
store i32 %121, i32* %14
br label %122
122: ; preds = %118
%123 = load i32, i32* %10
%124 = add nsw i32 %123, 1
store i32 %124, i32* %10
br label %114
125: ; preds = %114
%126 = load i32, i32* %7
%127 = load i32, i32* %9
%128 = sub nsw i32 %126, %127
%129 = shl i32 %128, 3
%130 = load i32, i32* %17
%131 = add nsw i32 %129, %130
%132 = load i32, i32* %18
%133 = sub nsw i32 %131, %132
store i32 %133, i32* %16
store i32 0, i32* %10
br label %134
134: ; preds = %166, %125
%135 = load i32, i32* %10
%136 = load i32, i32* %16
%137 = icmp sle i32 %135, %136
br i1 %137, label %138, label %169
138: ; preds = %134
%139 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 0
%140 = load i32, i32* %7
%141 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%142 = load i32, i32* %14
%143 = call i32 @compare(i8* %139, i32 %140, i8* %141, i32 %142)
store i32 %143, i32* %12
%144 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 0
%145 = load i32, i32* %15
%146 = call i32 @shiftleft(i8* %144, i32 %145)
store i32 %146, i32* %15
%147 = load i32, i32* %12
switch i32 %147, label %162 [
i32 1, label %148
i32 2, label %149
i32 3, label %149
]
148: ; preds = %138
br label %162
149: ; preds = %138, %138
%150 = load i32, i32* %15
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 %151
%153 = load i8, i8* %152
%154 = zext i8 %153 to i32
%155 = or i32 %154, 1
%156 = trunc i32 %155 to i8
store i8 %156, i8* %152
%157 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 0
%158 = load i32, i32* %7
%159 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%160 = load i32, i32* %14
%161 = call i32 @deduct(i8* %157, i32 %158, i8* %159, i32 %160)
store i32 %161, i32* %7
br label %162
162: ; preds = %138, %149, %148
%163 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%164 = load i32, i32* %14
%165 = call i32 @shiftright(i8* %163, i32 %164)
store i32 %165, i32* %14
br label %166
166: ; preds = %162
%167 = load i32, i32* %10
%168 = add nsw i32 %167, 1
store i32 %168, i32* %10
br label %134
169: ; preds = %134
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%171 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%172 = load i32, i32* %15
store i32 %172, i32* %10
store i32 0, i32* %11
br label %173
173: ; preds = %184, %169
%174 = load i32, i32* %10
%175 = icmp sge i32 %174, 0
br i1 %175, label %176, label %189
176: ; preds = %173
%177 = load i32, i32* %10
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 %178
%180 = load i8, i8* %179
%181 = zext i8 %180 to i32
%182 = load i32, i32* %11
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %181, i32 %182)
br label %184
184: ; preds = %176
%185 = load i32, i32* %10
%186 = add nsw i32 %185, -1
store i32 %186, i32* %10
%187 = load i32, i32* %11
%188 = add nsw i32 %187, 1
store i32 %188, i32* %11
br label %173
189: ; preds = %173
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%192 = load i32, i32* %7
store i32 %192, i32* %10
store i32 0, i32* %11
br label %193
193: ; preds = %204, %189
%194 = load i32, i32* %10
%195 = icmp sge i32 %194, 0
br i1 %195, label %196, label %209
196: ; preds = %193
%197 = load i32, i32* %10
%198 = sext i32 %197 to i64
%199 = getelementptr inbounds [10 x i8], [10 x i8]* %19, i64 0, i64 %198
%200 = load i8, i8* %199
%201 = zext i8 %200 to i32
%202 = load i32, i32* %11
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %201, i32 %202)
br label %204
204: ; preds = %196
%205 = load i32, i32* %10
%206 = add nsw i32 %205, -1
store i32 %206, i32* %10
%207 = load i32, i32* %11
%208 = add nsw i32 %207, 1
store i32 %208, i32* %11
br label %193
209: ; preds = %193
%210 = 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 %211
211: ; preds = %209, %74, %73, %44
%212 = load i32, i32* %5
ret i32 %212
}

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