#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 atoi(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char *, scalar_t__);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
int /*<<< orphan*/ system(char *);
int Menu(int *count, char *interface) {
  char input[32];
  int result;
  char cmd[30];
  printf("\033[H\033[J");
  printf("Welcome to sender. What do you want to do: \n");
  printf("[1] Send IPv4 packet \n");
  printf("[2] Send ICMP packet \n");
  fgets(input, 32, stdin);
  result = atoi(input);
  printf("\033[H\033[J");
  printf("Which interface do you want to use? Type name of interface.\n");
  sprintf(cmd, "/bin/ip link");
  system(cmd);
  printf("Name:");
  fgets(input, 32, stdin);
  memcpy(interface, input, strlen(input) - 1);
  printf("How many packets do you want to send? ");
  fgets(input, 32, stdin);
  *count = atoi(input);
  return result;
}


x86 assembly (clang, -O0):
<Menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
lea    0xe95(%rip),%rdi
call   1050 <printf@plt>
lea    0xea0(%rip),%rdi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1060 <fgets@plt>
lea    -0x30(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x34(%rbp)
lea    0xe26(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7c(%rip),%rdi
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x60(%rbp),%rdi
call   1040 <system@plt>
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2dcd(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1060 <fgets@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    %rax,%rdx
sub    $0x1,%rdx
call   1070 <memcpy@plt>
lea    0xe57(%rip),%rdi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2d7d(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1060 <fgets@plt>
lea    -0x30(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe75(%rip),%rbp
mov    %rbp,%rdi
call   1060 <printf@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e2a(%rip),%r13
mov    0x0(%r13),%edx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1090 <atoi@plt>
mov    %eax,%r12d
mov    %rbp,%rdi
call   1060 <printf@plt>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
movabs $0x2070692f6e69622f,%rax
69 70 20
mov    %rax,(%rsp)
movabs $0x6b6e696c207069,%rax
mov    %rax,0x5(%rsp)
mov    %rsp,%rdi
call   1050 <system@plt>
lea    0xdf5(%rip),%rdi
call   1060 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1080 <memcpy@plt>
lea    0xdc7(%rip),%rdi
call   1060 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1090 <atoi@plt>
mov    %eax,(%r14)
mov    %r12d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"\1B[H\1B[J\00"
@.str.1 = [45 x i8] c"Welcome to sender. What do you want to do: \0A\00"
@.str.2 = [23 x i8] c"[1] Send IPv4 packet \0A\00"
@.str.3 = [23 x i8] c"[2] Send ICMP packet \0A\00"
@stdin = global i32 0
@.str.4 = [61 x i8] c"Which interface do you want to use? Type name of interface.\0A\00"
@.str.5 = [13 x i8] c"/bin/ip link\00"
@.str.6 = [6 x i8] c"Name:\00"
@.str.7 = [39 x i8] c"How many packets do you want to send? \00"
define i32 @Menu(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca [32 x i8]
%6 = alloca i32
%7 = alloca [30 x i8]
store i32* %0, i32** %3
store i8* %1, i8** %4
%8 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 32, i32 %13)
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.4, i64 0, i64 0))
%19 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%20 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%21 = getelementptr inbounds [30 x i8], [30 x i8]* %7, i64 0, i64 0
%22 = call i32 @system(i8* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%25 = load i32, i32* @stdin
%26 = call i32 @fgets(i8* %24, i32 32, i32 %25)
%27 = load i8*, i8** %4
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%30 = call i64 @strlen(i8* %29)
%31 = sub nsw i64 %30, 1
%32 = call i32 @memcpy(i8* %27, i8* %28, i64 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%34 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%35 = load i32, i32* @stdin
%36 = call i32 @fgets(i8* %34, i32 32, i32 %35)
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%38 = call i32 @atoi(i8* %37)
%39 = load i32*, i32** %3
store i32 %38, i32* %39
%40 = load i32, i32* %6
ret i32 %40
}

LLVM IR (-O2):
@.str = [7 x i8] c"\1B[H\1B[J\00"
@stdin = global i32 0
@.str.5 = [13 x i8] c"/bin/ip link\00"
@.str.6 = [6 x i8] c"Name:\00"
@.str.7 = [39 x i8] c"How many packets do you want to send? \00"
@str = [44 x i8] c"Welcome to sender. What do you want to do: \00"
@str.8 = [22 x i8] c"[1] Send IPv4 packet \00"
@str.9 = [22 x i8] c"[2] Send ICMP packet \00"
@str.10 = [60 x i8] c"Which interface do you want to use? Type name of interface.\00"
define i32 @Menu(i32* nocapture writeonly %0, i8* %1) {
%3 = alloca [32 x i8]
%4 = alloca [30 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %5, i32 32, i32 %11)
%13 = call i32 @atoi(i8* %5)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.10, i64 0, i64 0))
%16 = call i32 @system(i8* %6)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%18 = load i32, i32* @stdin
%19 = call i32 @fgets(i8* %5, i32 32, i32 %18)
%20 = call i64 @strlen(i8* %5)
%21 = add nsw i64 %20, -1
%22 = call i32 @memcpy(i8* %1, i8* %5, i64 %21)
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0))
%24 = load i32, i32* @stdin
%25 = call i32 @fgets(i8* %5, i32 32, i32 %24)
%26 = call i32 @atoi(i8* %5)
store i32 %26, i32* %0
ret i32 %13
}