#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*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *, int *);
int /*<<< orphan*/ wait(int *);
int main(void) {
  int i, j, k, n, st, pid, s;
  int failed = 0;
  s = scanf("%d%d", &k, &n);
  for (i = 0; i < k; i++) {
    if ((pid = fork()) == 0) {
      for (j = i * n; j < i * n + n - 1; j++)
        printf("%d ", j);
      printf("\n");
      exit(0);
    } else if (pid < 0)
      failed++;
  }
  for (i = 0; i < k - failed; i++)
    wait(&st);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe93(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <scanf@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1224 <main+0xd4>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    11f9 <main+0xa9>
mov    -0x8(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11e4 <main+0x94>
mov    -0xc(%rbp),%esi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ad <main+0x5d>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
cmpl   $0x0,-0x1c(%rbp)
jge    120c <main+0xbc>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1211 <main+0xc1>
jmp    1216 <main+0xc6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1184 <main+0x34>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    1253 <main+0x103>
lea    -0x18(%rbp),%rdi
call   1060 <wait@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    122b <main+0xdb>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11d5 <main+0x75>
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
je     11e0 <main+0x80>
shr    $0x1f,%eax
add    %eax,%ebx
add    $0x1,%ebp
mov    0x4(%rsp),%eax
cmp    %eax,%ebp
jl     1190 <main+0x30>
cmp    %ebx,%eax
jle    11d5 <main+0x75>
xor    %ebp,%ebp
lea    0xc(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1070 <wait@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%eax
sub    %ebx,%eax
cmp    %eax,%ebp
jl     11c0 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x8(%rsp),%eax
mov    %eax,%ebx
imul   %ebp,%ebx
add    %ebx,%eax
add    $0xffffffff,%eax
cmp    %eax,%ebx
jge    1221 <main+0xc1>
lea    0xe0c(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
mov    0x8(%rsp),%eax
mov    %eax,%ecx
imul   %ebp,%ecx
add    %ecx,%eax
add    $0xffffffff,%eax
cmp    %eax,%ebx
jl     1200 <main+0xa0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %edi,%edi
call   1060 <exit@plt>

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

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