#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ socketquery(int);
void load_menu(void) {
  int choice;
  do {
    printf("What's your requirement? 1.DNS 2. QUERY 3. QUIT: ");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("Input URL address: ");
      socketquery(choice);
      break;
    case 2:
      printf("Input student ID: ");
      socketquery(choice);
      break;
    case 3:
      printf("Quitting program!\n");
      exit(0);
      break;
    default:
      printf("Invalid choice!\n");
      break;
    }
  } while (choice != 3);
}


x86 assembly (clang, -O0):
<load_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     119a <load_menu+0x5a>
jmp    1178 <load_menu+0x38>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     11b3 <load_menu+0x73>
jmp    1189 <load_menu+0x49>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
je     11cc <load_menu+0x8c>
jmp    11df <load_menu+0x9f>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
call   1030 <socketquery@plt>
jmp    11eb <load_menu+0xab>
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%edi
call   1030 <socketquery@plt>
jmp    11eb <load_menu+0xab>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
jmp    11f0 <load_menu+0xb0>
cmpl   $0x3,-0x4(%rbp)
jne    1148 <load_menu+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%r14
lea    0xec9(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xec0(%rip),%r12
lea    0xecd(%rip),%r13
lea    0xeeb(%rip),%rbp
jmp    11a8 <load_menu+0x58>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   1050 <printf@plt>
mov    0x4(%rsp),%edi
call   1030 <socketquery@plt>
cmpl   $0x3,0x4(%rsp)
je     11e5 <load_menu+0x95>
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     1190 <load_menu+0x40>
cmp    $0x2,%eax
je     11e0 <load_menu+0x90>
cmp    $0x3,%eax
je     11f4 <load_menu+0xa4>
mov    %rbp,%rdi
call   1040 <puts@plt>
cmpl   $0x3,0x4(%rsp)
jne    11a8 <load_menu+0x58>
jmp    11e5 <load_menu+0x95>
nop
mov    %r13,%rdi
jmp    1193 <load_menu+0x43>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe61(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"What's your requirement? 1.DNS 2. QUERY 3. QUIT: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Input URL address: \00"
@.str.3 = [19 x i8] c"Input student ID: \00"
@.str.4 = [19 x i8] c"Quitting program!\0A\00"
@.str.5 = [17 x i8] c"Invalid choice!\0A\00"
define void @load_menu() {
%1 = alloca i32
br label %2
2: ; preds = %20, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 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* %1)
%5 = load i32, i32* %1
switch i32 %5, label %17 [
i32 1, label %6
i32 2, label %10
i32 3, label %14
]
6: ; preds = %2
%7 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = call i32 @socketquery(i32 %8)
br label %19
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = call i32 @socketquery(i32 %12)
br label %19
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %19
19: ; preds = %17, %10, %6
br label %20
20: ; preds = %19
%21 = load i32, i32* %1
%22 = icmp ne i32 %21, 3
br i1 %22, label %2, label %23
23: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [50 x i8] c"What's your requirement? 1.DNS 2. QUERY 3. QUIT: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Input URL address: \00"
@.str.3 = [19 x i8] c"Input student ID: \00"
@str = [18 x i8] c"Quitting program!\00"
@str.6 = [16 x i8] c"Invalid choice!\00"
define void @load_menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %20, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
switch i32 %6, label %18 [
i32 1, label %7
i32 2, label %11
i32 3, label %15
]
7: ; preds = %3
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = call i32 @socketquery(i32 %9)
br label %20
11: ; preds = %3
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = call i32 @socketquery(i32 %13)
br label %20
15: ; preds = %3
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %3
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
br label %20
20: ; preds = %7, %11, %18
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 3
br i1 %22, label %23, label %3
23: ; preds = %20
ret void
}