#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 main() {
  int a[20];
  int out[20];
  int len = 0;
  for (int i = 0; i < 20; i++) {
    a[i] = 1;
  }
  int cnt = 3;
  int now = 0;
  while (len < 20) {
    printf("%d %d\n", now, cnt);
    if (a[now] == 1) {
      cnt--;
      if (cnt == 0) {
        a[now] = 0;
        out[len] = now;
        len++;
        cnt = 3;
      }
      now = (now + 1) % 20;
    } else {
      now = (now + 1) % 20;
    }
  }
  for (int i = 0; i < 20; i++) {
    printf("%d ", out[i] + 1);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0xb8(%rbp)
cmpl   $0x14,-0xb8(%rbp)
jge    1166 <main+0x56>
movslq -0xb8(%rbp),%rax
movl   $0x1,-0x60(%rbp,%rax,4)
mov    -0xb8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb8(%rbp)
jmp    1136 <main+0x26>
movl   $0x3,-0xbc(%rbp)
movl   $0x0,-0xc0(%rbp)
cmpl   $0x14,-0xb4(%rbp)
jge    1243 <main+0x133>
mov    -0xc0(%rbp),%esi
mov    -0xbc(%rbp),%edx
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc0(%rbp),%rax
cmpl   $0x1,-0x60(%rbp,%rax,4)
jne    1227 <main+0x117>
mov    -0xbc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xbc(%rbp)
cmpl   $0x0,-0xbc(%rbp)
jne    120b <main+0xfb>
movslq -0xc0(%rbp),%rax
movl   $0x0,-0x60(%rbp,%rax,4)
mov    -0xc0(%rbp),%ecx
movslq -0xb4(%rbp),%rax
mov    %ecx,-0xb0(%rbp,%rax,4)
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
movl   $0x3,-0xbc(%rbp)
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc0(%rbp)
jmp    123e <main+0x12e>
mov    -0xc0(%rbp),%eax
add    $0x1,%eax
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc0(%rbp)
jmp    117a <main+0x6a>
movl   $0x0,-0xc4(%rbp)
cmpl   $0x14,-0xc4(%rbp)
jge    128d <main+0x17d>
movslq -0xc4(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%esi
add    $0x1,%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    124d <main+0x13d>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xa8,%rsp
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
mov    $0x3,%ebp
lea    0xeb1(%rip),%r14
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    1198 <main+0x78>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebx
movslq %ebx,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
cmp    $0x14,%r15d
jge    11cf <main+0xaf>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movslq %ebx,%rax
cmpl   $0x1,0x50(%rsp,%rax,4)
jne    1170 <main+0x50>
add    $0xffffffff,%ebp
jne    1170 <main+0x50>
movl   $0x0,0x50(%rsp,%rax,4)
movslq %r15d,%r15
mov    %eax,(%rsp,%r15,4)
add    $0x1,%r15d
mov    $0x3,%ebp
jmp    1170 <main+0x50>
mov    (%rsp),%esi
add    $0x1,%esi
lea    0xe3b(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x34(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x3c(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x40(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x44(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x48(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4c(%rsp),%esi
add    $0x1,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d %d\0A\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 [20 x i32]
%3 = alloca [20 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %16, %0
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 20
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %14
store i32 1, i32* %15
br label %16
16: ; preds = %12
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %9
19: ; preds = %9
store i32 3, i32* %6
store i32 0, i32* %7
br label %20
20: ; preds = %55, %19
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 20
br i1 %22, label %23, label %56
23: ; preds = %20
%24 = load i32, i32* %7
%25 = load i32, i32* %6
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25)
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %51
32: ; preds = %23
%33 = load i32, i32* %6
%34 = add nsw i32 %33, -1
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %47
37: ; preds = %32
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %39
store i32 0, i32* %40
%41 = load i32, i32* %7
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %43
store i32 %41, i32* %44
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
store i32 3, i32* %6
br label %47
47: ; preds = %37, %32
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
%50 = srem i32 %49, 20
store i32 %50, i32* %7
br label %55
51: ; preds = %23
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
%54 = srem i32 %53, 20
store i32 %54, i32* %7
br label %55
55: ; preds = %51, %47
br label %20
56: ; preds = %20
store i32 0, i32* %8
br label %57
57: ; preds = %67, %56
%58 = load i32, i32* %8
%59 = icmp slt i32 %58, 20
br i1 %59, label %60, label %70
60: ; preds = %57
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [20 x i32], [20 x i32]* %3, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = add nsw i32 %64, 1
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %60
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
store i32 %69, i32* %8
br label %57
70: ; preds = %57
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

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