#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*/ ClearInput();
char getchar();
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
void ShowMsgAndInput(char *input, char *input_str) {
  printf("0 : init\r\n");
  printf("1 : SYSINFO\r\n");
  printf("2 : SYSSTATUS\r\n");
  printf("3 : SYSTRAFFIC\r\n");
  printf("4 : SHOW WAN\r\n");
  printf("5 : SHOW ADSL\r\n");
  printf("6 : SHOW LAN\r\n");
  printf("7 : PVC DISP\r\n");
  printf("8 : ADSL STATUS\r\n");
  printf("a : add PVC (VPI/VCI)\r\n");
  printf("v : add a default PVC (2 1234 0 35 0 0)\r\n");
  printf("i : add PVCs (1 : 35, 2 : 36, 3 : 37)\r\n");
  printf("s : show PVCs (1 : 35, 2 : 36, 3 : 37)\r\n");
  printf("c : enter user command\r\n");
  printf("q : quit\r\n");
  printf("\r\nYour command : ");
  *input = getchar();
  ClearInput();
  printf("Input is %c\r\n", *input);
  if (*input == 'a') {
    printf("Idx VID VPI VCI Encap Mode (3 1235 0 34 0 0) : ");
    gets(input_str);
    printf("PVC is %s\r\n", input_str);
  } else if (*input == 'c') {
    printf("User command : ");
    gets(input_str);
    printf("Cmd is %s\r\n", input_str);
  } else if (*input == 'v') {
    strcpy(input_str, "2 1234 0 35 0 0");
  }
}


x86 assembly (clang, -O0):
<ShowMsgAndInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf0a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf07(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    $0x0,%al
call   1040 <ClearInput@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jne    12a9 <ShowMsgAndInput+0x159>
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <gets@plt>
mov    -0x10(%rbp),%rsi
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1311 <ShowMsgAndInput+0x1c1>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    12e7 <ShowMsgAndInput+0x197>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <gets@plt>
mov    -0x10(%rbp),%rsi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    130c <ShowMsgAndInput+0x1bc>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x76,%eax
jne    1307 <ShowMsgAndInput+0x1b7>
mov    -0x10(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1030 <strcpy@plt>
jmp    130c <ShowMsgAndInput+0x1bc>
jmp    1311 <ShowMsgAndInput+0x1c1>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShowMsgAndInput>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xf17(%rip),%rdi
call   1040 <puts@plt>
lea    0xf15(%rip),%rdi
call   1040 <puts@plt>
lea    0xf16(%rip),%rdi
call   1040 <puts@plt>
lea    0xf19(%rip),%rdi
call   1040 <puts@plt>
lea    0xf1d(%rip),%rdi
call   1040 <puts@plt>
lea    0xf1f(%rip),%rdi
call   1040 <puts@plt>
lea    0xf22(%rip),%rdi
call   1040 <puts@plt>
lea    0xf24(%rip),%rdi
call   1040 <puts@plt>
lea    0xf26(%rip),%rdi
call   1040 <puts@plt>
lea    0xf2b(%rip),%rdi
call   1040 <puts@plt>
lea    0xf36(%rip),%rdi
call   1040 <puts@plt>
lea    0xf53(%rip),%rdi
call   1040 <puts@plt>
lea    0xf6e(%rip),%rdi
call   1040 <puts@plt>
lea    0xf8a(%rip),%rdi
call   1040 <puts@plt>
lea    0xf96(%rip),%rdi
call   1040 <puts@plt>
lea    0xddb(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %al,(%rbx)
xor    %eax,%eax
call   1050 <ClearInput@plt>
movsbl (%rbx),%esi
lea    0xdcc(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx),%al
cmp    $0x76,%al
je     127a <ShowMsgAndInput+0x11a>
cmp    $0x63,%al
je     1290 <ShowMsgAndInput+0x130>
cmp    $0x61,%al
jne    12be <ShowMsgAndInput+0x15e>
lea    0xdbe(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1080 <gets@plt>
lea    0xdd8(%rip),%rdi
jmp    12ad <ShowMsgAndInput+0x14d>
lea    0xdf7(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <strcpy@plt>
lea    0xdc5(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
call   1080 <gets@plt>
lea    0xdbf(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"0 : init\0D\0A\00"
@.str.1 = [14 x i8] c"1 : SYSINFO\0D\0A\00"
@.str.2 = [16 x i8] c"2 : SYSSTATUS\0D\0A\00"
@.str.3 = [17 x i8] c"3 : SYSTRAFFIC\0D\0A\00"
@.str.4 = [15 x i8] c"4 : SHOW WAN\0D\0A\00"
@.str.5 = [16 x i8] c"5 : SHOW ADSL\0D\0A\00"
@.str.6 = [15 x i8] c"6 : SHOW LAN\0D\0A\00"
@.str.7 = [15 x i8] c"7 : PVC DISP\0D\0A\00"
@.str.8 = [18 x i8] c"8 : ADSL STATUS\0D\0A\00"
@.str.9 = [24 x i8] c"a : add PVC (VPI/VCI)\0D\0A\00"
@.str.10 = [42 x i8] c"v : add a default PVC (2 1234 0 35 0 0)\0D\0A\00"
@.str.11 = [40 x i8] c"i : add PVCs (1 : 35, 2 : 36, 3 : 37)\0D\0A\00"
@.str.12 = [41 x i8] c"s : show PVCs (1 : 35, 2 : 36, 3 : 37)\0D\0A\00"
@.str.13 = [25 x i8] c"c : enter user command\0D\0A\00"
@.str.14 = [11 x i8] c"q : quit\0D\0A\00"
@.str.15 = [18 x i8] c"\0D\0AYour command : \00"
@.str.16 = [14 x i8] c"Input is %c\0D\0A\00"
@.str.17 = [48 x i8] c"Idx VID VPI VCI Encap Mode (3 1235 0 34 0 0) : \00"
@.str.18 = [12 x i8] c"PVC is %s\0D\0A\00"
@.str.19 = [16 x i8] c"User command : \00"
@.str.20 = [12 x i8] c"Cmd is %s\0D\0A\00"
@.str.21 = [16 x i8] c"2 1234 0 35 0 0\00"
define void @ShowMsgAndInput(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.10, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.12, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0))
%21 = call signext i8 (...) @getchar()
%22 = load i8*, i8** %3
store i8 %21, i8* %22
%23 = call i32 (...) @ClearInput()
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i32 %26)
%28 = load i8*, i8** %3
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 97
br i1 %31, label %32, label %38
32: ; preds = %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.17, i64 0, i64 0))
%34 = load i8*, i8** %4
%35 = call i32 @gets(i8* %34)
%36 = load i8*, i8** %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i64 0, i64 0), i8* %36)
br label %59
38: ; preds = %2
%39 = load i8*, i8** %3
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 99
br i1 %42, label %43, label %49
43: ; preds = %38
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.19, i64 0, i64 0))
%45 = load i8*, i8** %4
%46 = call i32 @gets(i8* %45)
%47 = load i8*, i8** %4
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.20, i64 0, i64 0), i8* %47)
br label %58
49: ; preds = %38
%50 = load i8*, i8** %3
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 118
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i8*, i8** %4
%56 = call i32 @strcpy(i8* %55, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.21, i64 0, i64 0))
br label %57
57: ; preds = %54, %49
br label %58
58: ; preds = %57, %43
br label %59
59: ; preds = %58, %32
ret void
}

