#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ test_ir();
int /*<<< orphan*/ test_key();
int /*<<< orphan*/ test_touch_screen();
int main() {
  static int i;
select:
  printf("Please select device:\n0.KeyBoard\n1.IR\n2.TouchScreen\n");
  scanf("%d", &i);
  switch (i) {
  case 0:
    test_key();
    break;
  case 1:
    test_ir();
    break;
  case 2:
    test_touch_screen();
    break;
  default:
    printf("Wrong device, Please select again!\n\n");
    break;
  }
  goto select;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
lea    0x2ed3(%rip),%rsi
call   1070 <scanf@plt>
mov    0x2ec8(%rip),%eax
mov    %eax,-0x8(%rbp)
test   %eax,%eax
je     11b6 <main+0x66>
jmp    1194 <main+0x44>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
je     11c2 <main+0x72>
jmp    11a5 <main+0x55>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     11ce <main+0x7e>
jmp    11da <main+0x8a>
mov    $0x0,%al
call   1030 <test_key@plt>
jmp    11e6 <main+0x96>
mov    $0x0,%al
call   1060 <test_ir@plt>
jmp    11e6 <main+0x96>
mov    $0x0,%al
call   1050 <test_touch_screen@plt>
jmp    11e6 <main+0x96>
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
jmp    115f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea4(%rip),%r14
lea    0xe9a(%rip),%r15
lea    0x2edf(%rip),%rbx
lea    0xec3(%rip),%r12
jmp    1187 <main+0x37>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <test_ir@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0x2eac(%rip),%eax
cmp    $0x2,%eax
je     11c0 <main+0x70>
cmp    $0x1,%eax
je     1180 <main+0x30>
test   %eax,%eax
jne    11d0 <main+0x80>
xor    %eax,%eax
call   1040 <test_key@plt>
jmp    1187 <main+0x37>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <test_touch_screen@plt>
jmp    1187 <main+0x37>
nopl   0x0(%rax)
mov    %r12,%rdi
call   1030 <puts@plt>
jmp    1187 <main+0x37>

LLVM IR (-O0):
@main.i = internal global i32 0
@.str = [53 x i8] c"Please select device:\0A0.KeyBoard\0A1.IR\0A2.TouchScreen\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [37 x i8] c"Wrong device, Please select again!\0A\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %14, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* @main.i)
%5 = load i32, i32* @main.i
switch i32 %5, label %12 [
i32 0, label %6
i32 1, label %8
i32 2, label %10
]
6: ; preds = %2
%7 = call i32 (...) @test_key()
br label %14
8: ; preds = %2
%9 = call i32 (...) @test_ir()
br label %14
10: ; preds = %2
%11 = call i32 (...) @test_touch_screen()
br label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %10, %8, %6
br label %2
}

LLVM IR (-O2):
@main.i = internal global i32 0
@.str.1 = [3 x i8] c"%d\00"
@str = [52 x i8] c"Please select device:\0A0.KeyBoard\0A1.IR\0A2.TouchScreen\00"
@str.3 = [36 x i8] c"Wrong device, Please select again!\0A\00"
define i32 @main() {
br label %1
1: ; preds = %13, %0
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* @main.i)
%4 = load i32, i32* @main.i
switch i32 %4, label %11 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
]
5: ; preds = %1
%6 = tail call i32 (...) @test_key()
br label %13
7: ; preds = %1
%8 = tail call i32 (...) @test_ir()
br label %13
9: ; preds = %1
%10 = tail call i32 (...) @test_touch_screen()
br label %13
11: ; preds = %1
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %9, %7, %5
br label %1
}