#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  void *s_addr;
};
struct TYPE_3__ {
  void *s_addr;
};
struct ip_mreq {
  TYPE_2__ imr_interface;
  TYPE_1__ imr_multiaddr;
};

/* Variables and functions */
void *inet_addr(char *);
int /*<<< orphan*/ test_add_multi(int, char *, struct ip_mreq, int);
int /*<<< orphan*/ test_drop_multi(int, char *, struct ip_mreq, int);
void test_addr(int raw_sock, int tcp_sock, int udp_sock) {
  struct ip_mreq imr;
  imr.imr_multiaddr.s_addr = inet_addr("224.100.100.100");
  imr.imr_interface.s_addr = inet_addr("127.0.0.1");
  test_add_multi(raw_sock, "raw_sock", imr, 0);
  test_drop_multi(raw_sock, "raw_sock", imr, 0);
  test_add_multi(tcp_sock, "raw_sock", imr, 0x00000000);
  test_drop_multi(tcp_sock, "raw_sock", imr, 0x00000000);
  test_add_multi(udp_sock, "raw_sock", imr, 0);
  test_drop_multi(udp_sock, "raw_sock", imr, 0);
}


x86 assembly (clang, -O0):
<test_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    0xeb8(%rip),%rdi
call   1050 <inet_addr@plt>
mov    %rax,-0x18(%rbp)
lea    0xeb8(%rip),%rdi
call   1050 <inet_addr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xea7(%rip),%rsi
xor    %r8d,%r8d
call   1030 <test_add_multi@plt>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe8d(%rip),%rsi
xor    %r8d,%r8d
call   1040 <test_drop_multi@plt>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe73(%rip),%rsi
xor    %r8d,%r8d
call   1030 <test_add_multi@plt>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe59(%rip),%rsi
xor    %r8d,%r8d
call   1040 <test_drop_multi@plt>
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe3f(%rip),%rsi
xor    %r8d,%r8d
call   1030 <test_add_multi@plt>
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xe25(%rip),%rsi
xor    %r8d,%r8d
call   1040 <test_drop_multi@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_addr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r12d
mov    %edi,%r13d
lea    0xeb5(%rip),%rdi
call   1050 <inet_addr@plt>
mov    %rax,%rbx
lea    0xeb6(%rip),%rdi
call   1050 <inet_addr@plt>
mov    %rax,%rbp
lea    0xeb1(%rip),%r15
mov    %r13d,%edi
mov    %r15,%rsi
mov    %rax,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1030 <test_add_multi@plt>
mov    %r13d,%edi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1040 <test_drop_multi@plt>
mov    %r12d,%edi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1030 <test_add_multi@plt>
mov    %r12d,%edi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1040 <test_drop_multi@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1030 <test_add_multi@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <test_drop_multi@plt>

LLVM IR (-O0):
%struct.ip_mreq = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i8* }
%struct.TYPE_3__ = type { i8* }
@.str = [16 x i8] c"224.100.100.100\00"
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [9 x i8] c"raw_sock\00"
define void @test_addr(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.ip_mreq
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = call i8* @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %7, i32 0, i32 1
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 0
store i8* %8, i8** %10
%11 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %7, i32 0, i32 0
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 0
store i8* %11, i8** %13
%14 = load i32, i32* %4
%15 = bitcast %struct.ip_mreq* %7 to { i8*, i8* }*
%16 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %15, i32 0, i32 0
%17 = load i8*, i8** %16
%18 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %15, i32 0, i32 1
%19 = load i8*, i8** %18
%20 = call i32 @test_add_multi(i32 %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %17, i8* %19, i32 0)
%21 = load i32, i32* %4
%22 = bitcast %struct.ip_mreq* %7 to { i8*, i8* }*
%23 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %22, i32 0, i32 0
%24 = load i8*, i8** %23
%25 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %22, i32 0, i32 1
%26 = load i8*, i8** %25
%27 = call i32 @test_drop_multi(i32 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %24, i8* %26, i32 0)
%28 = load i32, i32* %5
%29 = bitcast %struct.ip_mreq* %7 to { i8*, i8* }*
%30 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %29, i32 0, i32 0
%31 = load i8*, i8** %30
%32 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %29, i32 0, i32 1
%33 = load i8*, i8** %32
%34 = call i32 @test_add_multi(i32 %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %33, i32 0)
%35 = load i32, i32* %5
%36 = bitcast %struct.ip_mreq* %7 to { i8*, i8* }*
%37 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %36, i32 0, i32 0
%38 = load i8*, i8** %37
%39 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %36, i32 0, i32 1
%40 = load i8*, i8** %39
%41 = call i32 @test_drop_multi(i32 %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %38, i8* %40, i32 0)
%42 = load i32, i32* %6
%43 = bitcast %struct.ip_mreq* %7 to { i8*, i8* }*
%44 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %43, i32 0, i32 0
%45 = load i8*, i8** %44
%46 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %43, i32 0, i32 1
%47 = load i8*, i8** %46
%48 = call i32 @test_add_multi(i32 %42, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %45, i8* %47, i32 0)
%49 = load i32, i32* %6
%50 = bitcast %struct.ip_mreq* %7 to { i8*, i8* }*
%51 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %50, i32 0, i32 0
%52 = load i8*, i8** %51
%53 = getelementptr inbounds { i8*, i8* }, { i8*, i8* }* %50, i32 0, i32 1
%54 = load i8*, i8** %53
%55 = call i32 @test_drop_multi(i32 %49, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %52, i8* %54, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"224.100.100.100\00"
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [9 x i8] c"raw_sock\00"
define void @test_addr(i32 %0, i32 %1, i32 %2) {
%4 = tail call i8* @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 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 i32 @test_add_multi(i32 %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %4, i32 0)
%7 = tail call i32 @test_drop_multi(i32 %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %4, i32 0)
%8 = tail call i32 @test_add_multi(i32 %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %4, i32 0)
%9 = tail call i32 @test_drop_multi(i32 %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %4, i32 0)
%10 = tail call i32 @test_add_multi(i32 %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %4, i32 0)
%11 = tail call i32 @test_drop_multi(i32 %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %4, i32 0)
ret void
}