#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 atoi(char *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int dd = 0, r = 0, dr = 0, q = 0;
  if (argc != 3)
    return 0;
  dd = atoi(argv[1]);
  dr = atoi(argv[2]);
  printf("divident = %d\n", dd);
  printf("divisor = %d\n", dr);
  int tmp = 0;
  int dr_zero_flag = 0;
  while (dd) {
    dd--;
    dr--;
    r++;
    dr_zero_flag++;
    tmp = dr;
    while (tmp) {
      tmp--;
      dr_zero_flag = 0;
    }
    while (dr_zero_flag) {
      dr = r;
      r = 0;
      q++;
      dr_zero_flag--;
      printf("%d\n", dd);
    }
  }
  printf("q = %d\n", q);
  printf("r = %d\n", r);
  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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1168 <main+0x48>
movl   $0x0,-0x4(%rbp)
jmp    1273 <main+0x153>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     124e <main+0x12e>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1207 <main+0xe7>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
jmp    11e8 <main+0xc8>
jmp    120c <main+0xec>
cmpl   $0x0,-0x28(%rbp)
je     1249 <main+0x129>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
lea    0xde2(%rip),%rdi
call   1030 <printf@plt>
jmp    120c <main+0xec>
jmp    11b4 <main+0x94>
mov    -0x20(%rbp),%esi
lea    0xdc5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdae(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x3,%edi
jne    11db <main+0xbb>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebp
lea    0xeaf(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
test   %ebx,%ebx
je     11af <main+0x8f>
add    $0xffffffff,%ebx
xor    %r14d,%r14d
lea    0xeaa(%rip),%r15
xor    %r12d,%r12d
jmp    1196 <main+0x76>
nopl   0x0(%rax)
add    $0x1,%r14d
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %r12d,%r12d
add    $0xffffffff,%ebx
jae    11b5 <main+0x95>
mov    %ebp,%eax
mov    %r12d,%ebp
add    $0x1,%ebp
add    $0xffffffff,%eax
je     1180 <main+0x60>
mov    %ebp,%r12d
mov    %eax,%ebp
add    $0xffffffff,%ebx
jb     1196 <main+0x76>
jmp    11b5 <main+0x95>
xor    %r12d,%r12d
xor    %r14d,%r14d
lea    0xe61(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [15 x i8] c"divident = %d\0A\00"
@.str.1 = [14 x i8] c"divisor = %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [8 x i8] c"q = %d\0A\00"
@.str.4 = [8 x i8] c"r = %d\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
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 3
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 0, i32* %3
br label %65
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %8
%24 = load i32, i32* %6
%25 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %8
%27 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %26)
store i32 0, i32* %10
store i32 0, i32* %11
br label %28
28: ; preds = %59, %15
%29 = load i32, i32* %6
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %60
31: ; preds = %28
%32 = load i32, i32* %6
%33 = add nsw i32 %32, -1
store i32 %33, i32* %6
%34 = load i32, i32* %8
%35 = add nsw i32 %34, -1
store i32 %35, i32* %8
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
%38 = load i32, i32* %11
%39 = add nsw i32 %38, 1
store i32 %39, i32* %11
%40 = load i32, i32* %8
store i32 %40, i32* %10
br label %41
41: ; preds = %44, %31
%42 = load i32, i32* %10
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32, i32* %10
%46 = add nsw i32 %45, -1
store i32 %46, i32* %10
store i32 0, i32* %11
br label %41
47: ; preds = %41
br label %48
48: ; preds = %51, %47
%49 = load i32, i32* %11
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %59
51: ; preds = %48
%52 = load i32, i32* %7
store i32 %52, i32* %8
store i32 0, i32* %7
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
%55 = load i32, i32* %11
%56 = add nsw i32 %55, -1
store i32 %56, i32* %11
%57 = load i32, i32* %6
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %57)
br label %48
59: ; preds = %48
br label %28
60: ; preds = %28
%61 = load i32, i32* %9
%62 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %7
%64 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %63)
store i32 0, i32* %3
br label %65
65: ; preds = %60, %14
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [15 x i8] c"divident = %d\0A\00"
@.str.1 = [14 x i8] c"divisor = %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [8 x i8] c"q = %d\0A\00"
@.str.4 = [8 x i8] c"r = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %36
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %7)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%13 = icmp eq i32 %7, 0
br i1 %13, label %31, label %19
14: ; preds = %19, %28
%15 = phi i32 [ 0, %28 ], [ %27, %19 ]
%16 = phi i32 [ %27, %28 ], [ %24, %19 ]
%17 = phi i32 [ %29, %28 ], [ %20, %19 ]
%18 = icmp eq i32 %26, 0
br i1 %18, label %31, label %19
19: ; preds = %4, %14
%20 = phi i32 [ %17, %14 ], [ 0, %4 ]
%21 = phi i32 [ %16, %14 ], [ %10, %4 ]
%22 = phi i32 [ %15, %14 ], [ 0, %4 ]
%23 = phi i32 [ %26, %14 ], [ %7, %4 ]
%24 = add nsw i32 %21, -1
%25 = icmp eq i32 %24, 0
%26 = add nsw i32 %23, -1
%27 = add nsw i32 %22, 1
br i1 %25, label %28, label %14
28: ; preds = %19
%29 = add nsw i32 %20, 1
%30 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %14
31: ; preds = %14, %4
%32 = phi i32 [ 0, %4 ], [ %15, %14 ]
%33 = phi i32 [ 0, %4 ], [ %17, %14 ]
%34 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %32)
br label %36
36: ; preds = %2, %31
ret i32 0
}