LLVM IR (-O2):
@.str.15 = [18 x i8] c"\0D\0AYour command : \00"
@.str.16 = [14 x i8] c"Input is %c\0D\0A\00"
@.str.17 = [48 x i8] c"Idx VID VPI VCI Encap Mode (3 1235 0 34 0 0) : \00"
@.str.18 = [12 x i8] c"PVC is %s\0D\0A\00"
@.str.19 = [16 x i8] c"User command : \00"
@.str.20 = [12 x i8] c"Cmd is %s\0D\0A\00"
@.str.21 = [16 x i8] c"2 1234 0 35 0 0\00"
@str = [10 x i8] c"0 : init\0D\00"
@str.22 = [13 x i8] c"1 : SYSINFO\0D\00"
@str.23 = [15 x i8] c"2 : SYSSTATUS\0D\00"
@str.24 = [16 x i8] c"3 : SYSTRAFFIC\0D\00"
@str.25 = [14 x i8] c"4 : SHOW WAN\0D\00"
@str.26 = [15 x i8] c"5 : SHOW ADSL\0D\00"
@str.27 = [14 x i8] c"6 : SHOW LAN\0D\00"
@str.28 = [14 x i8] c"7 : PVC DISP\0D\00"
@str.29 = [17 x i8] c"8 : ADSL STATUS\0D\00"
@str.30 = [23 x i8] c"a : add PVC (VPI/VCI)\0D\00"
@str.31 = [41 x i8] c"v : add a default PVC (2 1234 0 35 0 0)\0D\00"
@str.32 = [39 x i8] c"i : add PVCs (1 : 35, 2 : 36, 3 : 37)\0D\00"
@str.33 = [40 x i8] c"s : show PVCs (1 : 35, 2 : 36, 3 : 37)\0D\00"
@str.34 = [24 x i8] c"c : enter user command\0D\00"
@str.35 = [10 x i8] c"q : quit\0D\00"
define void @ShowMsgAndInput(i8* nocapture %0, i8* %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.22, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.23, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.24, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.25, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.26, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.27, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.28, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.29, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.30, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.31, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.32, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.33, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.34, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.35, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0))
%19 = tail call signext i8 (...) @getchar()
store i8 %19, i8* %0
%20 = tail call i32 (...) @ClearInput()
%21 = load i8, i8* %0
%22 = sext i8 %21 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.16, i64 0, i64 0), i32 %22)
%24 = load i8, i8* %0
switch i8 %24, label %35 [
i8 97, label %25
i8 99, label %29
i8 118, label %33
]
25: ; preds = %2
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.17, i64 0, i64 0))
%27 = tail call i32 @gets(i8* %1)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i64 0, i64 0), i8* %1)
br label %35
29: ; preds = %2
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.19, i64 0, i64 0))
%31 = tail call i32 @gets(i8* %1)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.20, i64 0, i64 0), i8* %1)
br label %35
33: ; preds = %2
%34 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.21, i64 0, i64 0))
br label %35
35: ; preds = %2, %29, %33, %25
ret void
}