#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*/ subres;
typedef int /*<<< orphan*/ multires;
typedef int /*<<< orphan*/ min;
typedef int /*<<< orphan*/ max;
typedef int /*<<< orphan*/ addres;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int addition(unsigned char *, int, unsigned char *, int, unsigned char *);
int /*<<< orphan*/ bcopy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ bzero(unsigned char *, int);
int compare(unsigned char *, int, unsigned char *, int);
int multiplication(unsigned char *, int, unsigned char *, int, unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
int shiftright(unsigned char *, int);
int subtraction(unsigned char *, int, unsigned char *, int, unsigned char *);
int mydivision(unsigned char *a, int a_len, unsigned char *b, int b_len) {
  int mul_len, comp, sublen, shilen, addlen;
  int time = 0;
  int i, j, k;
  int max_len = a_len, min_len = 0;
  unsigned char max[20], min[20];
  unsigned char multires[20];
  unsigned char subres[20];
  unsigned char addres[20];
  bzero(max, sizeof(max));
  bzero(min, sizeof(min));
  bzero(multires, sizeof(multires));
  bzero(subres, sizeof(subres));
  bzero(addres, sizeof(addres));
  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("reminder[ %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;
  }
  bcopy(a, max, sizeof(a));
  while (1) {
    time++;
    sublen = subtraction(max, max_len, min, min_len, subres);
    shilen = shiftright(subres, sublen);
    addlen = addition(subres, shilen, min, min_len, addres);
    mul_len = multiplication(addres, addlen, b, b_len, multires);
    comp = compare(a, a_len, multires, mul_len);
    switch (comp) {
    case 1:
      bzero(max, sizeof(max));
      for (i = 0; i <= addlen; i++)
        max[i] = addres[i];
      max_len = addlen;
      break;
    case 2:
      sublen = subtraction(a, a_len, multires, mul_len, subres);
      comp = compare(subres, sublen, b, b_len);
      switch (comp) {
      case 1:
        printf("quotient:  ");
        for (i = 0; i <= addlen; i++)
          printf("+%d * 256^%d", addres[i], i);
        printf("\nremainder:  ");
        for (i = 0; i <= sublen; i++)
          printf("+%d * 256^%d", subres[i], i);
        printf("\n");
        printf("iteration is %d\n", time);
        return 1;
      case 2:
      case 3:
        bzero(min, sizeof(min));
        for (i = 0; i <= addlen; i++)
          min[i] = addres[i];
        min_len = addlen;
        break;
      }
      break;
    case 3:
      for (i = 0; i <= addlen; i++)
        printf("+%d * 256^%d\n", addres[i], i);
      printf("remainder is 0.\n");
      printf("iteration is %d\n", time);
      return 1;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<mydivision>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x14,%esi
call   1090 <bzero@plt>
lea    -0x90(%rbp),%rdi
mov    $0x14,%esi
call   1090 <bzero@plt>
lea    -0xb0(%rbp),%rdi
mov    $0x14,%esi
call   1090 <bzero@plt>
lea    -0xd0(%rbp),%rdi
mov    $0x14,%esi
call   1090 <bzero@plt>
lea    -0xf0(%rbp),%rdi
mov    $0x14,%esi
call   1090 <bzero@plt>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1233 <mydivision+0xb3>
cmpl   $0x0,-0x24(%rbp)
jne    1233 <mydivision+0xb3>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    163a <mydivision+0x4ba>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   10a0 <compare@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0xf4(%rbp)
sub    $0x1,%eax
je     1274 <mydivision+0xf4>
jmp    1260 <mydivision+0xe0>
mov    -0xf4(%rbp),%eax
sub    $0x3,%eax
je     12cf <mydivision+0x14f>
jmp    12f7 <mydivision+0x177>
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     12c3 <mydivision+0x143>
mov    -0x40(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
mov    -0x40(%rbp),%ecx
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1289 <mydivision+0x109>
movl   $0x1,-0x4(%rbp)
jmp    163a <mydivision+0x4ba>
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    163a <mydivision+0x4ba>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rsi
mov    $0x8,%edx
call   1070 <bcopy@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x4c(%rbp),%esi
mov    -0x50(%rbp),%ecx
lea    -0x70(%rbp),%rdi
lea    -0x90(%rbp),%rdx
mov    %rdx,-0x110(%rbp)
lea    -0xd0(%rbp),%r8
mov    %r8,-0x118(%rbp)
call   1060 <subtraction@plt>
mov    -0x118(%rbp),%rdi
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
call   1080 <shiftright@plt>
mov    -0x118(%rbp),%rdi
mov    -0x110(%rbp),%rdx
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
mov    -0x50(%rbp),%ecx
lea    -0xf0(%rbp),%r8
mov    %r8,-0x108(%rbp)
call   1030 <addition@plt>
mov    -0x108(%rbp),%rdi
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    -0xb0(%rbp),%r8
mov    %r8,-0x100(%rbp)
call   1040 <multiplication@plt>
mov    -0x100(%rbp),%rdx
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%ecx
call   10a0 <compare@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0xf8(%rbp)
sub    $0x1,%eax
je     13fb <mydivision+0x27b>
jmp    13d3 <mydivision+0x253>
mov    -0xf8(%rbp),%eax
sub    $0x2,%eax
je     1448 <mydivision+0x2c8>
jmp    13e7 <mydivision+0x267>
mov    -0xf8(%rbp),%eax
sub    $0x3,%eax
je     15cc <mydivision+0x44c>
jmp    1635 <mydivision+0x4b5>
lea    -0x70(%rbp),%rdi
mov    $0x14,%esi
call   1090 <bzero@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x38(%rbp),%eax
jg     143d <mydivision+0x2bd>
movslq -0x40(%rbp),%rax
mov    -0xf0(%rbp,%rax,1),%cl
movslq -0x40(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1410 <mydivision+0x290>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1635 <mydivision+0x4b5>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x28(%rbp),%ecx
lea    -0xb0(%rbp),%rdx
lea    -0xd0(%rbp),%r8
mov    %r8,-0x128(%rbp)
call   1060 <subtraction@plt>
mov    -0x128(%rbp),%rdi
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   10a0 <compare@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x11c(%rbp)
sub    $0x1,%eax
je     14b6 <mydivision+0x336>
jmp    149f <mydivision+0x31f>
mov    -0x11c(%rbp),%eax
add    $0xfffffffe,%eax
sub    $0x2,%eax
jb     1579 <mydivision+0x3f9>
jmp    15c7 <mydivision+0x447>
lea    0xbaf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x38(%rbp),%eax
jg     1502 <mydivision+0x382>
movslq -0x40(%rbp),%rax
movzbl -0xf0(%rbp,%rax,1),%esi
ff
mov    -0x40(%rbp),%edx
lea    0xb8b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    14cb <mydivision+0x34b>
lea    0xb7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x30(%rbp),%eax
jg     154e <mydivision+0x3ce>
movslq -0x40(%rbp),%rax
movzbl -0xd0(%rbp,%rax,1),%esi
ff
mov    -0x40(%rbp),%edx
lea    0xb3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1517 <mydivision+0x397>
lea    0xb6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xb2d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    163a <mydivision+0x4ba>
lea    -0x90(%rbp),%rdi
mov    $0x14,%esi
call   1090 <bzero@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x38(%rbp),%eax
jg     15c1 <mydivision+0x441>
movslq -0x40(%rbp),%rax
mov    -0xf0(%rbp,%rax,1),%cl
movslq -0x40(%rbp),%rax
mov    %cl,-0x90(%rbp,%rax,1)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1591 <mydivision+0x411>
mov    -0x38(%rbp),%eax
mov    %eax,-0x50(%rbp)
jmp    1635 <mydivision+0x4b5>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x38(%rbp),%eax
jg     160a <mydivision+0x48a>
movslq -0x40(%rbp),%rax
movzbl -0xf0(%rbp,%rax,1),%esi
ff
mov    -0x40(%rbp),%edx
lea    0xaaf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    15d3 <mydivision+0x453>
lea    0xaa1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xa71(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    163a <mydivision+0x4ba>
jmp    1309 <mydivision+0x189>
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mydivision>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %ecx,%r12d
mov    %rdx,%r14
mov    %esi,%r13d
mov    %rdi,%rbx
lea    0x80(%rsp),%rdi
mov    $0x14,%esi
call   10b0 <bzero@plt>
lea    0x60(%rsp),%rdi
mov    $0x14,%esi
call   10b0 <bzero@plt>
lea    0xa0(%rsp),%rdi
mov    $0x14,%esi
call   10b0 <bzero@plt>
lea    0x20(%rsp),%rdi
mov    $0x14,%esi
call   10b0 <bzero@plt>
lea    0x40(%rsp),%rdi
mov    $0x14,%esi
call   10b0 <bzero@plt>
test   %r12d,%r12d
jne    1222 <mydivision+0x82>
cmpb   $0x0,(%r14)
jne    1222 <mydivision+0x82>
lea    0xe81(%rip),%rdi
jmp    1293 <mydivision+0xf3>
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r14,%rdx
mov    %r12d,%ecx
call   10c0 <compare@plt>
cmp    $0x3,%eax
je     1280 <mydivision+0xe0>
cmp    $0x1,%eax
jne    129d <mydivision+0xfd>
lea    0xe3f(%rip),%rdi
call   1050 <puts@plt>
test   %r13d,%r13d
js     1536 <mydivision+0x396>
add    $0x1,%r13d
lea    0xda3(%rip),%r14
xor    %ebp,%ebp
nop
movzbl (%rbx,%rbp,1),%edx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1260 <mydivision+0xc0>
jmp    1536 <mydivision+0x396>
lea    0xddf(%rip),%rdi
call   1050 <puts@plt>
lea    0xde1(%rip),%rdi
call   1050 <puts@plt>
jmp    1536 <mydivision+0x396>
mov    %rbx,0x58(%rsp)
mov    (%rbx),%rax
mov    %rax,0x80(%rsp)
xor    %ebx,%ebx
lea    0x20(%rsp),%r15
mov    %r13d,%eax
mov    %r13d,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    %r13,0x18(%rsp)
add    $0x1,%ebx
mov    %ebx,0x4(%rsp)
jmp    12ea <mydivision+0x14a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addl   $0x1,0x4(%rsp)
lea    0x20(%rsp),%r15
lea    0x80(%rsp),%rdi
mov    0xc(%rsp),%esi
lea    0x60(%rsp),%rbp
mov    %rbp,%rdx
mov    0x8(%rsp),%ebx
mov    %ebx,%ecx
mov    %r15,%r8
call   1090 <subtraction@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   10a0 <shiftright@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    %rbp,%rdx
mov    %ebx,%ecx
lea    0x40(%rsp),%rbp
mov    %rbp,%r8
call   1040 <addition@plt>
mov    %rbp,%rdi
mov    %rax,0x10(%rsp)
mov    %eax,%esi
mov    %r14,%rdx
mov    %r12d,%ecx
lea    0xa0(%rsp),%rbx
mov    %rbx,%r8
call   1060 <multiplication@plt>
mov    %eax,%ebp
mov    %r14,%r13
mov    0x58(%rsp),%r14
mov    %r14,%rdi
mov    0x18(%rsp),%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   10c0 <compare@plt>
cmp    $0x2,%eax
je     1390 <mydivision+0x1f0>
cmp    $0x1,%eax
je     1408 <mydivision+0x268>
cmp    $0x3,%eax
mov    %r13,%r14
jne    12e0 <mydivision+0x140>
jmp    1454 <mydivision+0x2b4>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    0x18(%rsp),%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
mov    %r15,%r8
call   1090 <subtraction@plt>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %eax,%esi
mov    %r13,%rdx
mov    %r12d,%ecx
call   10c0 <compare@plt>
lea    -0x2(%rax),%ecx
cmp    $0x2,%ecx
mov    %r13,%r14
jb     13d0 <mydivision+0x230>
cmp    $0x1,%eax
jne    12e0 <mydivision+0x140>
jmp    149b <mydivision+0x2fb>
lea    0x60(%rsp),%rdi
mov    $0x14,%esi
call   10b0 <bzero@plt>
mov    0x10(%rsp),%rax
mov    %eax,%ecx
mov    %eax,0x8(%rsp)
test   %eax,%eax
mov    0x4(%rsp),%ebx
lea    0x20(%rsp),%r15
js     12c9 <mydivision+0x129>
lea    0x60(%rsp),%rbp
mov    %eax,%ecx
mov    %eax,0x8(%rsp)
jmp    143c <mydivision+0x29c>
lea    0x80(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x14,%esi
call   10b0 <bzero@plt>
mov    0x10(%rsp),%rax
mov    %eax,%ecx
mov    %eax,0xc(%rsp)
test   %eax,%eax
mov    %r13,%r14
lea    0x20(%rsp),%r15
mov    0x4(%rsp),%ebx
js     12c9 <mydivision+0x129>
mov    %eax,%edx
add    $0x1,%rdx
mov    %rbp,%rdi
lea    0x40(%rsp),%rsi
call   1080 <memcpy@plt>
jmp    12c9 <mydivision+0x129>
mov    0x10(%rsp),%r15
test   %r15d,%r15d
js     148a <mydivision+0x2ea>
add    $0x1,%r15d
lea    0xbef(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl 0x40(%rsp,%rbp,1),%esi
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1470 <mydivision+0x2d0>
lea    0xc00(%rip),%rdi
call   1050 <puts@plt>
jmp    1524 <mydivision+0x384>
lea    0xb7e(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%r12
test   %r12d,%r12d
js     14da <mydivision+0x33a>
add    $0x1,%r12d
lea    0xb6e(%rip),%r14
xor    %ebp,%ebp
movzbl 0x40(%rsp,%rbp,1),%esi
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    14c0 <mydivision+0x320>
lea    0xb58(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
test   %ebx,%ebx
js     151a <mydivision+0x37a>
add    $0x1,%ebx
lea    0xb36(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl 0x20(%rsp,%rbp,1),%esi
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1500 <mydivision+0x360>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xb1c(%rip),%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%eax
add    $0xb8,%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 = [32 x i8] c"reminder[ %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 = [12 x i8] c"quotient: \00"
@.str.6 = [13 x i8] c"+%d * 256^%d\00"
@.str.7 = [14 x i8] c"\0Aremainder: \00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [17 x i8] c"iteration is %d\0A\00"
@.str.10 = [14 x i8] c"+%d * 256^%d\0A\00"
@.str.11 = [17 x i8] c"remainder is 0.\0A\00"
define i32 @mydivision(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 i32
%20 = alloca i32
%21 = alloca [20 x i8]
%22 = alloca [20 x i8]
%23 = alloca [20 x i8]
%24 = alloca [20 x i8]
%25 = alloca [20 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* %15
%26 = load i32, i32* %7
store i32 %26, i32* %19
store i32 0, i32* %20
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %21, i64 0, i64 0
%28 = call i32 @bzero(i8* %27, i32 20)
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %22, i64 0, i64 0
%30 = call i32 @bzero(i8* %29, i32 20)
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %23, i64 0, i64 0
%32 = call i32 @bzero(i8* %31, i32 20)
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %24, i64 0, i64 0
%34 = call i32 @bzero(i8* %33, i32 20)
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %25, i64 0, i64 0
%36 = call i32 @bzero(i8* %35, i32 20)
%37 = load i8*, i8** %8
%38 = getelementptr inbounds i8, i8* %37, i64 0
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %4
%43 = load i32, i32* %9
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = 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 %224
47: ; preds = %42, %4
%48 = load i8*, i8** %6
%49 = load i32, i32* %7
%50 = load i8*, i8** %8
%51 = load i32, i32* %9
%52 = call i32 @compare(i8* %48, i32 %49, i8* %50, i32 %51)
store i32 %52, i32* %11
%53 = load i32, i32* %11
switch i32 %53, label %77 [
i32 1, label %54
i32 3, label %74
]
54: ; preds = %47
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %16
br label %56
56: ; preds = %70, %54
%57 = load i32, i32* %16
%58 = load i32, i32* %7
%59 = icmp sle i32 %57, %58
br i1 %59, label %60, label %73
60: ; preds = %56
%61 = load i32, i32* %16
%62 = load i8*, i8** %6
%63 = load i32, i32* %16
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = load i8, i8* %65
%67 = zext i8 %66 to i32
%68 = load i32, i32* %16
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %61, i32 %67, i32 %68)
br label %70
70: ; preds = %60
%71 = load i32, i32* %16
%72 = add nsw i32 %71, 1
store i32 %72, i32* %16
br label %56
73: ; preds = %56
store i32 1, i32* %5
br label %224
74: ; preds = %47
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%76 = 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 %224
77: ; preds = %47
%78 = load i8*, i8** %6
%79 = getelementptr inbounds [20 x i8], [20 x i8]* %21, i64 0, i64 0
%80 = call i32 @bcopy(i8* %78, i8* %79, i32 8)
br label %81
81: ; preds = %77, %223
%82 = load i32, i32* %15
%83 = add nsw i32 %82, 1
store i32 %83, i32* %15
%84 = getelementptr inbounds [20 x i8], [20 x i8]* %21, i64 0, i64 0
%85 = load i32, i32* %19
%86 = getelementptr inbounds [20 x i8], [20 x i8]* %22, i64 0, i64 0
%87 = load i32, i32* %20
%88 = getelementptr inbounds [20 x i8], [20 x i8]* %24, i64 0, i64 0
%89 = call i32 @subtraction(i8* %84, i32 %85, i8* %86, i32 %87, i8* %88)
store i32 %89, i32* %12
%90 = getelementptr inbounds [20 x i8], [20 x i8]* %24, i64 0, i64 0
%91 = load i32, i32* %12
%92 = call i32 @shiftright(i8* %90, i32 %91)
store i32 %92, i32* %13
%93 = getelementptr inbounds [20 x i8], [20 x i8]* %24, i64 0, i64 0
%94 = load i32, i32* %13
%95 = getelementptr inbounds [20 x i8], [20 x i8]* %22, i64 0, i64 0
%96 = load i32, i32* %20
%97 = getelementptr inbounds [20 x i8], [20 x i8]* %25, i64 0, i64 0
%98 = call i32 @addition(i8* %93, i32 %94, i8* %95, i32 %96, i8* %97)
store i32 %98, i32* %14
%99 = getelementptr inbounds [20 x i8], [20 x i8]* %25, i64 0, i64 0
%100 = load i32, i32* %14
%101 = load i8*, i8** %8
%102 = load i32, i32* %9
%103 = getelementptr inbounds [20 x i8], [20 x i8]* %23, i64 0, i64 0
%104 = call i32 @multiplication(i8* %99, i32 %100, i8* %101, i32 %102, i8* %103)
store i32 %104, i32* %10
%105 = load i8*, i8** %6
%106 = load i32, i32* %7
%107 = getelementptr inbounds [20 x i8], [20 x i8]* %23, i64 0, i64 0
%108 = load i32, i32* %10
%109 = call i32 @compare(i8* %105, i32 %106, i8* %107, i32 %108)
store i32 %109, i32* %11
%110 = load i32, i32* %11
switch i32 %110, label %223 [
i32 1, label %111
i32 2, label %131
i32 3, label %203
]
111: ; preds = %81
%112 = getelementptr inbounds [20 x i8], [20 x i8]* %21, i64 0, i64 0
%113 = call i32 @bzero(i8* %112, i32 20)
store i32 0, i32* %16
br label %114
114: ; preds = %126, %111
%115 = load i32, i32* %16
%116 = load i32, i32* %14
%117 = icmp sle i32 %115, %116
br i1 %117, label %118, label %129
118: ; preds = %114
%119 = load i32, i32* %16
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [20 x i8], [20 x i8]* %25, i64 0, i64 %120
%122 = load i8, i8* %121
%123 = load i32, i32* %16
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds [20 x i8], [20 x i8]* %21, i64 0, i64 %124
store i8 %122, i8* %125
br label %126
126: ; preds = %118
%127 = load i32, i32* %16
%128 = add nsw i32 %127, 1
store i32 %128, i32* %16
br label %114
129: ; preds = %114
%130 = load i32, i32* %14
store i32 %130, i32* %19
br label %223
131: ; preds = %81
%132 = load i8*, i8** %6
%133 = load i32, i32* %7
%134 = getelementptr inbounds [20 x i8], [20 x i8]* %23, i64 0, i64 0
%135 = load i32, i32* %10
%136 = getelementptr inbounds [20 x i8], [20 x i8]* %24, i64 0, i64 0
%137 = call i32 @subtraction(i8* %132, i32 %133, i8* %134, i32 %135, i8* %136)
store i32 %137, i32* %12
%138 = getelementptr inbounds [20 x i8], [20 x i8]* %24, i64 0, i64 0
%139 = load i32, i32* %12
%140 = load i8*, i8** %8
%141 = load i32, i32* %9
%142 = call i32 @compare(i8* %138, i32 %139, i8* %140, i32 %141)
store i32 %142, i32* %11
%143 = load i32, i32* %11
switch i32 %143, label %202 [
i32 1, label %144
i32 2, label %182
i32 3, label %182
]
144: ; preds = %131
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %16
br label %146
146: ; preds = %158, %144
%147 = load i32, i32* %16
%148 = load i32, i32* %14
%149 = icmp sle i32 %147, %148
br i1 %149, label %150, label %161
150: ; preds = %146
%151 = load i32, i32* %16
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds [20 x i8], [20 x i8]* %25, i64 0, i64 %152
%154 = load i8, i8* %153
%155 = zext i8 %154 to i32
%156 = load i32, i32* %16
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %155, i32 %156)
br label %158
158: ; preds = %150
%159 = load i32, i32* %16
%160 = add nsw i32 %159, 1
store i32 %160, i32* %16
br label %146
161: ; preds = %146
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %16
br label %163
163: ; preds = %175, %161
%164 = load i32, i32* %16
%165 = load i32, i32* %12
%166 = icmp sle i32 %164, %165
br i1 %166, label %167, label %178
167: ; preds = %163
%168 = load i32, i32* %16
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds [20 x i8], [20 x i8]* %24, i64 0, i64 %169
%171 = load i8, i8* %170
%172 = zext i8 %171 to i32
%173 = load i32, i32* %16
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %172, i32 %173)
br label %175
175: ; preds = %167
%176 = load i32, i32* %16
%177 = add nsw i32 %176, 1
store i32 %177, i32* %16
br label %163
178: ; preds = %163
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%180 = load i32, i32* %15
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %180)
store i32 1, i32* %5
br label %224
182: ; preds = %131, %131
%183 = getelementptr inbounds [20 x i8], [20 x i8]* %22, i64 0, i64 0
%184 = call i32 @bzero(i8* %183, i32 20)
store i32 0, i32* %16
br label %185
185: ; preds = %197, %182
%186 = load i32, i32* %16
%187 = load i32, i32* %14
%188 = icmp sle i32 %186, %187
br i1 %188, label %189, label %200
189: ; preds = %185
%190 = load i32, i32* %16
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds [20 x i8], [20 x i8]* %25, i64 0, i64 %191
%193 = load i8, i8* %192
%194 = load i32, i32* %16
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds [20 x i8], [20 x i8]* %22, i64 0, i64 %195
store i8 %193, i8* %196
br label %197
197: ; preds = %189
%198 = load i32, i32* %16
%199 = add nsw i32 %198, 1
store i32 %199, i32* %16
br label %185
200: ; preds = %185
%201 = load i32, i32* %14
store i32 %201, i32* %20
br label %202
202: ; preds = %131, %200
br label %223
203: ; preds = %81
store i32 0, i32* %16
br label %204
204: ; preds = %216, %203
%205 = load i32, i32* %16
%206 = load i32, i32* %14
%207 = icmp sle i32 %205, %206
br i1 %207, label %208, label %219
208: ; preds = %204
%209 = load i32, i32* %16
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds [20 x i8], [20 x i8]* %25, i64 0, i64 %210
%212 = load i8, i8* %211
%213 = zext i8 %212 to i32
%214 = load i32, i32* %16
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i32 %213, i32 %214)
br label %216
216: ; preds = %208
%217 = load i32, i32* %16
%218 = add nsw i32 %217, 1
store i32 %218, i32* %16
br label %204
219: ; preds = %204
%220 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0))
%221 = load i32, i32* %15
%222 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %221)
store i32 1, i32* %5
br label %224
223: ; preds = %81, %202, %129
br label %81
224: ; preds = %219, %178, %74, %73, %45
%225 = load i32, i32* %5
ret i32 %225
}

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