#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*/ avail_colo(char, int *);
char convert_int_char(int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int number_of_choice(int *);
int /*<<< orphan*/ print_board();
int /*<<< orphan*/ printf(char *, char);
int rand();
int /*<<< orphan*/ update(char, char);
void artificial2(void) {
  int avail[] = {0, 0, 0, 0, 0, 0, 0};
  int noc, cpt = 0;
  char color;
  char *colors;
  avail_colo('^', avail);
  noc = number_of_choice(avail);
  colors = malloc(noc * sizeof(char));
  for (int i = 0; i < 7; i++) {
    if (avail[i] == 1) {
      colors[cpt] = convert_int_char(i);
      cpt++;
    }
  }
  color = colors[rand() % noc];
  free(colors);
  printf("%c\n", color);
  update('^', color);
  print_board();
}


x86 assembly (clang, -O0):
<artificial2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x1c,%edx
call   1070 <memset@plt>
movl   $0x0,-0x28(%rbp)
lea    -0x20(%rbp),%rsi
mov    $0x5e,%edi
call   1090 <avail_colo@plt>
lea    -0x20(%rbp),%rdi
call   10b0 <number_of_choice@plt>
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x7,-0x3c(%rbp)
jge    123d <artificial2+0x9d>
movslq -0x3c(%rbp),%rax
cmpl   $0x1,-0x20(%rbp,%rax,4)
jne    122a <artificial2+0x8a>
mov    -0x3c(%rbp),%edi
call   10a0 <convert_int_char@plt>
mov    %al,%dl
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    122f <artificial2+0x8f>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11f3 <artificial2+0x53>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   10c0 <rand@plt>
cltd
idivl  -0x24(%rbp)
mov    -0x48(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
lea    0xd93(%rip),%rdi
movsbl -0x29(%rbp),%esi
call   1050 <printf@plt>
mov    $0x5e,%edi
movsbl -0x29(%rbp),%esi
call   1030 <update@plt>
mov    $0x0,%al
call   1060 <print_board@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<artificial2>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0xc(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    $0x5e,%edi
mov    %rbx,%rsi
call   1080 <avail_colo@plt>
mov    %rbx,%rdi
call   10a0 <number_of_choice@plt>
mov    %eax,%r14d
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
cmpl   $0x1,(%rsp)
je     1266 <artificial2+0xd6>
cmpl   $0x1,0x4(%rsp)
je     127f <artificial2+0xef>
cmpl   $0x1,0x8(%rsp)
je     129c <artificial2+0x10c>
cmpl   $0x1,0xc(%rsp)
je     12b9 <artificial2+0x129>
cmpl   $0x1,0x10(%rsp)
je     12d6 <artificial2+0x146>
cmpl   $0x1,0x14(%rsp)
je     12f3 <artificial2+0x163>
cmpl   $0x1,0x18(%rsp)
jne    1222 <artificial2+0x92>
mov    $0x6,%edi
call   1090 <convert_int_char@plt>
mov    %ebp,%ecx
mov    %al,(%rbx,%rcx,1)
xor    %eax,%eax
call   10b0 <rand@plt>
cltd
idiv   %r14d
movslq %edx,%rax
movsbl (%rbx,%rax,1),%ebp
mov    %rbx,%rdi
call   1040 <free@plt>
lea    0xdbd(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
mov    $0x5e,%edi
mov    %ebp,%esi
call   1030 <update@plt>
xor    %eax,%eax
call   1060 <print_board@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %edi,%edi
call   1090 <convert_int_char@plt>
mov    %al,(%rbx)
mov    $0x1,%ebp
cmpl   $0x1,0x4(%rsp)
jne    11e0 <artificial2+0x50>
mov    $0x1,%edi
call   1090 <convert_int_char@plt>
mov    %ebp,%ecx
mov    %al,(%rbx,%rcx,1)
add    $0x1,%ebp
cmpl   $0x1,0x8(%rsp)
jne    11eb <artificial2+0x5b>
mov    $0x2,%edi
call   1090 <convert_int_char@plt>
mov    %ebp,%ecx
mov    %al,(%rbx,%rcx,1)
add    $0x1,%ebp
cmpl   $0x1,0xc(%rsp)
jne    11f6 <artificial2+0x66>
mov    $0x3,%edi
call   1090 <convert_int_char@plt>
mov    %ebp,%ecx
mov    %al,(%rbx,%rcx,1)
add    $0x1,%ebp
cmpl   $0x1,0x10(%rsp)
jne    1201 <artificial2+0x71>
mov    $0x4,%edi
call   1090 <convert_int_char@plt>
mov    %ebp,%ecx
mov    %al,(%rbx,%rcx,1)
add    $0x1,%ebp
cmpl   $0x1,0x14(%rsp)
jne    120c <artificial2+0x7c>
mov    $0x5,%edi
call   1090 <convert_int_char@plt>
mov    %ebp,%ecx
mov    %al,(%rbx,%rcx,1)
add    $0x1,%ebp
cmpl   $0x1,0x18(%rsp)
je     1213 <artificial2+0x83>
jmp    1222 <artificial2+0x92>

LLVM IR (-O0):
@.str = [4 x i8] c"%c\0A\00"
define void @artificial2() {
%1 = alloca [7 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i32
%7 = bitcast [7 x i32]* %1 to i8*
store i32 0, i32* %3
%8 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%9 = call i32 @avail_colo(i8 signext 94, i32* %8)
%10 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%11 = call i32 @number_of_choice(i32* %10)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 1
%15 = trunc i64 %14 to i32
%16 = call i8* @malloc(i32 %15)
store i8* %16, i8** %5
store i32 0, i32* %6
br label %17
17: ; preds = %36, %0
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 7
br i1 %19, label %20, label %39
20: ; preds = %17
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %35
26: ; preds = %20
%27 = load i32, i32* %6
%28 = call signext i8 @convert_int_char(i32 %27)
%29 = load i8*, i8** %5
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
store i8 %28, i8* %32
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %35
35: ; preds = %26, %20
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %17
39: ; preds = %17
%40 = load i8*, i8** %5
%41 = call i32 (...) @rand()
%42 = load i32, i32* %2
%43 = srem i32 %41, %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %40, i64 %44
%46 = load i8, i8* %45
store i8 %46, i8* %4
%47 = load i8*, i8** %5
%48 = call i32 @free(i8* %47)
%49 = load i8, i8* %4
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %49)
%51 = load i8, i8* %4
%52 = call i32 @update(i8 signext 94, i8 signext %51)
%53 = call i32 (...) @print_board()
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%c\0A\00"
define void @artificial2() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%4 = call i32 @avail_colo(i8 signext 94, i32* %3)
%5 = call i32 @number_of_choice(i32* %3)
%6 = call i8* @malloc(i32 %5)
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call signext i8 @convert_int_char(i32 0)
store i8 %10, i8* %6
br label %11
11: ; preds = %0, %9
%12 = phi i32 [ 1, %9 ], [ 0, %0 ]
%13 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 1
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = call signext i8 @convert_int_char(i32 1)
%18 = zext i32 %12 to i64
%19 = getelementptr inbounds i8, i8* %6, i64 %18
store i8 %17, i8* %19
%20 = add nuw nsw i32 %12, 1
br label %21
21: ; preds = %16, %11
%22 = phi i32 [ %20, %16 ], [ %12, %11 ]
%23 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 2
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %31
26: ; preds = %21
%27 = call signext i8 @convert_int_char(i32 2)
%28 = zext i32 %22 to i64
%29 = getelementptr inbounds i8, i8* %6, i64 %28
store i8 %27, i8* %29
%30 = add nuw nsw i32 %22, 1
br label %31
31: ; preds = %26, %21
%32 = phi i32 [ %30, %26 ], [ %22, %21 ]
%33 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 3
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = call signext i8 @convert_int_char(i32 3)
%38 = zext i32 %32 to i64
%39 = getelementptr inbounds i8, i8* %6, i64 %38
store i8 %37, i8* %39
%40 = add nuw nsw i32 %32, 1
br label %41
41: ; preds = %36, %31
%42 = phi i32 [ %40, %36 ], [ %32, %31 ]
%43 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 4
%44 = load i32, i32* %43
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %51
46: ; preds = %41
%47 = call signext i8 @convert_int_char(i32 4)
%48 = zext i32 %42 to i64
%49 = getelementptr inbounds i8, i8* %6, i64 %48
store i8 %47, i8* %49
%50 = add nuw nsw i32 %42, 1
br label %51
51: ; preds = %46, %41
%52 = phi i32 [ %50, %46 ], [ %42, %41 ]
%53 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 5
%54 = load i32, i32* %53
%55 = icmp eq i32 %54, 1
br i1 %55, label %56, label %61
56: ; preds = %51
%57 = call signext i8 @convert_int_char(i32 5)
%58 = zext i32 %52 to i64
%59 = getelementptr inbounds i8, i8* %6, i64 %58
store i8 %57, i8* %59
%60 = add nuw nsw i32 %52, 1
br label %61
61: ; preds = %56, %51
%62 = phi i32 [ %60, %56 ], [ %52, %51 ]
%63 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 6
%64 = load i32, i32* %63
%65 = icmp eq i32 %64, 1
br i1 %65, label %66, label %70
66: ; preds = %61
%67 = call signext i8 @convert_int_char(i32 6)
%68 = zext i32 %62 to i64
%69 = getelementptr inbounds i8, i8* %6, i64 %68
store i8 %67, i8* %69
br label %70
70: ; preds = %66, %61
%71 = call i32 (...) @rand()
%72 = srem i32 %71, %5
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %6, i64 %73
%75 = load i8, i8* %74
%76 = call i32 @free(i8* %6)
%77 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %75)
%78 = call i32 @update(i8 signext 94, i8 signext %75)
%79 = call i32 (...) @print_board()
ret void
}