#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*/ directLookup();
int /*<<< orphan*/ get_dns_servers();
int /*<<< orphan*/ ipv6Lookup();
int /*<<< orphan*/ mxLookup();
int /*<<< orphan*/ nsLookup();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ reverseLookup();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ soaLookup();
int main(int argc, char *argv[]) {
  unsigned char hostname[100];
  int choice;
  get_dns_servers();
  printf("enter \n1 for direct lookup\n2 for reverse lookup\n3 for start of "
         "authority\n4 for ipv6 address\n");
  printf("5 for MX record\n6 for NS record\n");
  printf("choice = ");
  scanf("%d", &choice);
  switch (choice) {
  case 1:
    directLookup();
    break;
  case 2:
    reverseLookup();
    break;
  case 3:
    soaLookup();
    break;
  case 4:
    ipv6Lookup();
    break;
  case 5:
    mxLookup();
    break;
  case 6:
    nsLookup();
    break;
  default:
    printf("choice entered is invalid\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
call   1060 <get_dns_servers@plt>
lea    0xe61(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1050 <printf@plt>
lea    0xec7(%rip),%rdi
call   1050 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x84(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x84(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x90(%rbp)
sub    $0x5,%eax
ja     1261 <main+0xd1>
mov    -0x90(%rbp),%rax
lea    0xdf0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <directLookup@plt>
jmp    126d <main+0xdd>
mov    $0x0,%al
call   1090 <reverseLookup@plt>
jmp    126d <main+0xdd>
mov    $0x0,%al
call   1040 <soaLookup@plt>
jmp    126d <main+0xdd>
mov    $0x0,%al
call   10b0 <ipv6Lookup@plt>
jmp    126d <main+0xdd>
mov    $0x0,%al
call   1080 <mxLookup@plt>
jmp    126d <main+0xdd>
mov    $0x0,%al
call   1070 <nsLookup@plt>
jmp    126d <main+0xdd>
lea    0xe3b(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1070 <get_dns_servers@plt>
lea    0xe76(%rip),%rdi
call   1040 <puts@plt>
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
lea    0xe51(%rip),%rdi
call   1060 <printf@plt>
lea    0xe4f(%rip),%rdi
lea    0x4(%rsp),%rsi
call   10b0 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x5,%eax
ja     1202 <main+0x62>
lea    0xe10(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1030 <directLookup@plt>
jmp    123b <main+0x9b>
lea    0xe98(%rip),%rdi
call   1040 <puts@plt>
jmp    123b <main+0x9b>
xor    %eax,%eax
call   10a0 <reverseLookup@plt>
jmp    123b <main+0x9b>
xor    %eax,%eax
call   1050 <soaLookup@plt>
jmp    123b <main+0x9b>
xor    %eax,%eax
call   10c0 <ipv6Lookup@plt>
jmp    123b <main+0x9b>
xor    %eax,%eax
call   1090 <mxLookup@plt>
jmp    123b <main+0x9b>
xor    %eax,%eax
call   1080 <nsLookup@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [93 x i8] c"enter \0A1 for direct lookup\0A2 for reverse lookup\0A3 for start of authority\0A4 for ipv6 address\0A\00"
@.str.1 = [33 x i8] c"5 for MX record\0A6 for NS record\0A\00"
@.str.2 = [10 x i8] c"choice = \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [27 x i8] c"choice entered is invalid\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @get_dns_servers()
%9 = call i32 @printf(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%13 = load i32, i32* %7
switch i32 %13, label %26 [
i32 1, label %14
i32 2, label %16
i32 3, label %18
i32 4, label %20
i32 5, label %22
i32 6, label %24
]
14: ; preds = %2
%15 = call i32 (...) @directLookup()
br label %28
16: ; preds = %2
%17 = call i32 (...) @reverseLookup()
br label %28
18: ; preds = %2
%19 = call i32 (...) @soaLookup()
br label %28
20: ; preds = %2
%21 = call i32 (...) @ipv6Lookup()
br label %28
22: ; preds = %2
%23 = call i32 (...) @mxLookup()
br label %28
24: ; preds = %2
%25 = call i32 (...) @nsLookup()
br label %28
26: ; preds = %2
%27 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %24, %22, %20, %18, %16, %14
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [10 x i8] c"choice = \00"
@.str.3 = [3 x i8] c"%d\00"
@str = [92 x i8] c"enter \0A1 for direct lookup\0A2 for reverse lookup\0A3 for start of authority\0A4 for ipv6 address\00"
@str.5 = [32 x i8] c"5 for MX record\0A6 for NS record\00"
@str.6 = [26 x i8] c"choice entered is invalid\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (...) @get_dns_servers()
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([92 x i8], [92 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
switch i32 %10, label %23 [
i32 1, label %11
i32 2, label %13
i32 3, label %15
i32 4, label %17
i32 5, label %19
i32 6, label %21
]
11: ; preds = %2
%12 = call i32 (...) @directLookup()
br label %25
13: ; preds = %2
%14 = call i32 (...) @reverseLookup()
br label %25
15: ; preds = %2
%16 = call i32 (...) @soaLookup()
br label %25
17: ; preds = %2
%18 = call i32 (...) @ipv6Lookup()
br label %25
19: ; preds = %2
%20 = call i32 (...) @mxLookup()
br label %25
21: ; preds = %2
%22 = call i32 (...) @nsLookup()
br label %25
23: ; preds = %2
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.6, i64 0, i64 0))
br label %25
25: ; preds = %23, %21, %19, %17, %15, %13, %11
ret i32 0
}