#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num1 = 0;
  int num2 = 0;
  int counter = 0;
  int divide = 0;
  int negative1 = 0;
  int negative2 = 0;
  int rem = 0;
  printf("Note: Division two negative numbers may take long time\n");
  printf("First Number Divide: ");
  scanf("%d", &num1);
  printf("Second Number Divide: ");
  scanf("%d", &num2);
  if (num1 < 0) {
    num1 = -1 * num1;
    negative1 = 1;
  }
  if (num2 < 0) {
    num2 = -1 * num2;
    negative2 = 1;
  }
  if (num2 == 0) {
    printf("Cant divide by 0");
    return 0;
  }
  divide = num1;
  for (counter = 0; divide > 0; counter++) {
    divide = divide - num2;
  }
  if (divide < 0) {
    divide = divide + num2;
    counter = counter - 1;
  }
  rem = divide;
  if ((negative1 == 0) && (negative2 == 0))
    printf("%d with rem of %d", counter, rem);
  else if ((negative1 == 1) && (negative2 == 0))
    printf("%d with rem of %d", counter * -1, rem);
  else if ((negative1 == 0) && (negative2 == 1))
    printf("%d with rem of %d", counter * -1, rem);
  else
    printf("%d with rem of %d", counter, rem);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    11c5 <main+0xa5>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11e0 <main+0xc0>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1204 <main+0xe4>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12fb <main+0x1db>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1232 <main+0x112>
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1211 <main+0xf1>
cmpl   $0x0,-0x14(%rbp)
jge    124e <main+0x12e>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1281 <main+0x161>
cmpl   $0x0,-0x1c(%rbp)
jne    1281 <main+0x161>
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12fb <main+0x1db>
cmpl   $0x1,-0x18(%rbp)
jne    12af <main+0x18f>
cmpl   $0x0,-0x1c(%rbp)
jne    12af <main+0x18f>
imul   $0xffffffff,-0x10(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f6 <main+0x1d6>
cmpl   $0x0,-0x18(%rbp)
jne    12dd <main+0x1bd>
cmpl   $0x1,-0x1c(%rbp)
jne    12dd <main+0x1bd>
imul   $0xffffffff,-0x10(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f1 <main+0x1d1>
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12f6 <main+0x1d6>
jmp    12fb <main+0x1db>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee7(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebx
mov    %ebx,%eax
test   %ebx,%ebx
jns    11a0 <main+0x70>
mov    %ebx,%eax
neg    %eax
mov    %eax,0xc(%rsp)
test   %ebx,%ebx
setns  %r8b
mov    0x8(%rsp),%edi
mov    %edi,%edx
test   %edi,%edi
js     11c2 <main+0x92>
jne    11c8 <main+0x98>
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    122f <main+0xff>
neg    %edx
mov    %edx,0x8(%rsp)
test   %edi,%edi
setns  %r9b
xor    %esi,%esi
test   %eax,%eax
je     11eb <main+0xbb>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
sub    %edx,%eax
add    $0x1,%esi
test   %eax,%eax
jg     11e0 <main+0xb0>
jmp    11ed <main+0xbd>
xor    %eax,%eax
add    %eax,%edx
xor    %ecx,%ecx
test   %eax,%eax
cmove  %eax,%edx
setne  %cl
sub    %ecx,%esi
mov    %r8d,%eax
and    %r9b,%al
cmp    $0x1,%al
je     1221 <main+0xf1>
test   %ebx,%ebx
sets   %al
and    %r9b,%al
cmp    $0x1,%al
je     121f <main+0xef>
test   %edi,%edi
sets   %al
and    %al,%r8b
cmp    $0x1,%r8b
jne    1221 <main+0xf1>
neg    %esi
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [56 x i8] c"Note: Division two negative numbers may take long time\0A\00"
@.str.1 = [22 x i8] c"First Number Divide: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"Second Number Divide: \00"
@.str.4 = [17 x i8] c"Cant divide by 0\00"
@.str.5 = [18 x i8] c"%d with rem of %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = load i32, i32* %2
%18 = mul nsw i32 -1, %17
store i32 %18, i32* %2
store i32 1, i32* %6
br label %19
19: ; preds = %16, %0
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %3
%24 = mul nsw i32 -1, %23
store i32 %24, i32* %3
store i32 1, i32* %7
br label %25
25: ; preds = %22, %19
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %90
30: ; preds = %25
%31 = load i32, i32* %2
store i32 %31, i32* %5
store i32 0, i32* %4
br label %32
32: ; preds = %39, %30
%33 = load i32, i32* %5
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = load i32, i32* %5
%37 = load i32, i32* %3
%38 = sub nsw i32 %36, %37
store i32 %38, i32* %5
br label %39
39: ; preds = %35
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %32
42: ; preds = %32
%43 = load i32, i32* %5
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = load i32, i32* %5
%47 = load i32, i32* %3
%48 = add nsw i32 %46, %47
store i32 %48, i32* %5
%49 = load i32, i32* %4
%50 = sub nsw i32 %49, 1
store i32 %50, i32* %4
br label %51
51: ; preds = %45, %42
%52 = load i32, i32* %5
store i32 %52, i32* %8
%53 = load i32, i32* %6
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %62
55: ; preds = %51
%56 = load i32, i32* %7
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = load i32, i32* %4
%60 = load i32, i32* %8
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %59, i32 %60)
br label %90
62: ; preds = %55, %51
%63 = load i32, i32* %6
%64 = icmp eq i32 %63, 1
br i1 %64, label %65, label %73
65: ; preds = %62
%66 = load i32, i32* %7
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %73
68: ; preds = %65
%69 = load i32, i32* %4
%70 = mul nsw i32 %69, -1
%71 = load i32, i32* %8
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %70, i32 %71)
br label %89
73: ; preds = %65, %62
%74 = load i32, i32* %6
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %84
76: ; preds = %73
%77 = load i32, i32* %7
%78 = icmp eq i32 %77, 1
br i1 %78, label %79, label %84
79: ; preds = %76
%80 = load i32, i32* %4
%81 = mul nsw i32 %80, -1
%82 = load i32, i32* %8
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %81, i32 %82)
br label %88
84: ; preds = %76, %73
%85 = load i32, i32* %4
%86 = load i32, i32* %8
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %85, i32 %86)
br label %88
88: ; preds = %84, %79
br label %89
89: ; preds = %88, %68
br label %90
90: ; preds = %28, %89, %58
%91 = load i32, i32* %1
ret i32 %91
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"First Number Divide: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [23 x i8] c"Second Number Divide: \00"
@.str.4 = [17 x i8] c"Cant divide by 0\00"
@.str.5 = [18 x i8] c"%d with rem of %d\00"
@str = [55 x i8] c"Note: Division two negative numbers may take long time\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = sub nsw i32 0, %10
store i32 %13, i32* %1
br label %14
14: ; preds = %12, %0
%15 = phi i32 [ %13, %12 ], [ %10, %0 ]
%16 = xor i1 %11, true
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = sub nsw i32 0, %17
store i32 %20, i32* %2
br label %25
21: ; preds = %14
%22 = icmp eq i32 %17, 0
br i1 %22, label %23, label %25
23: ; preds = %21
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %59
25: ; preds = %19, %21
%26 = phi i32 [ %20, %19 ], [ %17, %21 ]
%27 = xor i1 %18, true
%28 = icmp eq i32 %15, 0
br i1 %28, label %35, label %29
29: ; preds = %25, %29
%30 = phi i32 [ %32, %29 ], [ %15, %25 ]
%31 = phi i32 [ %33, %29 ], [ 0, %25 ]
%32 = sub nsw i32 %30, %26
%33 = add nuw nsw i32 %31, 1
%34 = icmp sgt i32 %32, 0
br i1 %34, label %29, label %35
35: ; preds = %29, %25
%36 = phi i32 [ 0, %25 ], [ %33, %29 ]
%37 = phi i32 [ 0, %25 ], [ %32, %29 ]
%38 = icmp eq i32 %37, 0
%39 = add nsw i32 %37, %26
%40 = xor i1 %38, true
%41 = sext i1 %40 to i32
%42 = add nsw i32 %36, %41
%43 = select i1 %38, i32 0, i32 %39
%44 = select i1 %16, i1 %27, i1 false
br i1 %44, label %45, label %47
45: ; preds = %35
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %42, i32 %43)
br label %59
47: ; preds = %35
%48 = select i1 %11, i1 %27, i1 false
br i1 %48, label %49, label %52
49: ; preds = %47
%50 = sub nsw i32 0, %42
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %50, i32 %43)
br label %59
52: ; preds = %47
%53 = select i1 %16, i1 %18, i1 false
br i1 %53, label %54, label %57
54: ; preds = %52
%55 = sub nsw i32 0, %42
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %55, i32 %43)
br label %59
57: ; preds = %52
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %42, i32 %43)
br label %59
59: ; preds = %45, %54, %57, %49, %23
ret i32 0
}