#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 */
unsigned long modulerDivision(char *, unsigned long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
scalar_t__ validate(char *);
int main() {
  char dividend[10000];
  unsigned long int divisor, remainder;
  printf("Enter dividend: ");
  scanf("%s", dividend);
  if (validate(dividend))
    return 0;
  printf("Enter divisor: ");
  scanf("%lu", &divisor);
  remainder = modulerDivision(dividend, divisor);
  printf("Modular division: %s %% %lu  =  %lu", dividend, divisor, remainder);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x2720(%rbp),%rsi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x2720(%rbp),%rdi
call   1050 <validate@plt>
cmp    $0x0,%rax
je     1197 <main+0x57>
movl   $0x0,-0x4(%rbp)
jmp    11fe <main+0xbe>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe98(%rip),%rdi
lea    -0x2728(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x2720(%rbp),%rdi
mov    -0x2728(%rbp),%rsi
call   1030 <modulerDivision@plt>
mov    %rax,-0x2730(%rbp)
lea    -0x2720(%rbp),%rsi
mov    -0x2728(%rbp),%rdx
mov    -0x2730(%rbp),%rcx
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x2720,%rsp
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1050 <validate@plt>
test   %rax,%rax
jne    11c5 <main+0x85>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <modulerDivision@plt>
mov    0x8(%rsp),%rdx
lea    0xe6c(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x2720,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter dividend: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [16 x i8] c"Enter divisor: \00"
@.str.3 = [4 x i8] c"%lu\00"
@.str.4 = [36 x i8] c"Modular division: %s %% %lu = %lu\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10000 x i8]
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
%9 = call i64 @validate(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 0, i32* %1
br label %22
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %3)
%15 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
%16 = load i64, i64* %3
%17 = call i64 @modulerDivision(i8* %15, i64 %16)
store i64 %17, i64* %4
%18 = getelementptr inbounds [10000 x i8], [10000 x i8]* %2, i64 0, i64 0
%19 = load i64, i64* %3
%20 = load i64, i64* %4
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %18, i64 %19, i64 %20)
store i32 0, i32* %1
br label %22
22: ; preds = %12, %11
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter dividend: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [16 x i8] c"Enter divisor: \00"
@.str.3 = [4 x i8] c"%lu\00"
@.str.4 = [36 x i8] c"Modular division: %s %% %lu = %lu\00"
define i32 @main() {
%1 = alloca [10000 x i8]
%2 = alloca i64
%3 = getelementptr inbounds [10000 x i8], [10000 x i8]* %1, i64 0, i64 0
%4 = bitcast i64* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i64 @validate(i8* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64* %2)
%12 = load i64, i64* %2
%13 = call i64 @modulerDivision(i8* %3, i64 %12)
%14 = load i64, i64* %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i8* %3, i64 %14, i64 %13)
br label %16
16: ; preds = %0, %9
ret i32 0
}