#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 rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int i, rosso, blu, countRosso, countBlu, pari;
  srand(time(NULL));
  countBlu = 0;
  countRosso = 0;
  pari = 0;
  for (i = 1; i < 10; i++) {
    rosso = rand() % 6 + 1;
    blu = rand() % 6 + 1;
    printf("Rosso: %d \nBlu %d\n---------\n", rosso, blu);
    if (rosso == blu)
      pari++;
    else if (rosso > blu)
      countRosso++;
    else
      countBlu++;
  }
  if (countRosso == countBlu)
    printf("La partita è finita in parità.\n");
  else if (countRosso > countBlu)
    printf("La partita è stata vinta dal rosso.\nIl giocatore rosso ha vinto "
           "%d partite.\nIl giocatore blu ha vinto %d partite.",
           countRosso, countBlu);
  else
    printf("La partita è stata vinta dal blu.\nIl giocatore blu ha vinto %d "
           "partite.\nIl giocatore rosso ha vinto %d partite.",
           countBlu, countRosso);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1218 <main+0xd8>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x6,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    11dd <main+0x9d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1205 <main+0xc5>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11f7 <main+0xb7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1200 <main+0xc0>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1205 <main+0xc5>
jmp    120a <main+0xca>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    117b <main+0x3b>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    1237 <main+0xf7>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1275 <main+0x135>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    125c <main+0x11c>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1270 <main+0x130>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1275 <main+0x135>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x9,%ebx
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    118d <main+0x3d>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15d
add    $0xffffffff,%ebx
je     1212 <main+0xc2>
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %eax,%ebp
sub    %ecx,%ebp
neg    %ecx
lea    (%rax,%rcx,1),%r13d
add    $0x1,%r13d
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x2aaaaaab,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %eax,%r14d
sub    %ecx,%r14d
neg    %ecx
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
lea    0xe0c(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r14d,%ebp
je     1184 <main+0x34>
jle    1180 <main+0x30>
add    $0x1,%r12d
jmp    1184 <main+0x34>
cmp    %r15d,%r12d
jne    1225 <main+0xd5>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
jmp    124a <main+0xfa>
jle    1236 <main+0xe6>
lea    0xdef(%rip),%rdi
mov    %r12d,%esi
mov    %r15d,%edx
jmp    1243 <main+0xf3>
lea    0xe53(%rip),%rdi
mov    %r15d,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Rosso: %d \0ABlu %d\0A---------\0A\00"
@.str.1 = [34 x i8] c"La partita \C3\A8 finita in parit\C3\A0.\0A\00"
@.str.2 = [115 x i8] c"La partita \C3\A8 stata vinta dal rosso.\0AIl giocatore rosso ha vinto %d partite.\0AIl giocatore blu ha vinto %d partite.\00"
@.str.3 = [113 x i8] c"La partita \C3\A8 stata vinta dal blu.\0AIl giocatore blu ha vinto %d partite.\0AIl giocatore rosso ha vinto %d partite.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @time(i32* null)
%9 = call i32 @srand(i32 %8)
store i32 0, i32* %6
store i32 0, i32* %5
store i32 0, i32* %7
store i32 1, i32* %2
br label %10
10: ; preds = %41, %0
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %44
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 6
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
%17 = call i32 (...) @rand()
%18 = srem i32 %17, 6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21)
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %13
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %40
29: ; preds = %13
%30 = load i32, i32* %3
%31 = load i32, i32* %4
%32 = icmp sgt i32 %30, %31
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %39
36: ; preds = %29
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %39
39: ; preds = %36, %33
br label %40
40: ; preds = %39, %26
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %10
44: ; preds = %10
%45 = load i32, i32* %5
%46 = load i32, i32* %6
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %63
50: ; preds = %44
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = icmp sgt i32 %51, %52
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = load i32, i32* %5
%56 = load i32, i32* %6
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([115 x i8], [115 x i8]* @.str.2, i64 0, i64 0), i32 %55, i32 %56)
br label %62
58: ; preds = %50
%59 = load i32, i32* %6
%60 = load i32, i32* %5
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([113 x i8], [113 x i8]* @.str.3, i64 0, i64 0), i32 %59, i32 %60)
br label %62
62: ; preds = %58, %54
br label %63
63: ; preds = %62, %48
%64 = load i32, i32* %1
ret i32 %64
}

LLVM IR (-O2):
@.str = [29 x i8] c"Rosso: %d \0ABlu %d\0A---------\0A\00"
@.str.2 = [115 x i8] c"La partita \C3\A8 stata vinta dal rosso.\0AIl giocatore rosso ha vinto %d partite.\0AIl giocatore blu ha vinto %d partite.\00"
@.str.3 = [113 x i8] c"La partita \C3\A8 stata vinta dal blu.\0AIl giocatore blu ha vinto %d partite.\0AIl giocatore rosso ha vinto %d partite.\00"
@str = [33 x i8] c"La partita \C3\A8 finita in parit\C3\A0.\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %0, %21
%4 = phi i32 [ 0, %0 ], [ %23, %21 ]
%5 = phi i32 [ 0, %0 ], [ %22, %21 ]
%6 = phi i32 [ 1, %0 ], [ %24, %21 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 6
%9 = add nsw i32 %8, 1
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 6
%12 = add nsw i32 %11, 1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12)
%14 = icmp eq i32 %8, %11
br i1 %14, label %21, label %15
15: ; preds = %3
%16 = icmp sgt i32 %8, %11
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = add nsw i32 %5, 1
br label %21
19: ; preds = %15
%20 = add nsw i32 %4, 1
br label %21
21: ; preds = %3, %19, %17
%22 = phi i32 [ %18, %17 ], [ %5, %19 ], [ %5, %3 ]
%23 = phi i32 [ %4, %17 ], [ %20, %19 ], [ %4, %3 ]
%24 = add nuw nsw i32 %6, 1
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %3
26: ; preds = %21
%27 = icmp eq i32 %22, %23
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %36
30: ; preds = %26
%31 = icmp sgt i32 %22, %23
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([115 x i8], [115 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %23)
br label %36
34: ; preds = %30
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([113 x i8], [113 x i8]* @.str.3, i64 0, i64 0), i32 %23, i32 %22)
br label %36
36: ; preds = %32, %34, %28
ret i32 0
}