#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 */
struct in_addr {
  int dummy;
};
struct ether_addr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
char *ether_ntoa(struct ether_addr *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ get_ip_address(char *, struct in_addr *);
scalar_t__ get_mac_address(char *, unsigned char *);
scalar_t__ get_mac_address_struct(char *, struct ether_addr *);
char *inet_ntoa(struct in_addr);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char arr[4] = {192, 168, 1, 4};
  struct in_addr *arrstruct;
  struct in_addr network;
  struct ether_addr ether;
  int s = (14 + 28);
  int i = 0;
  printf("Size of a struct arp : %d bytes\n", s);
  char interface[] = "wlp3s0";
  unsigned char mac[6] = {'0'};
  struct in_addr ipaddr;
  if (get_mac_address(interface, mac) == 0) {
    printf("MAC Address : %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1],
           mac[2], mac[3], mac[4], mac[5]);
  } else {
    printf("Unable to get mac address ... \n");
    exit(EXIT_FAILURE);
  }
  if (get_mac_address_struct(interface, &ether) == 0) {
    printf("MAC Address with Struct : %s\n", ether_ntoa(&ether));
  }
  get_ip_address(interface, &ipaddr);
  if (1) {
    printf("IP Address : %s\n", inet_ntoa(ipaddr));
  } else {
    printf("Unable to get ip address ... \n");
    exit(EXIT_FAILURE);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe74(%rip),%eax
mov    %eax,-0x14(%rbp)
movl   $0x2a,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x34(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0xe71(%rip),%eax
mov    %eax,-0x3f(%rbp)
mov    0xe6b(%rip),%ax
mov    %ax,-0x3b(%rbp)
mov    0xe63(%rip),%al
mov    %al,-0x39(%rbp)
mov    0xed7(%rip),%eax
mov    %eax,-0x45(%rbp)
mov    0xed1(%rip),%ax
mov    %ax,-0x41(%rbp)
lea    -0x3f(%rbp),%rdi
lea    -0x45(%rbp),%rsi
call   1040 <get_mac_address@plt>
cmp    $0x0,%rax
jne    1226 <main+0xb6>
movzbl -0x45(%rbp),%esi
movzbl -0x44(%rbp),%edx
movzbl -0x43(%rbp),%ecx
movzbl -0x42(%rbp),%r8d
movzbl -0x41(%rbp),%r9d
movzbl -0x40(%rbp),%eax
lea    0xe15(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1242 <main+0xd2>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
lea    -0x3f(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <get_mac_address_struct@plt>
cmp    $0x0,%rax
jne    1273 <main+0x103>
lea    -0x30(%rbp),%rdi
call   1050 <ether_ntoa@plt>
mov    %rax,%rsi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x3f(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1080 <get_ip_address@plt>
mov    -0x50(%rbp),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2d38(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0xe75(%rip),%rdi
mov    $0x2a,%esi
xor    %eax,%eax
call   1080 <printf@plt>
movl   $0x307333,0x13(%rsp)
movl   $0x33706c77,0x10(%rsp)
33
movw   $0x0,0xc(%rsp)
movl   $0x30,0x8(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <get_mac_address@plt>
test   %rax,%rax
jne    1265 <main+0xe5>
movzbl 0x8(%rsp),%esi
movzbl 0x9(%rsp),%edx
movzbl 0xa(%rsp),%ecx
movzbl 0xb(%rsp),%r8d
movzbl 0xc(%rsp),%r9d
movzbl 0xd(%rsp),%eax
mov    %eax,(%rsp)
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x10(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   1070 <get_mac_address_struct@plt>
test   %rax,%rax
jne    122e <main+0xae>
lea    0x20(%rsp),%rdi
call   1060 <ether_ntoa@plt>
lea    0xe31(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x10(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1090 <get_ip_address@plt>
mov    0x18(%rsp),%edi
call   1040 <inet_ntoa@plt>
lea    0xe26(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
ret
lea    0xe18(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
%struct.ether_addr = type { i32 }
@__const.main.arr = [4 x i8] c"\C0\A8\01\04"
@.str = [33 x i8] c"Size of a struct arp : %d bytes\0A\00"
@__const.main.interface = [7 x i8] c"wlp3s0\00"
@__const.main.mac = [6 x i8] c"0\00\00\00\00\00"
@.str.1 = [45 x i8] c"MAC Address : %02X:%02X:%02X:%02X:%02X:%02X\0A\00"
@.str.2 = [32 x i8] c"Unable to get mac address ... \0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [30 x i8] c"MAC Address with Struct : %s\0A\00"
@.str.4 = [17 x i8] c"IP Address : %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i8]
%7 = alloca %struct.in_addr*
%8 = alloca %struct.in_addr
%9 = alloca %struct.ether_addr
%10 = alloca i32
%11 = alloca i32
%12 = alloca [7 x i8]
%13 = alloca [6 x i8]
%14 = alloca %struct.in_addr
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = bitcast [4 x i8]* %6 to i8*
store i32 42, i32* %10
store i32 0, i32* %11
%16 = load i32, i32* %10
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = bitcast [7 x i8]* %12 to i8*
%19 = bitcast [6 x i8]* %13 to i8*
%20 = getelementptr inbounds [7 x i8], [7 x i8]* %12, i64 0, i64 0
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 0
%22 = call i64 @get_mac_address(i8* %20, i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %44
24: ; preds = %2
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 0
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 1
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 2
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 3
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 4
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 5
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %30, i32 %33, i32 %36, i32 %39, i32 %42)
br label %48
44: ; preds = %2
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %24
%49 = getelementptr inbounds [7 x i8], [7 x i8]* %12, i64 0, i64 0
%50 = call i64 @get_mac_address_struct(i8* %49, %struct.ether_addr* %9)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = call i8* @ether_ntoa(%struct.ether_addr* %9)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %53)
br label %55
55: ; preds = %52, %48
%56 = getelementptr inbounds [7 x i8], [7 x i8]* %12, i64 0, i64 0
%57 = call i32 @get_ip_address(i8* %56, %struct.in_addr* %14)
%58 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %14, i32 0, i32 0
%59 = load i32, i32* %58
%60 = call i8* @inet_ntoa(i32 %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %60)
%62 = load i32, i32* @EXIT_SUCCESS
ret i32 %62
}

LLVM IR (-O2):
%struct.ether_addr = type { i32 }
%struct.in_addr = type { i32 }
@.str = [33 x i8] c"Size of a struct arp : %d bytes\0A\00"
@__const.main.interface = [7 x i8] c"wlp3s0\00"
@__const.main.mac = [6 x i8] c"0\00\00\00\00\00"
@.str.1 = [45 x i8] c"MAC Address : %02X:%02X:%02X:%02X:%02X:%02X\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [30 x i8] c"MAC Address with Struct : %s\0A\00"
@.str.4 = [17 x i8] c"IP Address : %s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [31 x i8] c"Unable to get mac address ... \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.ether_addr
%4 = alloca [7 x i8]
%5 = alloca [6 x i8]
%6 = alloca %struct.in_addr
%7 = bitcast %struct.ether_addr* %3 to i8*
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 42)
%9 = getelementptr inbounds [7 x i8], [7 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%11 = bitcast %struct.in_addr* %6 to i8*
%12 = call i64 @get_mac_address(i8* %9, i8* %10)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %35
14: ; preds = %2
%15 = load i8, i8* %10
%16 = zext i8 %15 to i32
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 1
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 2
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 3
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 4
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 5
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %19, i32 %22, i32 %25, i32 %28, i32 %31)
%33 = call i64 @get_mac_address_struct(i8* %9, %struct.ether_addr* %3)
%34 = icmp eq i64 %33, 0
br i1 %34, label %39, label %42
35: ; preds = %2
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %14
%40 = call i8* @ether_ntoa(%struct.ether_addr* %3)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %39, %14
%43 = call i32 @get_ip_address(i8* %9, %struct.in_addr* %6)
%44 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i64 0, i32 0
%45 = load i32, i32* %44
%46 = call i8* @inet_ntoa(i32 %45)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %46)
%48 = load i32, i32* @EXIT_SUCCESS
ret i32 %48
}