#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*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *, ...);
int /*<<< orphan*/ srand(int);
int main() {
  int s, k, n, a;
  scanf("%d", &s);
  srand(s);
  scanf("%d %d", &k, &n);
  while (n > 0) {
    scanf("%d", &a);
    printf("%d - %d = %d\n", n, a, n - a);
    n -= a;
    if (n == 0) {
      printf("RACUNALNIK\n");
      return 0;
    }
    int t = rand() % k + 1;
    if (t > n) {
      t = n;
    }
    printf("%d - %d = %d\n", n, t, n - t);
    n -= t;
    if (n == 0) {
      printf("IGRALEC\n");
      return 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xead(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1040 <srand@plt>
lea    0xe90(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jle    1255 <main+0x115>
lea    0xe73(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%ecx
sub    -0x14(%rbp),%ecx
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11e4 <main+0xa4>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125c <main+0x11c>
mov    $0x0,%al
call   1060 <rand@plt>
cltd
idivl  -0xc(%rbp)
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1207 <main+0xc7>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%ecx
sub    -0x18(%rbp),%ecx
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1250 <main+0x110>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125c <main+0x11c>
jmp    117f <main+0x3f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe9e(%rip),%r15
lea    0x14(%rsp),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x14(%rsp),%edi
call   1050 <srand@plt>
lea    0xe7c(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%eax
lea    0xc(%rsp),%r12
lea    0xe61(%rip),%rbx
lea    0xe70(%rip),%r14
lea    0xe61(%rip),%r13
jmp    11de <main+0x8e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %esi,%ebp
mov    %esi,%ecx
sub    %ebp,%ecx
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%eax
sub    %ebp,%eax
mov    %eax,0x8(%rsp)
je     122a <main+0xda>
test   %eax,%eax
jle    1235 <main+0xe5>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %esi,%ecx
sub    %edx,%ecx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
sub    %eax,0x8(%rsp)
je     122d <main+0xdd>
xor    %eax,%eax
call   1070 <rand@plt>
cltd
idivl  0x10(%rsp)
mov    0x8(%rsp),%esi
cmp    %esi,%edx
jge    11c0 <main+0x70>
mov    %edx,%ebp
add    $0x1,%ebp
jmp    11c2 <main+0x72>
mov    %r13,%r14
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [14 x i8] c"%d - %d = %d\0A\00"
@.str.3 = [12 x i8] c"RACUNALNIK\0A\00"
@.str.4 = [9 x i8] c"IGRALEC\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = call i32 @srand(i32 %8)
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
br label %11
11: ; preds = %53, %0
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %54
14: ; preds = %11
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = sub nsw i32 %18, %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %17, i32 %20)
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, %22
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %14
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %55
29: ; preds = %14
%30 = call i32 (...) @rand()
%31 = load i32, i32* %3
%32 = srem i32 %30, %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = load i32, i32* %4
%36 = icmp sgt i32 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %29
%38 = load i32, i32* %4
store i32 %38, i32* %6
br label %39
39: ; preds = %37, %29
%40 = load i32, i32* %4
%41 = load i32, i32* %6
%42 = load i32, i32* %4
%43 = load i32, i32* %6
%44 = sub nsw i32 %42, %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %41, i32 %44)
%46 = load i32, i32* %6
%47 = load i32, i32* %4
%48 = sub nsw i32 %47, %46
store i32 %48, i32* %4
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %39
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %55
53: ; preds = %39
br label %11
54: ; preds = %11
store i32 0, i32* %1
br label %55
55: ; preds = %54, %51, %27
%56 = load i32, i32* %1
ret i32 %56
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [14 x i8] c"%d - %d = %d\0A\00"
@str = [8 x i8] c"IGRALEC\00"
@str.5 = [11 x i8] c"RACUNALNIK\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = call i32 @srand(i32 %10)
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%13 = load i32, i32* %3
br label %14
14: ; preds = %27, %0
%15 = phi i32 [ %38, %27 ], [ %13, %0 ]
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %43
17: ; preds = %14
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = sub nsw i32 %19, %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %20, i32 %21)
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, %23
store i32 %25, i32* %3
%26 = icmp eq i32 %25, 0
br i1 %26, label %40, label %27
27: ; preds = %17
%28 = call i32 (...) @rand()
%29 = load i32, i32* %2
%30 = srem i32 %28, %29
%31 = add nsw i32 %30, 1
%32 = load i32, i32* %3
%33 = icmp slt i32 %30, %32
%34 = select i1 %33, i32 %31, i32 %32
%35 = sub nsw i32 %32, %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %32, i32 %34, i32 %35)
%37 = load i32, i32* %3
%38 = sub nsw i32 %37, %34
store i32 %38, i32* %3
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %14
40: ; preds = %27, %17
%41 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.5, i64 0, i64 0), %17 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0), %27 ]
%42 = call i32 @puts(i8* dereferenceable(1) %41)
br label %43
43: ; preds = %14, %40
ret i32 0
}