#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*/ assert(int);
unsigned long div15(unsigned long);
unsigned long mod15(unsigned long);
int /*<<< orphan*/ printf(char *, unsigned long const);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *args[]) {
  unsigned long int const limit = 1000000U;
  (void)argc;
  (void)args;
  printf("testing div15: 0 to %lu\n", limit);
  {
    unsigned long int i;
    for (i = 0; i < limit; ++i) {
      assert((i / 15) == div15(i));
    }
  }
  puts("ok");
  printf("testing mod15: 0 to %lu\n", limit);
  {
    unsigned long int i;
    for (i = 0; i < limit; ++i) {
      assert((i % 15) == mod15(i));
    }
  }
  puts("ok");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0xf4240,-0x18(%rbp)
lea    0xe8b(%rip),%rdi
mov    $0xf4240,%esi
call   1060 <printf@plt>
movq   $0x0,-0x20(%rbp)
cmpq   $0xf4240,-0x20(%rbp)
jae    11d8 <main+0x88>
mov    -0x20(%rbp),%rax
mov    $0xf,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <div15@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1187 <main+0x37>
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe31(%rip),%rdi
mov    $0xf4240,%esi
call   1060 <printf@plt>
movq   $0x0,-0x28(%rbp)
cmpq   $0xf4240,-0x28(%rbp)
jae    124b <main+0xfb>
mov    -0x28(%rbp),%rax
mov    $0xf,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <mod15@plt>
mov    -0x38(%rbp),%rdx
cmp    %rax,%rdx
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11fd <main+0xad>
lea    0xdc7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xea4(%rip),%rdi
mov    $0xf4240,%esi
call   1060 <printf@plt>
xor    %r15d,%r15d
mov    $0x88888889,%r14d
nop
mov    %r15d,%ebx
imul   %r14,%rbx
shr    $0x23,%rbx
mov    %r15,%rdi
call   1040 <div15@plt>
xor    %edi,%edi
cmp    %rbx,%rax
sete   %dil
call   1070 <assert@plt>
add    $0x1,%r15
cmp    $0xf4240,%r15
jne    1170 <main+0x20>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6b(%rip),%rdi
mov    $0xf4240,%esi
call   1060 <printf@plt>
xor    %r14d,%r14d
movabs $0x8888888888888889,%r15
88 88 88
nopl   0x0(%rax,%rax,1)
mov    %r14,%rax
mul    %r15
mov    %rdx,%rbx
shr    $0x3,%rbx
mov    %rbx,%rax
shl    $0x4,%rax
sub    %rax,%rbx
add    %r14,%rbx
mov    %r14,%rdi
call   1050 <mod15@plt>
xor    %edi,%edi
cmp    %rax,%rbx
sete   %dil
call   1070 <assert@plt>
add    $0x1,%r14
cmp    $0xf4240,%r14
jne    11d0 <main+0x80>
lea    0xe05(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"testing div15: 0 to %lu\0A\00"
@.str.1 = [3 x i8] c"ok\00"
@.str.2 = [25 x i8] c"testing mod15: 0 to %lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1000000, i64* %6
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 1000000)
store i64 0, i64* %7
br label %12
12: ; preds = %23, %2
%13 = load i64, i64* %7
%14 = icmp ult i64 %13, 1000000
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = load i64, i64* %7
%17 = udiv i64 %16, 15
%18 = load i64, i64* %7
%19 = call i64 @div15(i64 %18)
%20 = icmp eq i64 %17, %19
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
br label %23
23: ; preds = %15
%24 = load i64, i64* %7
%25 = add i64 %24, 1
store i64 %25, i64* %7
br label %12
26: ; preds = %12
%27 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i64 1000000)
store i64 0, i64* %8
br label %29
29: ; preds = %40, %26
%30 = load i64, i64* %8
%31 = icmp ult i64 %30, 1000000
br i1 %31, label %32, label %43
32: ; preds = %29
%33 = load i64, i64* %8
%34 = urem i64 %33, 15
%35 = load i64, i64* %8
%36 = call i64 @mod15(i64 %35)
%37 = icmp eq i64 %34, %36
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
br label %40
40: ; preds = %32
%41 = load i64, i64* %8
%42 = add i64 %41, 1
store i64 %42, i64* %8
br label %29
43: ; preds = %29
%44 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"testing div15: 0 to %lu\0A\00"
@.str.1 = [3 x i8] c"ok\00"
@.str.2 = [25 x i8] c"testing mod15: 0 to %lu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 1000000)
br label %4
4: ; preds = %2, %4
%5 = phi i64 [ 0, %2 ], [ %13, %4 ]
%6 = trunc i64 %5 to i32
%7 = udiv i32 %6, 15
%8 = zext i32 %7 to i64
%9 = tail call i64 @div15(i64 %5)
%10 = icmp eq i64 %9, %8
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = add nuw nsw i64 %5, 1
%14 = icmp eq i64 %13, 1000000
br i1 %14, label %15, label %4
15: ; preds = %4
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i64 1000000)
br label %18
18: ; preds = %15, %18
%19 = phi i64 [ 0, %15 ], [ %27, %18 ]
%20 = trunc i64 %19 to i32
%21 = urem i32 %20, 15
%22 = zext i32 %21 to i64
%23 = tail call i64 @mod15(i64 %19)
%24 = icmp eq i64 %23, %22
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = add nuw nsw i64 %19, 1
%28 = icmp eq i64 %27, 1000000
br i1 %28, label %29, label %18
29: ; preds = %18
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}