#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*/ eof_id_new(char *);
int /*<<< orphan*/ eof_va_read(int, int, int, char *, int, char *);
int /*<<< orphan*/ eof_va_write(int, int, int, char *, int, char *);
scalar_t__ strncmp(char *, char *, int);
int eof_ui_register(int sockfd, char id[]) {
  if (!eof_id_new(id))
    return -1;
  char answer[4];
  if (!eof_va_write(sockfd, 2, 4, "2100", 6, id)) {
    return -1;
  }
  if (!eof_va_read(sockfd, 2, 4, answer, 6, id)) {
    return -1;
  }
  if (strncmp(answer, "1100", 4))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<eof_ui_register>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <eof_id_new@plt>
cmp    $0x0,%eax
jne    116d <eof_ui_register+0x2d>
movl   $0xffffffff,-0x4(%rbp)
jmp    120c <eof_ui_register+0xcc>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%r9
mov    $0x2,%esi
mov    $0x4,%edx
lea    0xe7b(%rip),%rcx
mov    $0x6,%r8d
call   1060 <eof_va_write@plt>
cmp    $0x0,%eax
jne    11a5 <eof_ui_register+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    120c <eof_ui_register+0xcc>
mov    -0x8(%rbp),%edi
lea    -0x14(%rbp),%rcx
mov    -0x10(%rbp),%r9
mov    $0x2,%esi
mov    $0x4,%edx
mov    $0x6,%r8d
call   1040 <eof_va_read@plt>
cmp    $0x0,%eax
jne    11da <eof_ui_register+0x9a>
movl   $0xffffffff,-0x4(%rbp)
jmp    120c <eof_ui_register+0xcc>
lea    -0x14(%rbp),%rdi
lea    0xe20(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1205 <eof_ui_register+0xc5>
movl   $0x0,-0x4(%rbp)
jmp    120c <eof_ui_register+0xcc>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eof_ui_register>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsi,%rdi
call   1050 <eof_id_new@plt>
test   %eax,%eax
je     11ca <eof_ui_register+0x8a>
lea    0xe9f(%rip),%rcx
mov    %r14d,%edi
mov    $0x2,%esi
mov    $0x4,%edx
mov    $0x6,%r8d
mov    %rbx,%r9
call   1060 <eof_va_write@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
je     11cf <eof_ui_register+0x8f>
lea    0xc(%rsp),%rcx
mov    %r14d,%edi
mov    $0x2,%esi
mov    $0x4,%edx
mov    $0x6,%r8d
mov    %rbx,%r9
call   1040 <eof_va_read@plt>
test   %eax,%eax
je     11cf <eof_ui_register+0x8f>
lea    0xe55(%rip),%rsi
lea    0xc(%rsp),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
jmp    11cf <eof_ui_register+0x8f>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"2100\00"
@.str.1 = [5 x i8] c"1100\00"
define i32 @eof_ui_register(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [4 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i32 @eof_id_new(i8* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %2
store i32 -1, i32* %3
br label %30
11: ; preds = %2
%12 = load i32, i32* %4
%13 = load i8*, i8** %5
%14 = call i32 @eof_va_write(i32 %12, i32 2, i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 6, i8* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %11
store i32 -1, i32* %3
br label %30
17: ; preds = %11
%18 = load i32, i32* %4
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%20 = load i8*, i8** %5
%21 = call i32 @eof_va_read(i32 %18, i32 2, i32 4, i8* %19, i32 6, i8* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %17
store i32 -1, i32* %3
br label %30
24: ; preds = %17
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%26 = call i64 @strncmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 0, i32* %3
br label %30
29: ; preds = %24
store i32 1, i32* %3
br label %30
30: ; preds = %29, %28, %23, %16, %10
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [5 x i8] c"2100\00"
@.str.1 = [5 x i8] c"1100\00"
define i32 @eof_ui_register(i32 %0, i8* %1) {
%3 = alloca [4 x i8]
%4 = tail call i32 @eof_id_new(i8* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %2
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%8 = tail call i32 @eof_va_write(i32 %0, i32 2, i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 6, i8* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %6
%11 = call i32 @eof_va_read(i32 %0, i32 2, i32 4, i8* %7, i32 6, i8* %1)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %13, %10, %6
%18 = phi i32 [ -1, %6 ], [ -1, %10 ], [ %16, %13 ]
br label %19
19: ; preds = %2, %17
%20 = phi i32 [ %18, %17 ], [ -1, %2 ]
ret i32 %20
}