#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*/ bin2ip(unsigned int, char *);
int /*<<< orphan*/ ip2bin(char *, unsigned int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  unsigned int ip;
  char *ch;
  char *str;
  ch = (char *)malloc(25);
  printf("Ennter IP address\n");
  scanf("%s", ch);
  str = (char *)malloc(25);
  if (!ip2bin(ch, &ip))
    printf("Invalid ip address\n");
  printf("Ip address in binary form : %x\n", ip);
  bin2ip(ip, str);
  printf("Entered ip address is : %s", str);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x19,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xed9(%rip),%rdi
call   1050 <scanf@plt>
mov    $0x19,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <ip2bin@plt>
cmp    $0x0,%eax
jne    11bd <main+0x6d>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1070 <bin2ip@plt>
mov    -0x18(%rbp),%rsi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x19,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    $0x19,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <ip2bin@plt>
test   %eax,%eax
jne    11b6 <main+0x56>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%esi
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
mov    %r14,%rsi
call   1080 <bin2ip@plt>
lea    0xe45(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Ennter IP address\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [20 x i8] c"Invalid ip address\0A\00"
@.str.3 = [32 x i8] c"Ip address in binary form : %x\0A\00"
@.str.4 = [27 x i8] c"Entered ip address is : %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i64 @malloc(i32 25)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = load i8*, i8** %3
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i64 @malloc(i32 25)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %4
%12 = load i8*, i8** %3
%13 = call i32 @ip2bin(i8* %12, i32* %2)
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %0
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %2
%21 = load i8*, i8** %4
%22 = call i32 @bin2ip(i32 %20, i8* %21)
%23 = load i8*, i8** %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [32 x i8] c"Ip address in binary form : %x\0A\00"
@.str.4 = [27 x i8] c"Entered ip address is : %s\00"
@str = [18 x i8] c"Ennter IP address\00"
@str.5 = [19 x i8] c"Invalid ip address\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i64 @malloc(i32 25)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = tail call i64 @malloc(i32 25)
%8 = inttoptr i64 %7 to i8*
%9 = call i32 @ip2bin(i8* %4, i32* %1)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
br label %13
13: ; preds = %11, %0
%14 = load i32, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %1
%17 = call i32 @bin2ip(i32 %16, i8* %8)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %8)
ret i32 0
}