#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 genball(int);
scalar_t__ ind(int, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, j;
  int d[8];
  for (i = 0; i < 7; i++) {
    if (i != 6) {
      do
        j = genball(33);
      while (ind(j, d, 7) != 0);
      d[i] = j;
    } else {
      do
        j = genball(16);
      while (ind(j, d, 7) != 0);
      d[i] = j;
    }
  }
  printf("red ball ");
  for (i = 0; i < 7; i++) {
    if (i != 6)
      printf(" %d", d[i]);
    else
      printf("\nblue ball %d\n", d[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    11e2 <main+0xb2>
cmpl   $0x6,-0x8(%rbp)
je     1197 <main+0x67>
jmp    115f <main+0x2f>
mov    $0x21,%edi
call   1050 <genball@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x7,%edx
call   1040 <ind@plt>
cmp    $0x0,%rax
jne    115f <main+0x2f>
mov    -0xc(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11cf <main+0x9f>
jmp    119c <main+0x6c>
mov    $0x10,%edi
call   1050 <genball@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x7,%edx
call   1040 <ind@plt>
cmp    $0x0,%rax
jne    119c <main+0x6c>
mov    -0xc(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11d4 <main+0xa4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    124f <main+0x11f>
cmpl   $0x6,-0x8(%rbp)
je     1226 <main+0xf6>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123c <main+0x10c>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1241 <main+0x111>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f7 <main+0xc7>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
xor    %r14d,%r14d
mov    %rsp,%rbx
jmp    114a <main+0x1a>
add    $0x1,%r14
cmp    $0x7,%r14
je     11a6 <main+0x76>
cmp    $0x6,%r14
jne    1180 <main+0x50>
mov    $0x10,%edi
call   1050 <genball@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1040 <ind@plt>
test   %rax,%rax
jne    1150 <main+0x20>
mov    %ebp,0x18(%rsp)
jmp    1140 <main+0x10>
cs nopw 0x0(%rax,%rax,1)
mov    $0x21,%edi
call   1050 <genball@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1040 <ind@plt>
test   %rax,%rax
jne    1180 <main+0x50>
mov    %ebp,(%rsp,%r14,4)
jmp    1140 <main+0x10>
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%esi
lea    0xe4c(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xdf5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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