#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*/ buff;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int premier_joueur(void) {
  char buff[10] = {0};
  printf("Quel sera le premier joueur ?\n");
  while (buff[0] > '4' || buff[0] < '1') {
    printf("\nEntrez un nombre entre 1 et 4 : ");
    fgets(buff, sizeof(buff), stdin);
  }
  printf("Le joueur %d commence ! \n\n", (buff[0] - '0'));
  return (int)(buff[0] - '0');
}


x86 assembly (clang, -O0):
<premier_joueur>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0xa(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xa(%rbp),%ecx
mov    $0x1,%al
cmp    $0x34,%ecx
mov    %al,-0xb(%rbp)
jg     1175 <premier_joueur+0x45>
movsbl -0xa(%rbp),%eax
cmp    $0x31,%eax
setl   %al
mov    %al,-0xb(%rbp)
mov    -0xb(%rbp),%al
test   $0x1,%al
jne    1185 <premier_joueur+0x55>
jmp    11af <premier_joueur+0x7f>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xa(%rbp),%rdi
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1050 <fgets@plt>
jmp    1156 <premier_joueur+0x26>
movsbl -0xa(%rbp),%esi
sub    $0x30,%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0xa(%rbp),%eax
sub    $0x30,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<premier_joueur>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movw   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%r14
mov    0x2e86(%rip),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <fgets@plt>
movzbl (%rsp),%esi
lea    -0x35(%rsi),%eax
cmp    $0xfc,%al
jb     1170 <premier_joueur+0x40>
add    $0xffffffd0,%esi
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl (%rsp),%eax
add    $0xffffffd0,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Quel sera le premier joueur ?\0A\00"
@.str.1 = [34 x i8] c"\0AEntrez un nombre entre 1 et 4 : \00"
@stdin = global i32 0
@.str.2 = [27 x i8] c"Le joueur %d commence ! \0A\0A\00"
define i32 @premier_joueur() {
%1 = alloca [10 x i8]
%2 = bitcast [10 x i8]* %1 to i8*
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %16, %0
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp sgt i32 %7, 52
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp slt i32 %12, 49
br label %14
14: ; preds = %9, %4
%15 = phi i1 [ true, %4 ], [ %13, %9 ]
br i1 %15, label %16, label %21
16: ; preds = %14
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%19 = load i32, i32* @stdin
%20 = call i32 @fgets(i8* %18, i32 10, i32 %19)
br label %4
21: ; preds = %14
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = sub nsw i32 %24, 48
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = sub nsw i32 %29, 48
ret i32 %30
}

LLVM IR (-O2):
@.str.1 = [34 x i8] c"\0AEntrez un nombre entre 1 et 4 : \00"
@stdin = global i32 0
@.str.2 = [27 x i8] c"Le joueur %d commence ! \0A\0A\00"
@str = [30 x i8] c"Quel sera le premier joueur ?\00"
define i32 @premier_joueur() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %2, i32 10, i32 %6)
%8 = load i8, i8* %2
%9 = add i8 %8, -53
%10 = icmp ult i8 %9, -4
br i1 %10, label %4, label %11
11: ; preds = %4
%12 = zext i8 %8 to i32
%13 = add nsw i32 %12, -48
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = add nsw i32 %16, -48
ret i32 %17
}