#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 {
  void *s_addr;
};

/* Variables and functions */
int /*<<< orphan*/ IP_MULTICAST_IF;
void *inet_addr(char *);
int /*<<< orphan*/ test_in_addr(int /*<<< orphan*/, char *, struct in_addr,
                                struct in_addr, struct in_addr, char *, int,
                                int);
void test_if(int raw_sock, int tcp_sock, int udp_sock) {
  struct in_addr defaultv, modifiedv, fakev;
  defaultv.s_addr = inet_addr("0.0.0.0");
  modifiedv.s_addr = inet_addr("127.0.0.1");
  fakev.s_addr = inet_addr("255.255.255.255");
  test_in_addr(IP_MULTICAST_IF, "IP_MULTICAST_IF", defaultv, modifiedv, fakev,
               "raw_sock", raw_sock, 0);
  test_in_addr(IP_MULTICAST_IF, "IP_MULTICAST_IF", defaultv, modifiedv, fakev,
               "tcp_sock", tcp_sock, 0x00000000);
  test_in_addr(IP_MULTICAST_IF, "IP_MULTICAST_IF", defaultv, modifiedv, fakev,
               "udp_sock", udp_sock, 0);
}


x86 assembly (clang, -O0):
<test_if>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    0xec8(%rip),%rdi
call   1030 <inet_addr@plt>
mov    %rax,-0x18(%rbp)
lea    0xec0(%rip),%rdi
call   1030 <inet_addr@plt>
mov    %rax,-0x20(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <inet_addr@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%eax
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xea2(%rip),%rsi
lea    0xeab(%rip),%r9
xor    %r10d,%r10d
mov    %eax,(%rsp)
movl   $0x0,0x8(%rsp)
call   1040 <test_in_addr@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%eax
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe69(%rip),%rsi
lea    0xe7b(%rip),%r9
xor    %r10d,%r10d
mov    %eax,(%rsp)
movl   $0x0,0x8(%rsp)
call   1040 <test_in_addr@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%eax
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
lea    0xe30(%rip),%rsi
lea    0xe4b(%rip),%r9
xor    %r10d,%r10d
mov    %eax,(%rsp)
movl   $0x0,0x8(%rsp)
call   1040 <test_in_addr@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_if>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %edi,%r14d
lea    0xebe(%rip),%rdi
call   1030 <inet_addr@plt>
mov    %rax,%r12
lea    0xeb7(%rip),%rdi
call   1030 <inet_addr@plt>
mov    %rax,%r13
lea    0xeb2(%rip),%rdi
call   1030 <inet_addr@plt>
mov    %rax,%rbx
mov    0x2e79(%rip),%r15
mov    (%r15),%edi
lea    0xea9(%rip),%rbp
lea    0xeb2(%rip),%r9
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rax,%r8
push   $0x0
push   %r14
call   1040 <test_in_addr@plt>
add    $0x10,%rsp
mov    (%r15),%edi
lea    0xe98(%rip),%r9
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
push   $0x0
push   0x10(%rsp)
call   1040 <test_in_addr@plt>
add    $0x10,%rsp
mov    (%r15),%edi
lea    0xe7c(%rip),%r9
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
push   $0x0
push   0x18(%rsp)
call   1040 <test_in_addr@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.in_addr = type { i8* }
@.str = [8 x i8] c"0.0.0.0\00"
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [16 x i8] c"255.255.255.255\00"
@IP_MULTICAST_IF = global i32 0
@.str.3 = [16 x i8] c"IP_MULTICAST_IF\00"
@.str.4 = [9 x i8] c"raw_sock\00"
@.str.5 = [9 x i8] c"tcp_sock\00"
@.str.6 = [9 x i8] c"udp_sock\00"
define void @test_if(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.in_addr
%8 = alloca %struct.in_addr
%9 = alloca %struct.in_addr
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = call i8* @inet_addr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
store i8* %10, i8** %11
%12 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
store i8* %12, i8** %13
%14 = call i8* @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
store i8* %14, i8** %15
%16 = load i32, i32* @IP_MULTICAST_IF
%17 = load i32, i32* %4
%18 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%19 = load i8*, i8** %18
%20 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
%21 = load i8*, i8** %20
%22 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = call i32 @test_in_addr(i32 %16, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %19, i8* %21, i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %17, i32 0)
%25 = load i32, i32* @IP_MULTICAST_IF
%26 = load i32, i32* %5
%27 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%28 = load i8*, i8** %27
%29 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
%30 = load i8*, i8** %29
%31 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
%32 = load i8*, i8** %31
%33 = call i32 @test_in_addr(i32 %25, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %28, i8* %30, i8* %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %26, i32 0)
%34 = load i32, i32* @IP_MULTICAST_IF
%35 = load i32, i32* %6
%36 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %7, i32 0, i32 0
%37 = load i8*, i8** %36
%38 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %8, i32 0, i32 0
%39 = load i8*, i8** %38
%40 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %9, i32 0, i32 0
%41 = load i8*, i8** %40
%42 = call i32 @test_in_addr(i32 %34, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %37, i8* %39, i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %35, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"0.0.0.0\00"
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [16 x i8] c"255.255.255.255\00"
@IP_MULTICAST_IF = global i32 0
@.str.3 = [16 x i8] c"IP_MULTICAST_IF\00"
@.str.4 = [9 x i8] c"raw_sock\00"
@.str.5 = [9 x i8] c"tcp_sock\00"
@.str.6 = [9 x i8] c"udp_sock\00"
define void @test_if(i32 %0, i32 %1, i32 %2) {
%4 = tail call i8* @inet_addr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = tail call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i8* @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* @IP_MULTICAST_IF
%8 = tail call i32 @test_in_addr(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %4, i8* %5, i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %0, i32 0)
%9 = load i32, i32* @IP_MULTICAST_IF
%10 = tail call i32 @test_in_addr(i32 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %4, i8* %5, i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %1, i32 0)
%11 = load i32, i32* @IP_MULTICAST_IF
%12 = tail call i32 @test_in_addr(i32 %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %4, i8* %5, i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %2, i32 0)
ret void
}