#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 connectToTable(int);
int createTable();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int initNetwork();
int login();
int /*<<< orphan*/ networkDisconnect();
int /*<<< orphan*/ printf(char *);
int registerate();
int /*<<< orphan*/ scanf(char *, char *);
int selectTable();
int lobbyServer() {
  int retCode;
  char flg;
  int tableId;
  retCode = initNetwork();
  while (1) {
    printf("Create new profile?(y/n)\n");
    scanf("%s", &flg);
    if (flg == 'y') {
      retCode = registerate();
    } else {
      retCode = login();
    }
    if (retCode == 0) {
      break;
    }
  }
  while (1) {
    tableId = selectTable();
    if (tableId == -1) {
      continue;
    }
    if (tableId == 0) {
      retCode = createTable();
      if (retCode < 0) {
        continue;
      }
      break;
    }
    if (tableId == -2) {
      exit(0);
    }
    retCode = connectToTable(tableId);
    if (retCode == 0) {
      break;
    }
  }
  networkDisconnect();
  return 0;
}


x86 assembly (clang, -O0):
<lobbyServer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <initNetwork@plt>
mov    %eax,-0x4(%rbp)
lea    0xe47(%rip),%rdi
call   1050 <printf@plt>
lea    0xe55(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1090 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x79,%eax
jne    11ea <lobbyServer+0x4a>
mov    $0x0,%al
call   10a0 <registerate@plt>
mov    %eax,-0x4(%rbp)
jmp    11f4 <lobbyServer+0x54>
mov    $0x0,%al
call   1070 <login@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1203 <lobbyServer+0x63>
jmp    1208 <lobbyServer+0x68>
jmp    11b2 <lobbyServer+0x12>
jmp    120d <lobbyServer+0x6d>
mov    $0x0,%al
call   1040 <selectTable@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1226 <lobbyServer+0x86>
jmp    120d <lobbyServer+0x6d>
cmpl   $0x0,-0xc(%rbp)
jne    124e <lobbyServer+0xae>
mov    $0x0,%al
call   10c0 <createTable@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1249 <lobbyServer+0xa9>
jmp    120d <lobbyServer+0x6d>
jmp    127e <lobbyServer+0xde>
cmpl   $0xfffffffe,-0xc(%rbp)
jne    125f <lobbyServer+0xbf>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0xc(%rbp),%edi
call   1060 <connectToTable@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1279 <lobbyServer+0xd9>
jmp    127e <lobbyServer+0xde>
jmp    120d <lobbyServer+0x6d>
mov    $0x0,%al
call   1080 <networkDisconnect@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lobbyServer>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <initNetwork@plt>
lea    0xe4c(%rip),%r14
lea    0xe42(%rip),%r15
lea    0xf(%rsp),%rbx
jmp    11db <lobbyServer+0x3b>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1070 <login@plt>
test   %eax,%eax
je     121b <lobbyServer+0x7b>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
cmpb   $0x79,0xf(%rsp)
jne    11d0 <lobbyServer+0x30>
xor    %eax,%eax
call   10a0 <registerate@plt>
test   %eax,%eax
jne    11db <lobbyServer+0x3b>
jmp    121b <lobbyServer+0x7b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   10c0 <createTable@plt>
test   %eax,%eax
jns    123b <lobbyServer+0x9b>
xor    %eax,%eax
call   1050 <selectTable@plt>
cmp    $0xffffffff,%eax
je     121b <lobbyServer+0x7b>
test   %eax,%eax
je     1210 <lobbyServer+0x70>
cmp    $0xfffffffe,%eax
je     124e <lobbyServer+0xae>
mov    %eax,%edi
call   1060 <connectToTable@plt>
test   %eax,%eax
jne    121b <lobbyServer+0x7b>
xor    %eax,%eax
call   1080 <networkDisconnect@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Create new profile?(y/n)\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @lobbyServer() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = call i32 (...) @initNetwork()
store i32 %4, i32* %1
br label %5
5: ; preds = %0, %19
%6 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 121
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = call i32 (...) @registerate()
store i32 %12, i32* %1
br label %15
13: ; preds = %5
%14 = call i32 (...) @login()
store i32 %14, i32* %1
br label %15
15: ; preds = %13, %11
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %15
br label %20
19: ; preds = %15
br label %5
20: ; preds = %18
br label %21
21: ; preds = %20, %25, %33, %46
%22 = call i32 (...) @selectTable()
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %26
25: ; preds = %21
br label %21
26: ; preds = %21
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = call i32 (...) @createTable()
store i32 %30, i32* %1
%31 = load i32, i32* %1
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
br label %21
34: ; preds = %29
br label %47
35: ; preds = %26
%36 = load i32, i32* %3
%37 = icmp eq i32 %36, -2
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %35
%41 = load i32, i32* %3
%42 = call i32 @connectToTable(i32 %41)
store i32 %42, i32* %1
%43 = load i32, i32* %1
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %40
br label %47
46: ; preds = %40
br label %21
47: ; preds = %45, %34
%48 = call i32 (...) @networkDisconnect()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@str = [25 x i8] c"Create new profile?(y/n)\00"
define i32 @lobbyServer() {
%1 = alloca i8
%2 = tail call i32 (...) @initNetwork()
br label %3
3: ; preds = %12, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 121
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = call i32 (...) @registerate()
br label %12
10: ; preds = %3
%11 = call i32 (...) @login()
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ %9, %8 ], [ %11, %10 ]
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %3
15: ; preds = %12, %20
%16 = call i32 (...) @selectTable()
switch i32 %16, label %23 [
i32 -1, label %20
i32 0, label %17
i32 -2, label %21
]
17: ; preds = %15
%18 = call i32 (...) @createTable()
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17, %23, %15
br label %15
21: ; preds = %15
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %15
%24 = call i32 @connectToTable(i32 %16)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %20
26: ; preds = %23, %17
%27 = call i32 (...) @networkDisconnect()
ret i32 0
}