#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 */
struct sea {
  int dummy;
};

/* Variables and functions */
int inserisci(struct sea *, int, int, int, char *);
int rand();
void random_board(struct sea *board) {
  int i, ris;
  for (i = 1; i <= 5; i++) {
    do {
      if (rand() % 2)
        ris = inserisci(board, i, rand() % 10, rand() % 10, "->");
      else
        ris = inserisci(board, i, rand() % 10, rand() % 10, "^^");
    } while (ris <= 0);
  }
}


x86 assembly (clang, -O0):
<random_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jg     1215 <random_board+0xf5>
jmp    1142 <random_board+0x22>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11a9 <random_board+0x89>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x14(%rbp),%edx
lea    0xe64(%rip),%r8
call   1030 <inserisci@plt>
mov    %eax,-0x10(%rbp)
jmp    11f3 <random_board+0xd3>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x24(%rbp),%edx
lea    0xe18(%rip),%r8
call   1030 <inserisci@plt>
mov    %eax,-0x10(%rbp)
jmp    11f8 <random_board+0xd8>
cmpl   $0x0,-0x10(%rbp)
jle    1142 <random_board+0x22>
jmp    1207 <random_board+0xe7>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <random_board+0x13>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_board>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
lea    0xed1(%rip),%r15
lea    0xec7(%rip),%r12
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ecx
test   $0x1,%bpl
mov    %r12,%r8
cmove  %r15,%r8
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1030 <inserisci@plt>
test   %eax,%eax
jle    1140 <random_board+0x20>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ecx
test   $0x1,%bpl
mov    %r12,%r8
cmove  %r15,%r8
mov    %r14,%rdi
mov    $0x2,%esi
mov    %ebx,%edx
call   1030 <inserisci@plt>
test   %eax,%eax
jle    11c0 <random_board+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ecx
test   $0x1,%bpl
mov    %r12,%r8
cmove  %r15,%r8
mov    %r14,%rdi
mov    $0x3,%esi
mov    %ebx,%edx
call   1030 <inserisci@plt>
test   %eax,%eax
jle    1240 <random_board+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ecx
test   $0x1,%bpl
mov    %r12,%r8
cmove  %r15,%r8
mov    %r14,%rdi
mov    $0x4,%esi
mov    %ebx,%edx
call   1030 <inserisci@plt>
test   %eax,%eax
jle    12c0 <random_board+0x1a0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ecx
test   $0x1,%bpl
mov    %r12,%r8
cmove  %r15,%r8
mov    %r14,%rdi
mov    $0x5,%esi
mov    %ebx,%edx
call   1030 <inserisci@plt>
test   %eax,%eax
jle    1340 <random_board+0x220>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sea = type { i32 }
@.str = [3 x i8] c"->\00"
@.str.1 = [3 x i8] c"^^\00"
define void @random_board(%struct.sea* %0) {
%2 = alloca %struct.sea*
%3 = alloca i32
%4 = alloca i32
store %struct.sea* %0, %struct.sea** %2
store i32 1, i32* %3
br label %5
5: ; preds = %34, %1
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 5
br i1 %7, label %8, label %37
8: ; preds = %5
br label %9
9: ; preds = %30, %8
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = load %struct.sea*, %struct.sea** %2
%15 = load i32, i32* %3
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 10
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 10
%20 = call i32 @inserisci(%struct.sea* %14, i32 %15, i32 %17, i32 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %20, i32* %4
br label %29
21: ; preds = %9
%22 = load %struct.sea*, %struct.sea** %2
%23 = load i32, i32* %3
%24 = call i32 (...) @rand()
%25 = srem i32 %24, 10
%26 = call i32 (...) @rand()
%27 = srem i32 %26, 10
%28 = call i32 @inserisci(%struct.sea* %22, i32 %23, i32 %25, i32 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %28, i32* %4
br label %29
29: ; preds = %21, %13
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = icmp sle i32 %31, 0
br i1 %32, label %9, label %33
33: ; preds = %30
br label %34
34: ; preds = %33
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %5
37: ; preds = %5
ret void
}

LLVM IR (-O2):
%struct.sea = type { i32 }
@.str = [3 x i8] c"->\00"
@.str.1 = [3 x i8] c"^^\00"
define void @random_board(%struct.sea* %0) {
br label %2
2: ; preds = %1, %2
%3 = tail call i32 (...) @rand()
%4 = and i32 %3, 1
%5 = icmp eq i32 %4, 0
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 10
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 10
%10 = select i1 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%11 = tail call i32 @inserisci(%struct.sea* %0, i32 1, i32 %7, i32 %9, i8* %10)
%12 = icmp slt i32 %11, 1
br i1 %12, label %2, label %13
13: ; preds = %2, %13
%14 = tail call i32 (...) @rand()
%15 = and i32 %14, 1
%16 = icmp eq i32 %15, 0
%17 = tail call i32 (...) @rand()
%18 = srem i32 %17, 10
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 10
%21 = select i1 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%22 = tail call i32 @inserisci(%struct.sea* %0, i32 2, i32 %18, i32 %20, i8* %21)
%23 = icmp slt i32 %22, 1
br i1 %23, label %13, label %24
24: ; preds = %13, %24
%25 = tail call i32 (...) @rand()
%26 = and i32 %25, 1
%27 = icmp eq i32 %26, 0
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 10
%30 = tail call i32 (...) @rand()
%31 = srem i32 %30, 10
%32 = select i1 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%33 = tail call i32 @inserisci(%struct.sea* %0, i32 3, i32 %29, i32 %31, i8* %32)
%34 = icmp slt i32 %33, 1
br i1 %34, label %24, label %35
35: ; preds = %24, %35
%36 = tail call i32 (...) @rand()
%37 = and i32 %36, 1
%38 = icmp eq i32 %37, 0
%39 = tail call i32 (...) @rand()
%40 = srem i32 %39, 10
%41 = tail call i32 (...) @rand()
%42 = srem i32 %41, 10
%43 = select i1 %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%44 = tail call i32 @inserisci(%struct.sea* %0, i32 4, i32 %40, i32 %42, i8* %43)
%45 = icmp slt i32 %44, 1
br i1 %45, label %35, label %46
46: ; preds = %35, %46
%47 = tail call i32 (...) @rand()
%48 = and i32 %47, 1
%49 = icmp eq i32 %48, 0
%50 = tail call i32 (...) @rand()
%51 = srem i32 %50, 10
%52 = tail call i32 (...) @rand()
%53 = srem i32 %52, 10
%54 = select i1 %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0)
%55 = tail call i32 @inserisci(%struct.sea* %0, i32 5, i32 %51, i32 %53, i8* %54)
%56 = icmp slt i32 %55, 1
br i1 %56, label %46, label %57
57: ; preds = %46
ret void
}