#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 pollfd {
  int events;
  int revents;
  int /*<<< orphan*/ fd;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ LOG_CRIT;
int /*<<< orphan*/ LOG_NOTICE;
int POLLIN;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ log__(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ parse_args(int, char **);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ process_packet(int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ setup_bcast_listener(char *);
int /*<<< orphan*/ setup_mcast_listener(char *);
int setup_sender(char *);
int main(int argc, char *argv[]) {
  struct pollfd pfds[2];
  int sender, ret;
  argv += parse_args(argc, argv);
  pfds[0].fd = setup_bcast_listener(argv[1]);
  pfds[0].events = POLLIN;
  pfds[1].fd = setup_mcast_listener(argv[1]);
  pfds[1].events = POLLIN;
  sender = setup_sender(argv[2]);
  log__(LOG_NOTICE,
        "NOTICE: "
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/ipilcher/squoxy/refs/heads/master/squoxy.c"
        ":"
        "678"
        ": "
        "Forwarding from %s to %s\n",
        argv[1], argv[2]);
  while (1) {
    pfds[0].revents = 0;
    pfds[1].revents = 0;
    ret = poll(pfds, 2, -1);
    if (ret < 0)
      do {
        log__(LOG_CRIT, "FATAL: "
                        "/scratch/repos/new/home/jordi_armengol_estape/"
                        "c-scraper/outputs/2022-01-22/02-19-57/repos/ipilcher/"
                        "squoxy/refs/heads/master/squoxy.c"
                        ":"
                        "687"
                        ": "
                        "poll: %m\n");
        exit(EXIT_FAILURE);
      } while (0);
    if (ret == 0)
      continue;
    if (pfds[0].revents & POLLIN)
      process_packet(pfds[0].fd, sender, "broadcast");
    if (pfds[1].revents & POLLIN)
      process_packet(pfds[1].fd, sender, "multicast");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <parse_args@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <setup_bcast_listener@plt>
mov    %eax,-0x28(%rbp)
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <setup_mcast_listener@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2df7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <setup_sender@plt>
mov    %eax,-0x34(%rbp)
mov    0x2dc3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
lea    0xde2(%rip),%rsi
mov    $0x0,%al
call   1070 <log__@plt>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x2,%esi
mov    $0xffffffff,%edx
call   1080 <poll@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    127d <main+0xfd>
jmp    1258 <main+0xd8>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1070 <log__@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cmpl   $0x0,-0x38(%rbp)
jne    128c <main+0x10c>
jmp    1225 <main+0xa5>
mov    -0x2c(%rbp),%eax
mov    0x2d4a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12b3 <main+0x133>
mov    -0x28(%rbp),%edi
mov    -0x34(%rbp),%esi
lea    0xe99(%rip),%rdx
call   1030 <process_packet@plt>
mov    -0x20(%rbp),%eax
mov    0x2d23(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12da <main+0x15a>
mov    -0x1c(%rbp),%edi
mov    -0x34(%rbp),%esi
lea    0xe7c(%rip),%rdx
call   1030 <process_packet@plt>
jmp    1225 <main+0xa5>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
call   1050 <parse_args@plt>
movslq %eax,%r15
mov    0x8(%r14,%r15,8),%rdi
call   1040 <setup_bcast_listener@plt>
mov    %eax,0x8(%rsp)
mov    0x2e33(%rip),%r13
mov    0x0(%r13),%eax
mov    %eax,(%rsp)
mov    0x8(%r14,%r15,8),%rdi
call   10a0 <setup_mcast_listener@plt>
mov    %eax,0x14(%rsp)
mov    0x0(%r13),%eax
mov    %eax,0xc(%rsp)
mov    0x10(%r14,%r15,8),%rdi
call   1060 <setup_sender@plt>
mov    %eax,%ebx
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14,%r15,8),%rdx
mov    0x10(%r14,%r15,8),%rcx
lea    0xe10(%rip),%rsi
xor    %eax,%eax
call   1070 <log__@plt>
movl   $0x0,0x4(%rsp)
movl   $0x0,0x10(%rsp)
mov    %rsp,%rdi
mov    $0x2,%esi
mov    $0xffffffff,%edx
call   1080 <poll@plt>
test   %eax,%eax
jns    1242 <main+0xc2>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
xor    %eax,%eax
call   1070 <log__@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %rsp,%r14
lea    0xf05(%rip),%r15
lea    0xef4(%rip),%r12
jmp    1286 <main+0x106>
cs nopw 0x0(%rax,%rax,1)
nop
movl   $0x0,0x4(%rsp)
movl   $0x0,0x10(%rsp)
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0xffffffff,%edx
call   1080 <poll@plt>
test   %eax,%eax
js     121d <main+0x9d>
test   %eax,%eax
je     1260 <main+0xe0>
mov    0x0(%r13),%eax
test   %eax,0x4(%rsp)
je     12a6 <main+0x126>
mov    0x8(%rsp),%edi
mov    %ebx,%esi
mov    %r12,%rdx
call   1030 <process_packet@plt>
mov    0x0(%r13),%eax
test   %eax,0x10(%rsp)
je     1260 <main+0xe0>
mov    0x14(%rsp),%edi
mov    %ebx,%esi
mov    %r15,%rdx
call   1030 <process_packet@plt>
jmp    1260 <main+0xe0>

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
@POLLIN = global i32 0
@LOG_NOTICE = global i32 0
@.str = [172 x i8] c"NOTICE: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ipilcher/squoxy/refs/heads/master/squoxy.c:678: Forwarding from %s to %s\0A\00"
@LOG_CRIT = global i32 0
@.str.1 = [155 x i8] c"FATAL: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ipilcher/squoxy/refs/heads/master/squoxy.c:687: poll: %m\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"broadcast\00"
@.str.3 = [10 x i8] c"multicast\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x %struct.pollfd]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @parse_args(i32 %9, i8** %10)
%12 = load i8**, i8*** %5
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds i8*, i8** %12, i64 %13
store i8** %14, i8*** %5
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @setup_bcast_listener(i8* %17)
%19 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 0
%20 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %19, i32 0, i32 2
store i32 %18, i32* %20
%21 = load i32, i32* @POLLIN
%22 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 0
%23 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %22, i32 0, i32 0
store i32 %21, i32* %23
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @setup_mcast_listener(i8* %26)
%28 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 1
%29 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %28, i32 0, i32 2
store i32 %27, i32* %29
%30 = load i32, i32* @POLLIN
%31 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 1
%32 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %31, i32 0, i32 0
store i32 %30, i32* %32
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @setup_sender(i8* %35)
store i32 %36, i32* %7
%37 = load i32, i32* @LOG_NOTICE
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 (i32, i8*, ...) @log__(i32 %37, i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i8* %40, i8* %43)
br label %45
45: ; preds = %2, %64, %91
%46 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 0
%47 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %46, i32 0, i32 1
store i32 0, i32* %47
%48 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 1
%49 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %48, i32 0, i32 1
store i32 0, i32* %49
%50 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 0
%51 = call i32 @poll(%struct.pollfd* %50, i32 2, i32 -1)
store i32 %51, i32* %8
%52 = load i32, i32* %8
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %45
br label %55
55: ; preds = %54
%56 = load i32, i32* @LOG_CRIT
%57 = call i32 (i32, i8*, ...) @log__(i32 %56, i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0))
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; No predecessors!
br label %61
61: ; preds = %60, %45
%62 = load i32, i32* %8
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %61
br label %45
65: ; preds = %61
%66 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 0
%67 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %66, i32 0, i32 1
%68 = load i32, i32* %67
%69 = load i32, i32* @POLLIN
%70 = and i32 %68, %69
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %78
72: ; preds = %65
%73 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 0
%74 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %73, i32 0, i32 2
%75 = load i32, i32* %74
%76 = load i32, i32* %7
%77 = call i32 @process_packet(i32 %75, i32 %76, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %78
78: ; preds = %72, %65
%79 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 1
%80 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %79, i32 0, i32 1
%81 = load i32, i32* %80
%82 = load i32, i32* @POLLIN
%83 = and i32 %81, %82
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %91
85: ; preds = %78
%86 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %6, i64 0, i64 1
%87 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %86, i32 0, i32 2
%88 = load i32, i32* %87
%89 = load i32, i32* %7
%90 = call i32 @process_packet(i32 %88, i32 %89, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %91
91: ; preds = %85, %78
br label %45
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
@POLLIN = global i32 0
@LOG_NOTICE = global i32 0
@.str = [172 x i8] c"NOTICE: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ipilcher/squoxy/refs/heads/master/squoxy.c:678: Forwarding from %s to %s\0A\00"
@LOG_CRIT = global i32 0
@.str.1 = [155 x i8] c"FATAL: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ipilcher/squoxy/refs/heads/master/squoxy.c:687: poll: %m\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"broadcast\00"
@.str.3 = [10 x i8] c"multicast\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x %struct.pollfd]
%4 = bitcast [2 x %struct.pollfd]* %3 to i8*
%5 = tail call i32 @parse_args(i32 %0, i8** %1)
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8*, i8** %1, i64 %6
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @setup_bcast_listener(i8* %9)
%11 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %3, i64 0, i64 0
%12 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %3, i64 0, i64 0, i32 2
store i32 %10, i32* %12
%13 = load i32, i32* @POLLIN
%14 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %3, i64 0, i64 0, i32 0
store i32 %13, i32* %14
%15 = load i8*, i8** %8
%16 = tail call i32 @setup_mcast_listener(i8* %15)
%17 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %3, i64 0, i64 1, i32 2
store i32 %16, i32* %17
%18 = load i32, i32* @POLLIN
%19 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %3, i64 0, i64 1, i32 0
store i32 %18, i32* %19
%20 = getelementptr inbounds i8*, i8** %7, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @setup_sender(i8* %21)
%23 = load i32, i32* @LOG_NOTICE
%24 = load i8*, i8** %8
%25 = load i8*, i8** %20
%26 = tail call i32 (i32, i8*, ...) @log__(i32 %23, i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %25)
%27 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %3, i64 0, i64 0, i32 1
%28 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %3, i64 0, i64 1, i32 1
store i32 0, i32* %27
store i32 0, i32* %28
%29 = call i32 @poll(%struct.pollfd* %11, i32 2, i32 -1)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %56, %2
%32 = load i32, i32* @LOG_CRIT
%33 = call i32 (i32, i8*, ...) @log__(i32 %32, i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %2, %56
%37 = phi i32 [ %57, %56 ], [ %29, %2 ]
%38 = icmp eq i32 %37, 0
br i1 %38, label %56, label %39
39: ; preds = %36
%40 = load i32, i32* %27
%41 = load i32, i32* @POLLIN
%42 = and i32 %41, %40
%43 = icmp eq i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %39
%45 = load i32, i32* %12
%46 = call i32 @process_packet(i32 %45, i32 %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* @POLLIN
br label %48
48: ; preds = %44, %39
%49 = phi i32 [ %47, %44 ], [ %41, %39 ]
%50 = load i32, i32* %28
%51 = and i32 %49, %50
%52 = icmp eq i32 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %48
%54 = load i32, i32* %17
%55 = call i32 @process_packet(i32 %54, i32 %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %56
56: ; preds = %48, %53, %36
store i32 0, i32* %27
store i32 0, i32* %28
%57 = call i32 @poll(%struct.pollfd* %11, i32 2, i32 -1)
%58 = icmp slt i32 %57, 0
br i1 %58, label %31, label %36
}