#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 */
typedef int uintmax_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int strtoumax(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  uintmax_t i, j, period, max;
  if (argc > 1) {
    max = strtoumax(argv[1], NULL, 10);
  } else {
    max = 10;
  }
  if (argc > 2) {
    period = strtoumax(argv[2], NULL, 10);
  } else {
    period = 1;
  }
  i = 0;
  j = 0;
  while (1) {
    if (period != 0 && i % period == 0) {
      printf("%ju\n", j);
      j++;
    }
    i++;
    if (i == max)
      break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    115e <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtoumax@plt>
mov    %eax,-0x20(%rbp)
jmp    1165 <main+0x45>
movl   $0xa,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    118d <main+0x6d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtoumax@plt>
mov    %eax,-0x1c(%rbp)
jmp    1194 <main+0x74>
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11d4 <main+0xb4>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
cmp    $0x0,%edx
jne    11d4 <main+0xb4>
mov    -0x18(%rbp),%esi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11ee <main+0xce>
jmp    11f3 <main+0xd3>
jmp    11a2 <main+0x82>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%ebx
mov    $0xa,%r14d
cmp    $0x2,%edi
jl     1167 <main+0x47>
mov    %rsi,%r15
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtoumax@plt>
mov    %eax,%r14d
cmp    $0x2,%ebp
je     1167 <main+0x47>
mov    0x10(%r15),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtoumax@plt>
mov    %eax,%ebx
xor    %ebp,%ebp
lea    0xe90(%rip),%r15
xor    %r12d,%r12d
jmp    1188 <main+0x68>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
cmp    %ebp,%r14d
je     11a6 <main+0x86>
test   %ebx,%ebx
je     1180 <main+0x60>
mov    %ebp,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    1180 <main+0x60>
mov    %r15,%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
add    $0x1,%r12d
jmp    1180 <main+0x60>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%ju\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strtoumax(i8* %15, i32* null, i32 10)
store i32 %16, i32* %9
br label %18
17: ; preds = %2
store i32 10, i32* %9
br label %18
18: ; preds = %17, %12
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @strtoumax(i8* %24, i32* null, i32 10)
store i32 %25, i32* %8
br label %27
26: ; preds = %18
store i32 1, i32* %8
br label %27
27: ; preds = %26, %21
store i32 0, i32* %6
store i32 0, i32* %7
br label %28
28: ; preds = %27, %48
%29 = load i32, i32* %8
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %41
31: ; preds = %28
%32 = load i32, i32* %6
%33 = load i32, i32* %8
%34 = srem i32 %32, %33
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i32, i32* %7
%38 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %41
41: ; preds = %36, %31, %28
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = load i32, i32* %9
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %48
47: ; preds = %41
br label %49
48: ; preds = %41
br label %28
49: ; preds = %47
%50 = load i32, i32* %3
ret i32 %50
}

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