#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*/ client_log(char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int client_menu() {
  int option = 0;
  printf("\t\t\t******************************************\n");
  printf("\t\t\t*                ChatRoom                *\n");
  printf("\t\t\t*                                        *\n");
  printf("\t\t\t*               0. exit                  *\n");
  printf("\t\t\t*               1. sign in               *\n");
  printf("\t\t\t*               2. sign up               *\n");
  printf("\t\t\t*                                        *\n");
  printf("\t\t\t*(C) 2014 Sean Guo. All rights reserved. *\n");
  printf("\t\t\t******************************************\n");
  do {
    printf("\t\t\t               >");
    scanf("%d", &option);
    getchar();
    if (option >= 0 && option <= 2)
      return option;
    else {
      client_log("Error input!");
      continue;
    }
  } while (1);
  return 0;
}


x86 assembly (clang, -O0):
<client_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
call   1040 <printf@plt>
lea    0xef0(%rip),%rdi
call   1040 <printf@plt>
lea    0xf13(%rip),%rdi
call   1040 <printf@plt>
lea    0xf36(%rip),%rdi
call   1040 <printf@plt>
lea    0xf59(%rip),%rdi
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
lea    0xf70(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
lea    0xf87(%rip),%rdi
call   1040 <printf@plt>
lea    0xf8f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
cmpl   $0x0,-0x8(%rbp)
jl     11fd <client_menu+0xbd>
cmpl   $0x2,-0x8(%rbp)
jg     11fd <client_menu+0xbd>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121f <client_menu+0xdf>
lea    0xf5c(%rip),%rdi
call   1030 <client_log@plt>
mov    $0x1,%al
test   $0x1,%al
jne    11bb <client_menu+0x7b>
jmp    1218 <client_menu+0xd8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client_menu>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xfd1(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5a(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xf05(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xf4d(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
lea    0xe37(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
jb     124b <client_menu+0xfb>
lea    0xe19(%rip),%r14
lea    0xdfb(%rip),%r15
lea    0xe08(%rip),%r12
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <client_log@plt>
mov    %r15,%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
jae    1220 <client_menu+0xd0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [47 x i8] c"\09\09\09******************************************\0A\00"
@.str.1 = [47 x i8] c"\09\09\09* ChatRoom *\0A\00"
@.str.2 = [47 x i8] c"\09\09\09* *\0A\00"
@.str.3 = [47 x i8] c"\09\09\09* 0. exit *\0A\00"
@.str.4 = [47 x i8] c"\09\09\09* 1. sign in *\0A\00"
@.str.5 = [47 x i8] c"\09\09\09* 2. sign up *\0A\00"
@.str.6 = [47 x i8] c"\09\09\09*(C) 2014 Sean Guo. All rights reserved. *\0A\00"
@.str.7 = [20 x i8] c"\09\09\09 >\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [13 x i8] c"Error input!\00"
define i32 @client_menu() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %25, %0
%13 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%15 = call i32 (...) @getchar()
%16 = load i32, i32* %2
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = load i32, i32* %2
%20 = icmp sle i32 %19, 2
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = load i32, i32* %2
store i32 %22, i32* %1
br label %27
23: ; preds = %18, %12
%24 = call i32 @client_log(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %25
25: ; preds = %23
br i1 true, label %12, label %26
26: ; preds = %25
store i32 0, i32* %1
br label %27
27: ; preds = %26, %21
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str.7 = [20 x i8] c"\09\09\09 >\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [13 x i8] c"Error input!\00"
@str.10 = [46 x i8] c"\09\09\09* ChatRoom *\00"
@str.12 = [46 x i8] c"\09\09\09* 0. exit *\00"
@str.13 = [46 x i8] c"\09\09\09* 1. sign in *\00"
@str.14 = [46 x i8] c"\09\09\09* 2. sign up *\00"
@str.15 = [46 x i8] c"\09\09\09* *\00"
@str.16 = [46 x i8] c"\09\09\09*(C) 2014 Sean Guo. All rights reserved. *\00"
@str.17 = [46 x i8] c"\09\09\09******************************************\00"
define i32 @client_menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.17, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.10, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.15, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.12, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.13, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.14, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.15, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.16, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.17, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%14 = call i32 (...) @getchar()
%15 = load i32, i32* %1
%16 = icmp ult i32 %15, 3
br i1 %16, label %17, label %19
17: ; preds = %19, %0
%18 = phi i32 [ %15, %0 ], [ %24, %19 ]
ret i32 %18
19: ; preds = %0, %19
%20 = call i32 @client_log(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%23 = call i32 (...) @getchar()
%24 = load i32, i32* %1
%25 = icmp ult i32 %24, 3
br i1 %25, label %17, label %19
}