#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
void open_bulot(int i, int colonnes, int fall) {
  FILE *bulot;
  bulot = fopen("../files/bulot.ansi", "r");
  int c, j, lol;
  printf("\033[2J");
  printf("\033[;H");
  printf("\033[%dC", colonnes - i);
  if (fall == 1) {
    for (j = 0; j < colonnes - i; ++j) {
      printf("\033[%dC", j);
      if (j % 2) {
        printf("o                 O\n");
      } else {
        printf("  O              o\n");
      }
    }
  }
  while ((c = fgetc(bulot)) != EOF) {
    if (fall == 2 || fall == 1) {
      lol = rand();
      printf("\033[%dm", 30 + (lol % 8));
    }
    printf("%c", c);
    if (c == '\n') {
      printf("\033[%dC", colonnes - i);
    }
  }
  printf("\033[%dm", 39);
  printf("\n");
  fclose(bulot);
}


x86 assembly (clang, -O0):
<open_bulot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    0xe98(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%esi
sub    -0x4(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    1228 <open_bulot+0xd8>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0x4(%rbp),%ecx
cmp    %ecx,%eax
jge    1223 <open_bulot+0xd3>
mov    -0x20(%rbp),%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1202 <open_bulot+0xb2>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1210 <open_bulot+0xc0>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1215 <open_bulot+0xc5>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b9 <open_bulot+0x69>
jmp    1228 <open_bulot+0xd8>
jmp    122d <open_bulot+0xdd>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2da8(%rip),%rcx
cmp    (%rcx),%eax
je     12b8 <open_bulot+0x168>
cmpl   $0x2,-0xc(%rbp)
je     125c <open_bulot+0x10c>
cmpl   $0x1,-0xc(%rbp)
jne    1284 <open_bulot+0x134>
mov    $0x0,%al
call   1070 <rand@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1e,%esi
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xa,-0x1c(%rbp)
jne    12b3 <open_bulot+0x163>
mov    -0x8(%rbp),%esi
sub    -0x4(%rbp),%esi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    122d <open_bulot+0xdd>
lea    0xd90(%rip),%rdi
mov    $0x27,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_bulot>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r13d
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xe77(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,(%rsp)
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
sub    %ebp,%ebx
lea    0xe62(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x1,%r13d
jne    1213 <open_bulot+0xa3>
test   %ebx,%ebx
jle    1213 <open_bulot+0xa3>
lea    0xe48(%rip),%r15
lea    0xe4d(%rip),%r12
lea    0xe59(%rip),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
test   $0x1,%bpl
mov    %r14,%rdi
cmove  %r12,%rdi
call   1040 <puts@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    11f0 <open_bulot+0x80>
mov    (%rsp),%r14
mov    %r14,%rdi
call   1070 <fgetc@plt>
mov    0x2dc2(%rip),%r15
cmp    (%r15),%eax
jne    125e <open_bulot+0xee>
lea    0xdf4(%rip),%rdi
mov    $0x27,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fclose@plt>
mov    %eax,%ebp
add    $0xffffffff,%r13d
lea    0xdb5(%rip),%r12
jmp    127f <open_bulot+0x10f>
nopl   (%rax)
mov    %r14,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
je     122b <open_bulot+0xbb>
cmp    $0x1,%r13d
ja     12ad <open_bulot+0x13d>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffff8,%ecx
neg    %ecx
lea    (%rax,%rcx,1),%esi
add    $0x1e,%esi
lea    0xd80(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebp,%edi
call   1030 <putchar@plt>
cmp    $0xa,%ebp
jne    1270 <open_bulot+0x100>
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1270 <open_bulot+0x100>

LLVM IR (-O0):
@.str = [20 x i8] c"../files/bulot.ansi\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"\1B[2J\00"
@.str.3 = [5 x i8] c"\1B[;H\00"
@.str.4 = [6 x i8] c"\1B[%dC\00"
@.str.5 = [21 x i8] c"o O\0A\00"
@.str.6 = [20 x i8] c" O o\0A\00"
@EOF = global i32 0
@.str.7 = [6 x i8] c"\1B[%dm\00"
@.str.8 = [3 x i8] c"%c\00"
@.str.9 = [2 x i8] c"\0A\00"
define void @open_bulot(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = sub nsw i32 %14, %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %42
20: ; preds = %3
store i32 0, i32* %9
br label %21
21: ; preds = %38, %20
%22 = load i32, i32* %9
%23 = load i32, i32* %5
%24 = load i32, i32* %4
%25 = sub nsw i32 %23, %24
%26 = icmp slt i32 %22, %25
br i1 %26, label %27, label %41
27: ; preds = %21
%28 = load i32, i32* %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %9
%31 = srem i32 %30, 2
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %37
35: ; preds = %27
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %37
37: ; preds = %35, %33
br label %38
38: ; preds = %37
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %21
41: ; preds = %21
br label %42
42: ; preds = %41, %3
br label %43
43: ; preds = %70, %42
%44 = load i32*, i32** %7
%45 = call i32 @fgetc(i32* %44)
store i32 %45, i32* %8
%46 = load i32, i32* @EOF
%47 = icmp ne i32 %45, %46
br i1 %47, label %48, label %71
48: ; preds = %43
%49 = load i32, i32* %6
%50 = icmp eq i32 %49, 2
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = load i32, i32* %6
%53 = icmp eq i32 %52, 1
br i1 %53, label %54, label %60
54: ; preds = %51, %48
%55 = call i32 (...) @rand()
store i32 %55, i32* %10
%56 = load i32, i32* %10
%57 = srem i32 %56, 8
%58 = add nsw i32 30, %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %54, %51
%61 = load i32, i32* %8
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %8
%64 = icmp eq i32 %63, 10
br i1 %64, label %65, label %70
65: ; preds = %60
%66 = load i32, i32* %5
%67 = load i32, i32* %4
%68 = sub nsw i32 %66, %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %65, %60
br label %43
71: ; preds = %43
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 39)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%74 = load i32*, i32** %7
%75 = call i32 @fclose(i32* %74)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"../files/bulot.ansi\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"\1B[2J\00"
@.str.3 = [5 x i8] c"\1B[;H\00"
@.str.4 = [6 x i8] c"\1B[%dC\00"
@EOF = global i32 0
@.str.7 = [6 x i8] c"\1B[%dm\00"
@str = [19 x i8] c" O o\00"
@str.10 = [20 x i8] c"o O\00"
define void @open_bulot(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%7 = sub nsw i32 %1, %0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %2, 1
%10 = icmp sgt i32 %7, 0
%11 = and i1 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %3, %12
%13 = phi i32 [ %19, %12 ], [ 0, %3 ]
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %13)
%15 = and i32 %13, 1
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0)
%18 = tail call i32 @puts(i8* dereferenceable(1) %17)
%19 = add nuw nsw i32 %13, 1
%20 = icmp eq i32 %19, %7
br i1 %20, label %21, label %12
21: ; preds = %12, %3
%22 = tail call i32 @fgetc(i32* %4)
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %44, label %25
25: ; preds = %21
%26 = add i32 %2, -1
%27 = icmp ult i32 %26, 2
br label %28
28: ; preds = %25, %40
%29 = phi i32 [ %22, %25 ], [ %41, %40 ]
br i1 %27, label %30, label %35
30: ; preds = %28
%31 = tail call i32 (...) @rand()
%32 = srem i32 %31, 8
%33 = add nsw i32 %32, 30
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %28, %30
%36 = tail call i32 @putchar(i32 %29)
%37 = icmp eq i32 %29, 10
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %7)
br label %40
40: ; preds = %38, %35
%41 = tail call i32 @fgetc(i32* %4)
%42 = load i32, i32* @EOF
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %28
44: ; preds = %40, %21
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 39)
%46 = tail call i32 @putchar(i32 10)
%47 = tail call i32 @fclose(i32* %4)
ret void
}