#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 dado();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int main() {
  srand(time(0));
  printf("Juego de dado\n");
  printf("|---------------------------------|\n");
  printf("| N° tiro | Jugador 1 | Jugador 2 |\n");
  int p1 = 0, p2 = 0;
  int l1 = 0, l2 = 0;
  int ac1, ac2;
  char ganador[2];
  for (int i = 0; i < 20; i++) {
    ac1 = dado();
    ac2 = dado();
    printf("|   %2d    |    %2d     |    %2d     |\n", i, ac1, ac2);
    switch (ac1) {
    case 5:
      p1++;
      break;
    case 6:
      l1++;
      break;
    default:
      break;
    }
    switch (ac2) {
    case 5:
      p2++;
      break;
    case 6:
      l2++;
      break;
    default:
      break;
    }
    usleep(100000);
  }
  printf("|---------------------------------|\n");
  printf("\n");
  if (p1 > p2 && l1 < p1) {
    printf("Jugador 1 gana con %d veces 5\n", p1);
    printf(
        "Estadisticas: p1 %d veces 5, %d veces 6; p2 %d veces 5, %d veces 6\n",
        p1, l1, p2, l2);
  } else if (p1 < p2 && l2 < p2) {
    printf("Jugador 2 gana con %d veces 5\n", p2);
    printf(
        "Estadisticas: p1 %d veces 5, %d veces 6; p2 %d veces 5, %d veces 6\n",
        p1, l1, p2, l2);
  } else {
    printf("Empate entre jugador 1 y 2\n");
    printf(
        "Estadisticas: p1 %d veces 5, %d veces 6; p2 %d veces 5, %d veces 6\n",
        p1, l1, p2, l2);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x14,-0x24(%rbp)
jge    129c <main+0x14c>
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   1060 <dado@plt>
mov    %eax,%ecx
mov    -0x29(%rbp),%al
mov    %ecx,-0x18(%rbp)
call   1060 <dado@plt>
mov    %eax,%ecx
mov    -0x29(%rbp),%al
mov    %ecx,-0x1c(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x5,%eax
je     121d <main+0xcd>
jmp    120c <main+0xbc>
mov    -0x28(%rbp),%eax
sub    $0x6,%eax
je     122b <main+0xdb>
jmp    1239 <main+0xe9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    123e <main+0xee>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    123e <main+0xee>
jmp    123e <main+0xee>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x5,%eax
je     1263 <main+0x113>
jmp    1252 <main+0x102>
mov    -0x30(%rbp),%eax
sub    $0x6,%eax
je     1271 <main+0x121>
jmp    127f <main+0x12f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1284 <main+0x134>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1284 <main+0x134>
jmp    1284 <main+0x134>
mov    $0x186a0,%edi
call   1070 <usleep@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ba <main+0x6a>
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1301 <main+0x1b1>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1301 <main+0x1b1>
mov    -0x8(%rbp),%esi
lea    0xda8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1378 <main+0x228>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    134a <main+0x1fa>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    134a <main+0x1fa>
mov    -0xc(%rbp),%esi
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1373 <main+0x223>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1378 <main+0x228>
mov    -0x4(%rbp),%eax
add    $0x30,%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   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xf1a(%rip),%rdi
call   1040 <puts@plt>
lea    0xf41(%rip),%rdi
call   1040 <puts@plt>
lea    0xf10(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r13d,%r13d
movl   $0x0,0x4(%rsp)
xor    %r12d,%r12d
jmp    11e6 <main+0x76>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12d
mov    $0x186a0,%edi
call   1090 <usleep@plt>
add    $0x1,%ebx
cmp    $0x14,%ebx
je     1247 <main+0xd7>
xor    %eax,%eax
call   1080 <dado@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1080 <dado@plt>
mov    %eax,%r14d
lea    0xdff(%rip),%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x6,%r15d
je     1230 <main+0xc0>
cmp    $0x5,%r15d
jne    121e <main+0xae>
add    $0x1,%ebp
cmp    $0x6,%r14d
jne    123b <main+0xcb>
jmp    11d0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
addl   $0x1,0x4(%rsp)
cmp    $0x6,%r14d
je     11d0 <main+0x60>
cmp    $0x5,%r14d
jne    11d4 <main+0x64>
add    $0x1,%r13d
jmp    11d4 <main+0x64>
lea    0xe8f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r13d,%ebp
jle    1273 <main+0x103>
cmp    %ebp,0x4(%rsp)
jge    1273 <main+0x103>
lea    0xdb9(%rip),%rdi
mov    %ebp,%esi
jmp    1287 <main+0x117>
cmp    %r13d,%ebp
jge    1290 <main+0x120>
cmp    %r13d,%r12d
jge    1290 <main+0x120>
lea    0xe07(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    129c <main+0x12c>
lea    0xe6a(%rip),%rdi
call   1040 <puts@plt>
lea    0xda4(%rip),%rdi
mov    %ebp,%esi
mov    0x4(%rsp),%edx
mov    %r13d,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   1050 <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 = [15 x i8] c"Juego de dado\0A\00"
@.str.1 = [37 x i8] c"|---------------------------------|\0A\00"
@.str.2 = [38 x i8] c"| N\C2\B0 tiro | Jugador 1 | Jugador 2 |\0A\00"
@.str.3 = [40 x i8] c"| %2d | %2d | %2d |\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [31 x i8] c"Jugador 1 gana con %d veces 5\0A\00"
@.str.6 = [68 x i8] c"Estadisticas: p1 %d veces 5, %d veces 6; p2 %d veces 5, %d veces 6\0A\00"
@.str.7 = [31 x i8] c"Jugador 2 gana con %d veces 5\0A\00"
@.str.8 = [28 x i8] c"Empate entre jugador 1 y 2\0A\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
%8 = alloca [2 x i8]
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 @time(i32 0)
%11 = call i32 @srand(i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %9
br label %15
15: ; preds = %44, %0
%16 = load i32, i32* %9
%17 = icmp slt i32 %16, 20
br i1 %17, label %18, label %47
18: ; preds = %15
%19 = call i32 (...) @dado()
store i32 %19, i32* %6
%20 = call i32 (...) @dado()
store i32 %20, i32* %7
%21 = load i32, i32* %9
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
%25 = load i32, i32* %6
switch i32 %25, label %32 [
i32 5, label %26
i32 6, label %29
]
26: ; preds = %18
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %33
29: ; preds = %18
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %33
32: ; preds = %18
br label %33
33: ; preds = %32, %29, %26
%34 = load i32, i32* %7
switch i32 %34, label %41 [
i32 5, label %35
i32 6, label %38
]
35: ; preds = %33
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %42
38: ; preds = %33
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %42
41: ; preds = %33
br label %42
42: ; preds = %41, %38, %35
%43 = call i32 @usleep(i32 100000)
br label %44
44: ; preds = %42
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %15
47: ; preds = %15
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%50 = load i32, i32* %2
%51 = load i32, i32* %3
%52 = icmp sgt i32 %50, %51
br i1 %52, label %53, label %65
53: ; preds = %47
%54 = load i32, i32* %4
%55 = load i32, i32* %2
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %65
57: ; preds = %53
%58 = load i32, i32* %2
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %2
%61 = load i32, i32* %4
%62 = load i32, i32* %3
%63 = load i32, i32* %5
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0), i32 %60, i32 %61, i32 %62, i32 %63)
br label %89
65: ; preds = %53, %47
%66 = load i32, i32* %2
%67 = load i32, i32* %3
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %81
69: ; preds = %65
%70 = load i32, i32* %5
%71 = load i32, i32* %3
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %81
73: ; preds = %69
%74 = load i32, i32* %3
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %74)
%76 = load i32, i32* %2
%77 = load i32, i32* %4
%78 = load i32, i32* %3
%79 = load i32, i32* %5
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0), i32 %76, i32 %77, i32 %78, i32 %79)
br label %88
81: ; preds = %69, %65
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
%83 = load i32, i32* %2
%84 = load i32, i32* %4
%85 = load i32, i32* %3
%86 = load i32, i32* %5
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0), i32 %83, i32 %84, i32 %85, i32 %86)
br label %88
88: ; preds = %81, %73
br label %89
89: ; preds = %88, %57
%90 = load i32, i32* %1
ret i32 %90
}

