#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*/ SaleGoods();
int /*<<< orphan*/ ShowGoodNotFound();
int /*<<< orphan*/ ShowGoodsCountLess();
int /*<<< orphan*/ ShowInputTypeError();
int StockGoods();
int /*<<< orphan*/ ToLoggin2SScreen();
int /*<<< orphan*/ ToMainScreen();
int /*<<< orphan*/ WantEnter();
int WantNum();
int Loggin2S() {
  ToLoggin2SScreen();
  int type = -1;
  while (type < 0 || type > 2) {
    type = WantNum();
    switch (type) {
    case 1:
      switch (SaleGoods()) {
      case -1: {
        ShowGoodNotFound();
        WantEnter();
        break;
      }
      case -2: {
        ShowGoodsCountLess();
        WantEnter();
        break;
      }
      }
      break;
    case 2:
      if (StockGoods() == -1) {
        ShowGoodNotFound();
        WantEnter();
      };
      break;
    case 0:
      ToMainScreen();
      return 1;
    default: {
      ShowInputTypeError();
      WantEnter();
      ToLoggin2SScreen();
    }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<Loggin2S>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   10a0 <ToLoggin2SScreen@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
jl     11bf <Loggin2S+0x2f>
cmpl   $0x2,-0x8(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    11cf <Loggin2S+0x3f>
jmp    12af <Loggin2S+0x11f>
xor    %eax,%eax
call   1080 <WantNum@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1282 <Loggin2S+0xf2>
jmp    11ec <Loggin2S+0x5c>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     120e <Loggin2S+0x7e>
jmp    11fd <Loggin2S+0x6d>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     125f <Loggin2S+0xcf>
jmp    1295 <Loggin2S+0x105>
xor    %eax,%eax
call   1060 <SaleGoods@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
sub    $0xfffffffe,%eax
je     124c <Loggin2S+0xbc>
jmp    1228 <Loggin2S+0x98>
mov    -0x14(%rbp),%eax
sub    $0xffffffff,%eax
jne    125a <Loggin2S+0xca>
jmp    1239 <Loggin2S+0xa9>
mov    $0x0,%al
call   1090 <ShowGoodNotFound@plt>
mov    $0x0,%al
call   10b0 <WantEnter@plt>
jmp    125a <Loggin2S+0xca>
mov    $0x0,%al
call   1040 <ShowGoodsCountLess@plt>
mov    $0x0,%al
call   10b0 <WantEnter@plt>
jmp    12aa <Loggin2S+0x11a>
mov    $0x0,%al
call   1050 <StockGoods@plt>
cmp    $0xffffffff,%eax
jne    127d <Loggin2S+0xed>
mov    $0x0,%al
call   1090 <ShowGoodNotFound@plt>
mov    $0x0,%al
call   10b0 <WantEnter@plt>
jmp    12aa <Loggin2S+0x11a>
mov    $0x0,%al
call   1070 <ToMainScreen@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b6 <Loggin2S+0x126>
mov    $0x0,%al
call   1030 <ShowInputTypeError@plt>
mov    $0x0,%al
call   10b0 <WantEnter@plt>
mov    $0x0,%al
call   10a0 <ToLoggin2SScreen@plt>
jmp    11a6 <Loggin2S+0x16>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Loggin2S>:
push   %rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <ToLoggin2SScreen@plt>
xor    %eax,%eax
call   1080 <WantNum@plt>
test   %eax,%eax
je     11cc <Loggin2S+0x3c>
cmp    $0x2,%eax
je     11da <Loggin2S+0x4a>
cmp    $0x1,%eax
je     11e5 <Loggin2S+0x55>
xor    %eax,%eax
call   1030 <ShowInputTypeError@plt>
xor    %eax,%eax
call   10b0 <WantEnter@plt>
jmp    11a0 <Loggin2S+0x10>
xor    %eax,%eax
call   1070 <ToMainScreen@plt>
mov    $0x1,%ebx
jmp    1213 <Loggin2S+0x83>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <StockGoods@plt>
jmp    11f3 <Loggin2S+0x63>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <SaleGoods@plt>
cmp    $0xfffffffe,%eax
je     1203 <Loggin2S+0x73>
cmp    $0xffffffff,%eax
jne    1213 <Loggin2S+0x83>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <ShowGoodNotFound@plt>
jmp    120c <Loggin2S+0x7c>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <ShowGoodsCountLess@plt>
xor    %eax,%eax
call   10b0 <WantEnter@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @Loggin2S() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @ToLoggin2SScreen()
store i32 -1, i32* %2
br label %4
4: ; preds = %37, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 2
br label %10
10: ; preds = %7, %4
%11 = phi i1 [ true, %4 ], [ %9, %7 ]
br i1 %11, label %12, label %38
12: ; preds = %10
%13 = call i32 (...) @WantNum()
store i32 %13, i32* %2
%14 = load i32, i32* %2
switch i32 %14, label %33 [
i32 1, label %15
i32 2, label %24
i32 0, label %31
]
15: ; preds = %12
%16 = call i32 (...) @SaleGoods()
switch i32 %16, label %23 [
i32 -1, label %17
i32 -2, label %20
]
17: ; preds = %15
%18 = call i32 (...) @ShowGoodNotFound()
%19 = call i32 (...) @WantEnter()
br label %23
20: ; preds = %15
%21 = call i32 (...) @ShowGoodsCountLess()
%22 = call i32 (...) @WantEnter()
br label %23
23: ; preds = %15, %20, %17
br label %37
24: ; preds = %12
%25 = call i32 (...) @StockGoods()
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 (...) @ShowGoodNotFound()
%29 = call i32 (...) @WantEnter()
br label %30
30: ; preds = %27, %24
br label %37
31: ; preds = %12
%32 = call i32 (...) @ToMainScreen()
store i32 1, i32* %1
br label %39
33: ; preds = %12
%34 = call i32 (...) @ShowInputTypeError()
%35 = call i32 (...) @WantEnter()
%36 = call i32 (...) @ToLoggin2SScreen()
br label %37
37: ; preds = %33, %30, %23
br label %4
38: ; preds = %10
store i32 0, i32* %1
br label %39
39: ; preds = %38, %31
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
define i32 @Loggin2S() {
br label %1
1: ; preds = %20, %0
%2 = tail call i32 (...) @ToLoggin2SScreen()
%3 = tail call i32 (...) @WantNum()
switch i32 %3, label %20 [
i32 1, label %4
i32 2, label %12
i32 0, label %18
]
4: ; preds = %1
%5 = tail call i32 (...) @SaleGoods()
switch i32 %5, label %23 [
i32 -1, label %6
i32 -2, label %9
]
6: ; preds = %4
%7 = tail call i32 (...) @ShowGoodNotFound()
%8 = tail call i32 (...) @WantEnter()
br label %23
9: ; preds = %4
%10 = tail call i32 (...) @ShowGoodsCountLess()
%11 = tail call i32 (...) @WantEnter()
br label %23
12: ; preds = %1
%13 = tail call i32 (...) @StockGoods()
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = tail call i32 (...) @ShowGoodNotFound()
%17 = tail call i32 (...) @WantEnter()
br label %23
18: ; preds = %1
%19 = tail call i32 (...) @ToMainScreen()
br label %23
20: ; preds = %1
%21 = tail call i32 (...) @ShowInputTypeError()
%22 = tail call i32 (...) @WantEnter()
br label %1
23: ; preds = %4, %9, %6, %15, %12, %18
%24 = phi i32 [ 1, %18 ], [ 0, %12 ], [ 0, %15 ], [ 0, %6 ], [ 0, %9 ], [ 0, %4 ]
ret i32 %24
}