#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*/ ethernet_test();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ video_test();
int do_it(char choice) {
  int retval = 0;
  switch (choice) {
  case 'a':
  case 'A':
    printf("\n  selected:  Ethernet Connection Test\n");
    ethernet_test();
    break;
  case 'b':
  case 'B':
    printf("\n  selected:  Video Tests\n");
    video_test();
    break;
  case 'c':
  case 'C':
    printf("\n  selected:  USB Tests\n");
    break;
  case 'q':
  case 'Q':
    retval = 1;
    break;
  default:
    printf("\n  ERROR: Wrong input! Try again.");
    retval = 1;
    break;
  }
  return retval;
}


x86 assembly (clang, -O0):
<do_it>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x30,%eax
ja     11bc <do_it+0x8c>
mov    -0x10(%rbp),%rax
lea    0xe9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf4e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <ethernet_test@plt>
jmp    11cf <do_it+0x9f>
lea    0xf5e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <video_test@plt>
jmp    11cf <do_it+0x9f>
lea    0xf61(%rip),%rdi
call   1040 <printf@plt>
jmp    11cf <do_it+0x9f>
movl   $0x1,-0x8(%rbp)
jmp    11cf <do_it+0x9f>
lea    0xf5d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_it>:
push   %rbx
mov    $0x1,%ebx
add    $0xffffffbf,%edi
cmp    $0x30,%edi
ja     119c <do_it+0x5c>
lea    0xeab(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xfb3(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <ethernet_test@plt>
jmp    11a8 <do_it+0x68>
lea    0xf82(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <video_test@plt>
jmp    11a8 <do_it+0x68>
lea    0xf53(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    11a8 <do_it+0x68>
lea    0xf21(%rip),%rdi
call   1050 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [40 x i8] c"\0A selected: Ethernet Connection Test\0A\00"
@.str.1 = [27 x i8] c"\0A selected: Video Tests\0A\00"
@.str.2 = [25 x i8] c"\0A selected: USB Tests\0A\00"
@.str.3 = [34 x i8] c"\0A ERROR: Wrong input! Try again.\00"
define i32 @do_it(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
store i32 0, i32* %3
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
switch i32 %5, label %15 [
i32 97, label %6
i32 65, label %6
i32 98, label %9
i32 66, label %9
i32 99, label %12
i32 67, label %12
i32 113, label %14
i32 81, label %14
]
6: ; preds = %1, %1
%7 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (...) @ethernet_test()
br label %17
9: ; preds = %1, %1
%10 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (...) @video_test()
br label %17
12: ; preds = %1, %1
%13 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %17
14: ; preds = %1, %1
store i32 1, i32* %3
br label %17
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %17
17: ; preds = %15, %14, %12, %9, %6
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
@.str.3 = [34 x i8] c"\0A ERROR: Wrong input! Try again.\00"
@str = [24 x i8] c"\0A selected: USB Tests\00"
@str.4 = [26 x i8] c"\0A selected: Video Tests\00"
@str.5 = [39 x i8] c"\0A selected: Ethernet Connection Test\00"
define i32 @do_it(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %11 [
i32 97, label %3
i32 65, label %3
i32 98, label %6
i32 66, label %6
i32 99, label %9
i32 67, label %9
i32 113, label %13
i32 81, label %13
]
3: ; preds = %1, %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i32 (...) @ethernet_test()
br label %13
6: ; preds = %1, %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.4, i64 0, i64 0))
%8 = tail call i32 (...) @video_test()
br label %13
9: ; preds = %1, %1
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %13
11: ; preds = %1
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %1, %1, %11, %9, %6, %3
%14 = phi i32 [ 1, %11 ], [ 0, %9 ], [ 0, %6 ], [ 0, %3 ], [ 1, %1 ], [ 1, %1 ]
ret i32 %14
}