#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
typedef struct sockaddr sockaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ inet_addr(char *);
int stub1(char *, struct sockaddr *, void *);
int if_map(int (*func)(char *, struct sockaddr *, void *), void *arg) {
  int err = 0;
  char address[] = "192.168.12.211";
  struct sockaddr_in addr;
  addr.sin_family = AF_INET;
  addr.sin_addr.s_addr = inet_addr(address);
  if ((*func)("en", (struct sockaddr *)&addr, arg) == -1)
    err = -1;
  return err;
}


x86 assembly (clang, -O0):
<if_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xed2(%rip),%rax
mov    %rax,-0x23(%rbp)
mov    0xed0(%rip),%eax
mov    %eax,-0x1b(%rbp)
mov    0xeca(%rip),%ax
mov    %ax,-0x17(%rbp)
mov    0xec2(%rip),%al
mov    %al,-0x15(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x23(%rbp),%rdi
call   1030 <inet_addr@plt>
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
lea    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe95(%rip),%rdi
call   *%rax
cmp    $0xffffffff,%eax
jne    118c <if_map+0x7c>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<if_map>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movabs $0x3131322e32312e,%rax
mov    %rax,0xf(%rsp)
movabs $0x2e3836312e323931,%rax
36 38 2e
mov    %rax,0x8(%rsp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <inet_addr@plt>
mov    %eax,(%rsp)
lea    0xeb3(%rip),%rdi
mov    %rsp,%rsi
mov    %rbx,%rdx
call   *%r14
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
sete   %cl
neg    %ecx
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr = type opaque
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@__const.if_map.address = [15 x i8] c"192.168.12.211\00"
@AF_INET = global i32 0
@.str = [3 x i8] c"en\00"
define i32 @if_map(i32 (i8*, %struct.sockaddr*, i8*)* %0, i8* %1) {
%3 = alloca i32 (i8*, %struct.sockaddr*, i8*)*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [15 x i8]
%7 = alloca %struct.sockaddr_in
store i32 (i8*, %struct.sockaddr*, i8*)* %0, i32 (i8*, %struct.sockaddr*, i8*)** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%8 = bitcast [15 x i8]* %6 to i8*
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
store i32 %9, i32* %10
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %6, i64 0, i64 0
%12 = call i32 @inet_addr(i8* %11)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 0
store i32 %12, i32* %14
%15 = load i32 (i8*, %struct.sockaddr*, i8*)*, i32 (i8*, %struct.sockaddr*, i8*)** %3
%16 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%17 = load i8*, i8** %4
%18 = call i32 %15(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.sockaddr* %16, i8* %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %2
store i32 -1, i32* %5
br label %21
21: ; preds = %20, %2
%22 = load i32, i32* %5
ret i32 %22
}

LLVM IR (-O2):
%struct.sockaddr = type opaque
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@__const.if_map.address = [15 x i8] c"192.168.12.211\00"
@AF_INET = global i32 0
@.str = [3 x i8] c"en\00"
define i32 @if_map(i32 (i8*, %struct.sockaddr*, i8*)* nocapture %0, i8* %1) {
%3 = alloca [15 x i8]
%4 = alloca %struct.sockaddr_in
%5 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.sockaddr_in* %4 to i8*
%7 = load i32, i32* @AF_INET
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %7, i32* %8
%9 = call i32 @inet_addr(i8* %5)
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i32 %9, i32* %10
%11 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%12 = call i32 %0(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.sockaddr* %11, i8* %1)
%13 = icmp eq i32 %12, -1
%14 = sext i1 %13 to i32
ret i32 %14
}