#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 */
unsigned int INADDR_NONE;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
unsigned int inet_addr(char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char *addr1 = "192.168.1.101";
  char *addr2 = "1.2.3.256";
  unsigned int conv_addr;
  conv_addr = inet_addr(addr1);
  if (conv_addr == INADDR_NONE)
    fprintf(stderr, "inet_addr() failed\n");
  else
    printf("network order int addr: %#x\n", conv_addr);
  conv_addr = inet_addr(addr2);
  if (conv_addr == INADDR_NONE)
    fprintf(stderr, "inet_addr() failed\n");
  else
    printf("network order int addr: %#x\n", conv_addr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeb6(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <inet_addr@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e76(%rip),%rcx
cmp    (%rcx),%eax
jne    1194 <main+0x64>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11a3 <main+0x73>
mov    -0x24(%rbp),%esi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <inet_addr@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%eax
jne    11db <main+0xab>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11ea <main+0xba>
mov    -0x24(%rbp),%esi
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1040 <inet_addr@plt>
mov    0x2ea4(%rip),%rbx
cmp    (%rbx),%eax
jne    115f <main+0x2f>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xec0(%rip),%rsi
call   1050 <fprintf@plt>
jmp    116d <main+0x3d>
lea    0xec6(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1040 <inet_addr@plt>
cmp    (%rbx),%eax
jne    1194 <main+0x64>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11a2 <main+0x72>
lea    0xe91(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"192.168.1.101\00"
@.str.1 = [10 x i8] c"1.2.3.256\00"
@INADDR_NONE = global i32 0
@stderr = global i32 0
@.str.2 = [20 x i8] c"inet_addr() failed\0A\00"
@.str.3 = [29 x i8] c"network order int addr: %#x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %7
%9 = load i8*, i8** %6
%10 = call i32 @inet_addr(i8* %9)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = load i32, i32* @INADDR_NONE
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %20
17: ; preds = %2
%18 = load i32, i32* %8
%19 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %14
%21 = load i8*, i8** %7
%22 = call i32 @inet_addr(i8* %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = load i32, i32* @INADDR_NONE
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %32
29: ; preds = %20
%30 = load i32, i32* %8
%31 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29, %26
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"192.168.1.101\00"
@.str.1 = [10 x i8] c"1.2.3.256\00"
@INADDR_NONE = global i32 0
@stderr = global i32 0
@.str.2 = [20 x i8] c"inet_addr() failed\0A\00"
@.str.3 = [29 x i8] c"network order int addr: %#x\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @INADDR_NONE
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %11
9: ; preds = %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %3)
br label %11
11: ; preds = %9, %6
%12 = tail call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @INADDR_NONE
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %20
18: ; preds = %11
%19 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %12)
br label %20
20: ; preds = %18, %15
ret i32 0
}