#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 mod(int, int);
int /*<<< orphan*/ printf(char *, ...);
void modtest(int players) {
  printf("Plus\nL ");
  for (int i = 0; i < players; i++) {
    printf(" %d", i);
  }
  printf("\n -");
  for (int i = 0; i < players; i++) {
    printf("- ");
  }
  for (int lead = 0; lead < players; lead++) {
    printf("\n%d ", lead);
    for (int loc = 0; loc < players; loc++) {
      printf(" %d", (lead + loc) % players);
    }
  }
  printf("\n\n");
  printf("Minus\nL ");
  for (int i = 0; i < players; i++) {
    printf(" %d", i);
  }
  printf("\n -");
  for (int i = 0; i < players; i++) {
    printf("- ");
  }
  for (int lead = 0; lead < players; lead++) {
    printf("\n%d ", lead);
    for (int loc = 0; loc < players; loc++) {
      printf(" %d", mod(lead - loc, players));
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<modtest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    116b <modtest+0x4b>
mov    -0x8(%rbp),%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1140 <modtest+0x20>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a8 <modtest+0x88>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1180 <modtest+0x60>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121a <modtest+0xfa>
mov    -0x10(%rbp),%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1207 <modtest+0xe7>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    %edx,%esi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d3 <modtest+0xb3>
jmp    120c <modtest+0xec>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11af <modtest+0x8f>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1268 <modtest+0x148>
mov    -0x18(%rbp),%esi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    123d <modtest+0x11d>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12a5 <modtest+0x185>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    127d <modtest+0x15d>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    131b <modtest+0x1fb>
mov    -0x20(%rbp),%esi
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1308 <modtest+0x1e8>
mov    -0x20(%rbp),%edi
sub    -0x24(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1030 <mod@plt>
mov    %eax,%esi
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12d0 <modtest+0x1b0>
jmp    130d <modtest+0x1ed>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12ac <modtest+0x18c>
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modtest>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r13d
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r13d,%r13d
jle    1234 <modtest+0xf4>
lea    0xe9c(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%r13d
jne    1170 <modtest+0x30>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r13d,%r13d
jle    1215 <modtest+0xd5>
lea    0xe72(%rip),%rbx
mov    %r13d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xffffffff,%ebp
jne    11b0 <modtest+0x70>
test   %r13d,%r13d
jle    1215 <modtest+0xd5>
lea    0xe48(%rip),%r14
lea    0xe36(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %ebp,%ebp
xchg   %ax,%ax
lea    (%rbx,%rbp,1),%eax
cltd
idiv   %r13d
mov    %r15,%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%r13d
jne    11f0 <modtest+0xb0>
add    $0x1,%ebx
cmp    %r13d,%ebx
jne    11e0 <modtest+0xa0>
jmp    1242 <modtest+0x102>
lea    0xe05(%rip),%rdi
call   1050 <puts@plt>
lea    0xdf0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    131d <modtest+0x1dd>
lea    0xdd1(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdd8(%rip),%rdi
call   1050 <puts@plt>
lea    0xdc3(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r13d,%r13d
jle    131d <modtest+0x1dd>
lea    0xd9c(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%r13d
jne    1270 <modtest+0x130>
lea    0xd81(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r13d,%r13d
jle    132b <modtest+0x1eb>
lea    0xd6e(%rip),%rbx
mov    %r13d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xffffffff,%ebp
jne    12b0 <modtest+0x170>
test   %r13d,%r13d
jle    132b <modtest+0x1eb>
lea    0xd48(%rip),%r14
lea    0xd36(%rip),%r15
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %ebx,%ebx
nop
lea    (%r12,%rbx,1),%edi
mov    %r13d,%esi
call   1040 <mod@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xffffffff,%ebx
mov    %r13d,%eax
add    %ebx,%eax
jne    12f0 <modtest+0x1b0>
add    $0x1,%r12d
cmp    %r13d,%r12d
jne    12e0 <modtest+0x1a0>
jmp    132b <modtest+0x1eb>
lea    0xce8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"Plus\0AL \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [4 x i8] c"\0A -\00"
@.str.3 = [3 x i8] c"- \00"
@.str.4 = [5 x i8] c"\0A%d \00"
@.str.5 = [3 x i8] c"\0A\0A\00"
@.str.6 = [9 x i8] c"Minus\0AL \00"
@.str.7 = [2 x i8] c"\0A\00"
define void @modtest(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %12
12: ; preds = %19, %1
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %12
22: ; preds = %12
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %24
24: ; preds = %30, %22
%25 = load i32, i32* %4
%26 = load i32, i32* %2
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %24
33: ; preds = %24
store i32 0, i32* %5
br label %34
34: ; preds = %56, %33
%35 = load i32, i32* %5
%36 = load i32, i32* %2
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %59
38: ; preds = %34
%39 = load i32, i32* %5
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %39)
store i32 0, i32* %6
br label %41
41: ; preds = %52, %38
%42 = load i32, i32* %6
%43 = load i32, i32* %2
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %55
45: ; preds = %41
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = add nsw i32 %46, %47
%49 = load i32, i32* %2
%50 = srem i32 %48, %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %45
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %41
55: ; preds = %41
br label %56
56: ; preds = %55
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 1
store i32 %58, i32* %5
br label %34
59: ; preds = %34
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %7
br label %62
62: ; preds = %69, %59
%63 = load i32, i32* %7
%64 = load i32, i32* %2
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %72
66: ; preds = %62
%67 = load i32, i32* %7
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %66
%70 = load i32, i32* %7
%71 = add nsw i32 %70, 1
store i32 %71, i32* %7
br label %62
72: ; preds = %62
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %74
74: ; preds = %80, %72
%75 = load i32, i32* %8
%76 = load i32, i32* %2
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %83
78: ; preds = %74
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %80
80: ; preds = %78
%81 = load i32, i32* %8
%82 = add nsw i32 %81, 1
store i32 %82, i32* %8
br label %74
83: ; preds = %74
store i32 0, i32* %9
br label %84
84: ; preds = %106, %83
%85 = load i32, i32* %9
%86 = load i32, i32* %2
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %109
88: ; preds = %84
%89 = load i32, i32* %9
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %89)
store i32 0, i32* %10
br label %91
91: ; preds = %102, %88
%92 = load i32, i32* %10
%93 = load i32, i32* %2
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %105
95: ; preds = %91
%96 = load i32, i32* %9
%97 = load i32, i32* %10
%98 = sub nsw i32 %96, %97
%99 = load i32, i32* %2
%100 = call i32 @mod(i32 %98, i32 %99)
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %100)
br label %102
102: ; preds = %95
%103 = load i32, i32* %10
%104 = add nsw i32 %103, 1
store i32 %104, i32* %10
br label %91
105: ; preds = %91
br label %106
106: ; preds = %105
%107 = load i32, i32* %9
%108 = add nsw i32 %107, 1
store i32 %108, i32* %9
br label %84
109: ; preds = %84
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"Plus\0AL \00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [4 x i8] c"\0A -\00"
@.str.3 = [3 x i8] c"- \00"
@.str.4 = [5 x i8] c"\0A%d \00"
@.str.6 = [9 x i8] c"Minus\0AL \00"
@str = [2 x i8] c"\0A\00"
define void @modtest(i32 %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = icmp sgt i32 %0, 0
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %19
6: ; preds = %8
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br i1 %3, label %14, label %22
8: ; preds = %1, %8
%9 = phi i32 [ %11, %8 ], [ 0, %1 ]
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = add nuw nsw i32 %9, 1
%12 = icmp eq i32 %11, %0
br i1 %12, label %6, label %8
13: ; preds = %14
br i1 %3, label %27, label %22
14: ; preds = %6, %14
%15 = phi i32 [ %17, %14 ], [ 0, %6 ]
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%17 = add nuw nsw i32 %15, 1
%18 = icmp eq i32 %17, %0
br i1 %18, label %13, label %14
19: ; preds = %30, %4
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br i1 %3, label %42, label %25
22: ; preds = %13, %6
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %25
25: ; preds = %22, %19
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %53
27: ; preds = %13, %30
%28 = phi i32 [ %31, %30 ], [ 0, %13 ]
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %28)
br label %33
30: ; preds = %33
%31 = add nuw nsw i32 %28, 1
%32 = icmp eq i32 %31, %0
br i1 %32, label %19, label %27
33: ; preds = %27, %33
%34 = phi i32 [ %38, %33 ], [ 0, %27 ]
%35 = add nuw nsw i32 %34, %28
%36 = srem i32 %35, %0
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = add nuw nsw i32 %34, 1
%39 = icmp eq i32 %38, %0
br i1 %39, label %30, label %33
40: ; preds = %42
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br i1 %3, label %48, label %53
42: ; preds = %19, %42
%43 = phi i32 [ %45, %42 ], [ 0, %19 ]
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = add nuw nsw i32 %43, 1
%46 = icmp eq i32 %45, %0
br i1 %46, label %40, label %42
47: ; preds = %48
br i1 %3, label %55, label %53
48: ; preds = %40, %48
%49 = phi i32 [ %51, %48 ], [ 0, %40 ]
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%51 = add nuw nsw i32 %49, 1
%52 = icmp eq i32 %51, %0
br i1 %52, label %47, label %48
53: ; preds = %58, %40, %25, %47
%54 = tail call i32 @putchar(i32 10)
ret void
55: ; preds = %47, %58
%56 = phi i32 [ %59, %58 ], [ 0, %47 ]
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %56)
br label %61
58: ; preds = %61
%59 = add nuw nsw i32 %56, 1
%60 = icmp eq i32 %59, %0
br i1 %60, label %53, label %55
61: ; preds = %55, %61
%62 = phi i32 [ %66, %61 ], [ 0, %55 ]
%63 = sub nsw i32 %56, %62
%64 = tail call i32 @mod(i32 %63, i32 %0)
%65 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %64)
%66 = add nuw nsw i32 %62, 1
%67 = icmp eq i32 %66, %0
br i1 %67, label %58, label %61
}