#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 petra_psalidi_xarti(int c) {
  int value;
  value = rand() % 3 + 1;
  if (value < c) {
    printf("Result %d :", value);
    printf("Winner\n");
  } else if (value == c) {
    printf("Result %d :", value);
    printf("Equal\n");
  } else if (value == 1 && c == 2) {
    printf("Result %d :", value);
    printf("Winner\n");
  } else {
    printf("Result %d :", value);
    printf("Lost\n ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<petra_psalidi_xarti>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1170 <petra_psalidi_xarti+0x50>
mov    -0x8(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1201 <petra_psalidi_xarti+0xe1>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    11a0 <petra_psalidi_xarti+0x80>
mov    -0x8(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fc <petra_psalidi_xarti+0xdc>
cmpl   $0x1,-0x8(%rbp)
jne    11d8 <petra_psalidi_xarti+0xb8>
cmpl   $0x2,-0x4(%rbp)
jne    11d8 <petra_psalidi_xarti+0xb8>
mov    -0x8(%rbp),%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f7 <petra_psalidi_xarti+0xd7>
mov    -0x8(%rbp),%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fc <petra_psalidi_xarti+0xdc>
jmp    1201 <petra_psalidi_xarti+0xe1>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<petra_psalidi_xarti>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1050 <rand@plt>
movslq %eax,%rcx
imul   $0x55555556,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rax
add    %edx,%eax
lea    (%rax,%rax,2),%edx
mov    %ecx,%eax
sub    %edx,%eax
neg    %edx
lea    (%rcx,%rdx,1),%esi
add    $0x1,%esi
cmp    %ebx,%esi
jge    1180 <petra_psalidi_xarti+0x50>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
jmp    11d3 <petra_psalidi_xarti+0xa3>
jne    11a0 <petra_psalidi_xarti+0x70>
lea    0xe77(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
jmp    11d3 <petra_psalidi_xarti+0xa3>
cmp    $0x2,%ebx
jne    11b7 <petra_psalidi_xarti+0x87>
test   %eax,%eax
jne    11b7 <petra_psalidi_xarti+0x87>
lea    0xe50(%rip),%rdi
mov    $0x1,%esi
jmp    116b <petra_psalidi_xarti+0x3b>
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Result %d :\00"
@.str.1 = [8 x i8] c"Winner\0A\00"
@.str.2 = [7 x i8] c"Equal\0A\00"
@.str.3 = [7 x i8] c"Lost\0A \00"
define i32 @petra_psalidi_xarti(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 (...) @rand()
%5 = srem i32 %4, 3
%6 = add nsw i32 %5, 1
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %38
14: ; preds = %1
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %37
22: ; preds = %14
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 2
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %36
32: ; preds = %25, %22
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %32, %28
br label %37
37: ; preds = %36, %18
br label %38
38: ; preds = %37, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Result %d :\00"
@.str.3 = [7 x i8] c"Lost\0A \00"
@str.4 = [6 x i8] c"Equal\00"
@str.5 = [7 x i8] c"Winner\00"
define i32 @petra_psalidi_xarti(i32 %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 3
%4 = add nsw i32 %3, 1
%5 = icmp slt i32 %4, %0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0))
br label %24
9: ; preds = %1
%10 = icmp eq i32 %4, %0
br i1 %10, label %11, label %14
11: ; preds = %9
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %0)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.4, i64 0, i64 0))
br label %24
14: ; preds = %9
%15 = icmp eq i32 %3, 0
%16 = icmp eq i32 %0, 2
%17 = and i1 %16, %15
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 1)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0))
br label %24
21: ; preds = %14
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %11, %21, %18, %6
ret i32 0
}