#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ atoll(char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int main(int argc, char *argv[]) {
  unsigned int dividend = (unsigned int)atoll(argv[1]);
  unsigned int divisor = (unsigned int)atoll(argv[2]);
  unsigned int quotient = 0;
  unsigned int remainder = 0;
  int bit;
  for (bit = 31; bit >= 0; bit--) {
    remainder = remainder << 1;
    if (((dividend >> bit) & 1) == 1) {
      remainder |= 1;
    } else if (((dividend >> bit) & 1) == 0) {
      remainder &= ~1;
    }
    if (remainder >= divisor) {
      remainder -= divisor;
      quotient |= 1 << bit;
    }
  }
  printf(" %u / ", dividend);
  printf("%u ", divisor);
  printf(" =  %u ", quotient);
  printf(" R %u \n", remainder);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoll@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoll@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x1f,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     11fc <main+0xdc>
mov    -0x20(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x24(%rbp),%ecx
shr    %cl,%eax
and    $0x1,%eax
cmp    $0x1,%eax
jne    11a0 <main+0x80>
mov    -0x20(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c2 <main+0xa2>
mov    -0x14(%rbp),%eax
mov    -0x24(%rbp),%ecx
shr    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11bd <main+0x9d>
mov    -0x20(%rbp),%eax
and    $0xfffffffe,%eax
mov    %eax,-0x20(%rbp)
jmp    11c2 <main+0xa2>
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jb     11e9 <main+0xc9>
mov    -0x18(%rbp),%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11ee <main+0xce>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    116b <main+0x4b>
mov    -0x14(%rbp),%esi
lea    0xdfa(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdf6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xde3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xddc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1040 <atoll@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
call   1040 <atoll@plt>
mov    %rax,%r15
xor    %ebx,%ebx
mov    $0x1f,%ecx
xor    %ebp,%ebp
jmp    1159 <main+0x39>
nopl   (%rax)
or     %eax,%ebp
sub    %esi,%ebx
sub    $0x1,%ecx
jb     11ae <main+0x8e>
mov    $0x1,%edx
shl    %cl,%edx
mov    %r14d,%eax
shr    %cl,%eax
and    $0x1,%eax
lea    (%rax,%rbx,2),%eax
mov    $0x0,%esi
mov    $0x0,%edi
cmp    %r15d,%eax
jb     117f <main+0x5f>
mov    %edx,%esi
mov    %r15d,%edi
or     %esi,%ebp
sub    %edi,%eax
add    $0xffffffff,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %r14d,%esi
shr    %cl,%esi
and    $0x1,%esi
lea    (%rsi,%rax,2),%ebx
mov    $0x0,%eax
mov    $0x0,%esi
cmp    %r15d,%ebx
jb     1150 <main+0x30>
mov    %edx,%eax
mov    %r15d,%esi
jmp    1150 <main+0x30>
lea    0xe4b(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
lea    0xe34(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0xe2e(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c" %u / \00"
@.str.1 = [4 x i8] c"%u \00"
@.str.2 = [8 x i8] c" = %u \00"
@.str.3 = [8 x i8] c" R %u \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @atoll(i8* %13)
%15 = trunc i64 %14 to i32
store i32 %15, i32* %6
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i64 @atoll(i8* %18)
%20 = trunc i64 %19 to i32
store i32 %20, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 31, i32* %10
br label %21
21: ; preds = %58, %2
%22 = load i32, i32* %10
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %61
24: ; preds = %21
%25 = load i32, i32* %9
%26 = shl i32 %25, 1
store i32 %26, i32* %9
%27 = load i32, i32* %6
%28 = load i32, i32* %10
%29 = lshr i32 %27, %28
%30 = and i32 %29, 1
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %35
32: ; preds = %24
%33 = load i32, i32* %9
%34 = or i32 %33, 1
store i32 %34, i32* %9
br label %45
35: ; preds = %24
%36 = load i32, i32* %6
%37 = load i32, i32* %10
%38 = lshr i32 %36, %37
%39 = and i32 %38, 1
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = load i32, i32* %9
%43 = and i32 %42, -2
store i32 %43, i32* %9
br label %44
44: ; preds = %41, %35
br label %45
45: ; preds = %44, %32
%46 = load i32, i32* %9
%47 = load i32, i32* %7
%48 = icmp uge i32 %46, %47
br i1 %48, label %49, label %57
49: ; preds = %45
%50 = load i32, i32* %7
%51 = load i32, i32* %9
%52 = sub i32 %51, %50
store i32 %52, i32* %9
%53 = load i32, i32* %10
%54 = shl i32 1, %53
%55 = load i32, i32* %8
%56 = or i32 %55, %54
store i32 %56, i32* %8
br label %57
57: ; preds = %49, %45
br label %58
58: ; preds = %57
%59 = load i32, i32* %10
%60 = add nsw i32 %59, -1
store i32 %60, i32* %10
br label %21
61: ; preds = %21
%62 = load i32, i32* %6
%63 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %7
%65 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %64)
%66 = load i32, i32* %8
%67 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %66)
%68 = load i32, i32* %9
%69 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %68)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c" %u / \00"
@.str.1 = [4 x i8] c"%u \00"
@.str.2 = [8 x i8] c" = %u \00"
@.str.3 = [8 x i8] c" R %u \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i64 @atoll(i8* %4)
%6 = trunc i64 %5 to i32
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i64 @atoll(i8* %8)
%10 = trunc i64 %9 to i32
br label %11
11: ; preds = %11, %2
%12 = phi i32 [ 31, %2 ], [ %36, %11 ]
%13 = phi i32 [ 0, %2 ], [ %35, %11 ]
%14 = phi i32 [ 0, %2 ], [ %33, %11 ]
%15 = shl i32 %13, 1
%16 = shl nuw i32 1, %12
%17 = lshr i32 %6, %12
%18 = and i32 %17, 1
%19 = or i32 %18, %15
%20 = icmp ult i32 %19, %10
%21 = select i1 %20, i32 0, i32 %16
%22 = or i32 %21, %14
%23 = select i1 %20, i32 0, i32 %10
%24 = sub i32 %19, %23
%25 = add nsw i32 %12, -1
%26 = shl i32 %24, 1
%27 = shl nuw i32 1, %25
%28 = lshr i32 %6, %25
%29 = and i32 %28, 1
%30 = or i32 %29, %26
%31 = icmp ult i32 %30, %10
%32 = select i1 %31, i32 0, i32 %27
%33 = or i32 %32, %22
%34 = select i1 %31, i32 0, i32 %10
%35 = sub i32 %30, %34
%36 = add nsw i32 %12, -2
%37 = icmp eq i32 %25, 0
br i1 %37, label %38, label %11
38: ; preds = %11
%39 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %6)
%40 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%41 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%42 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %35)
ret i32 0
}