#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*/ read_server(int, char *);
scalar_t__ strncmp(char *, char *, int);
int check_winner(int fd, char *buff_win) {
  int win = 0;
  do {
    read_server(fd, buff_win);
  } while (strncmp(buff_win, "WINNER", 6));
  if (strncmp(buff_win, "WINNER ", 7) == 0)
    win = 1;
  return win;
}


x86 assembly (clang, -O0):
<check_winner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <read_server@plt>
mov    -0x10(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1136 <check_winner+0x16>
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1187 <check_winner+0x67>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_winner>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xed0(%rip),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <read_server@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    1130 <check_winner+0x10>
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1040 <strncmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"WINNER\00"
@.str.1 = [8 x i8] c"WINNER \00"
define i32 @check_winner(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %10, %2
%7 = load i32, i32* %3
%8 = load i8*, i8** %4
%9 = call i32 @read_server(i32 %7, i8* %8)
br label %10
10: ; preds = %6
%11 = load i8*, i8** %4
%12 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%13 = icmp ne i64 %12, 0
br i1 %13, label %6, label %14
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 1, i32* %5
br label %19
19: ; preds = %18, %14
%20 = load i32, i32* %5
ret i32 %20
}

LLVM IR (-O2):
@.str = [7 x i8] c"WINNER\00"
@.str.1 = [8 x i8] c"WINNER \00"
define i32 @check_winner(i32 %0, i8* %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i32 @read_server(i32 %0, i8* %1)
%5 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %3
7: ; preds = %3
%8 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
ret i32 %10
}