LLVM IR (-O2):
@.str.3 = [40 x i8] c"| %2d | %2d | %2d |\0A\00"
@.str.5 = [31 x i8] c"Jugador 1 gana con %d veces 5\0A\00"
@.str.6 = [68 x i8] c"Estadisticas: p1 %d veces 5, %d veces 6; p2 %d veces 5, %d veces 6\0A\00"
@.str.7 = [31 x i8] c"Jugador 2 gana con %d veces 5\0A\00"
@str = [14 x i8] c"Juego de dado\00"
@str.10 = [37 x i8] c"| N\C2\B0 tiro | Jugador 1 | Jugador 2 |\00"
@str.11 = [36 x i8] c"|---------------------------------|\00"
@str.12 = [27 x i8] c"Empate entre jugador 1 y 2\00"
define i32 @main() {
%1 = tail call i32 @time(i32 0)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.11, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.10, i64 0, i64 0))
br label %12
6: ; preds = %32
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.11, i64 0, i64 0))
%8 = tail call i32 @putchar(i32 10)
%9 = icmp sgt i32 %27, %34
%10 = icmp slt i32 %26, %27
%11 = select i1 %9, i1 %10, i1 false
br i1 %11, label %38, label %40
12: ; preds = %0, %32
%13 = phi i32 [ 0, %0 ], [ %36, %32 ]
%14 = phi i32 [ 0, %0 ], [ %27, %32 ]
%15 = phi i32 [ 0, %0 ], [ %34, %32 ]
%16 = phi i32 [ 0, %0 ], [ %26, %32 ]
%17 = phi i32 [ 0, %0 ], [ %33, %32 ]
%18 = tail call i32 (...) @dado()
%19 = tail call i32 (...) @dado()
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %18, i32 %19)
switch i32 %18, label %25 [
i32 5, label %21
i32 6, label %23
]
21: ; preds = %12
%22 = add nsw i32 %14, 1
br label %25
23: ; preds = %12
%24 = add nsw i32 %16, 1
br label %25
25: ; preds = %12, %23, %21
%26 = phi i32 [ %16, %12 ], [ %24, %23 ], [ %16, %21 ]
%27 = phi i32 [ %14, %12 ], [ %14, %23 ], [ %22, %21 ]
switch i32 %19, label %32 [
i32 5, label %28
i32 6, label %30
]
28: ; preds = %25
%29 = add nsw i32 %15, 1
br label %32
30: ; preds = %25
%31 = add nsw i32 %17, 1
br label %32
32: ; preds = %25, %30, %28
%33 = phi i32 [ %17, %25 ], [ %31, %30 ], [ %17, %28 ]
%34 = phi i32 [ %15, %25 ], [ %15, %30 ], [ %29, %28 ]
%35 = tail call i32 @usleep(i32 100000)
%36 = add nuw nsw i32 %13, 1
%37 = icmp eq i32 %36, 20
br i1 %37, label %6, label %12
38: ; preds = %6
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %27)
br label %48
40: ; preds = %6
%41 = icmp slt i32 %27, %34
%42 = icmp slt i32 %33, %34
%43 = select i1 %41, i1 %42, i1 false
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %34)
br label %48
46: ; preds = %40
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.12, i64 0, i64 0))
br label %48
48: ; preds = %44, %46, %38
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @.str.6, i64 0, i64 0), i32 %27, i32 %26, i32 %34, i32 %33)
ret i32 0
}