#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 */
typedef size_t ssize_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sock_add_multicast_membership(int, char *);
int /*<<< orphan*/ sock_bind(int, int);
size_t sock_recvfrom(int, char *, int);
int udpsock_create();
int main(int argc, char *argv[]) {
  int cfd;
  cfd = udpsock_create();
  sock_bind(cfd, 3333);
  sock_add_multicast_membership(cfd, "224.25.25.25");
  char buf[100];
  ssize_t rbytes;
  while (1) {
    rbytes = sock_recvfrom(cfd, buf, 100);
    buf[rbytes] = '\0';
    printf("%s\n", buf);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <udpsock_create@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0xd05,%esi
call   1030 <sock_bind@plt>
mov    -0x14(%rbp),%edi
lea    0xe76(%rip),%rsi
call   1070 <sock_add_multicast_membership@plt>
mov    -0x14(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x64,%edx
call   1040 <sock_recvfrom@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
jmp    118f <main+0x3f>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
xor    %eax,%eax
call   1060 <udpsock_create@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0xd05,%esi
call   1030 <sock_bind@plt>
lea    0xe8c(%rip),%rsi
mov    %ebp,%edi
call   1070 <sock_add_multicast_membership@plt>
mov    %rsp,%rbx
lea    0xe88(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1040 <sock_recvfrom@plt>
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
jmp    1190 <main+0x40>

LLVM IR (-O0):
@.str = [13 x i8] c"224.25.25.25\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @udpsock_create()
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = call i32 @sock_bind(i32 %10, i32 3333)
%12 = load i32, i32* %6
%13 = call i32 @sock_add_multicast_membership(i32 %12, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %2, %14
%15 = load i32, i32* %6
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%17 = call i64 @sock_recvfrom(i32 %15, i8* %16, i32 100)
store i64 %17, i64* %8
%18 = load i64, i64* %8
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 %18
store i8 0, i8* %19
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %14
}

LLVM IR (-O2):
@.str = [13 x i8] c"224.25.25.25\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = tail call i32 (...) @udpsock_create()
%5 = tail call i32 @sock_bind(i32 %4, i32 3333)
%6 = tail call i32 @sock_add_multicast_membership(i32 %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
br label %8
8: ; preds = %8, %2
%9 = call i64 @sock_recvfrom(i32 %4, i8* %7, i32 100)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
br label %8
}