#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 */

/* Variables and functions */
int /*<<< orphan*/ PACKET_RX_RING;
int /*<<< orphan*/ PACKET_TX_RING;
int /*<<< orphan*/ TPACKET_V1;
int /*<<< orphan*/ TPACKET_V2;
int /*<<< orphan*/ TPACKET_V3;
int /*<<< orphan*/ printf(char *);
int test_tpacket(int /*<<< orphan*/, int /*<<< orphan*/);
int main(void) {
  int ret = 0;
  ret |= test_tpacket(TPACKET_V1, PACKET_RX_RING);
  ret |= test_tpacket(TPACKET_V1, PACKET_TX_RING);
  ret |= test_tpacket(TPACKET_V2, PACKET_RX_RING);
  ret |= test_tpacket(TPACKET_V2, PACKET_TX_RING);
  ret |= test_tpacket(TPACKET_V3, PACKET_RX_RING);
  ret |= test_tpacket(TPACKET_V3, PACKET_TX_RING);
  if (ret)
    return 1;
  printf("OK. All tests passed\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
call   1040 <test_tpacket@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
call   1040 <test_tpacket@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    0x2e58(%rip),%rax
mov    (%rax),%esi
call   1040 <test_tpacket@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
call   1040 <test_tpacket@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    0x2e1e(%rip),%rax
mov    (%rax),%esi
call   1040 <test_tpacket@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
call   1040 <test_tpacket@plt>
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11fa <main+0xda>
movl   $0x1,-0x4(%rbp)
jmp    120d <main+0xed>
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2eb1(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2e9f(%rip),%r12
mov    (%r12),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%ebx
mov    0x0(%rbp),%edi
mov    0x2e7a(%rip),%r15
mov    (%r15),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%ebp
or     %ebx,%ebp
mov    0x2e5f(%rip),%rbx
mov    (%rbx),%edi
mov    (%r12),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%r14d
mov    (%rbx),%edi
mov    (%r15),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%ebx
or     %r14d,%ebx
or     %ebp,%ebx
mov    0x2e61(%rip),%r14
mov    (%r14),%edi
mov    (%r12),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%ebp
or     %ebx,%ebp
mov    (%r14),%edi
mov    (%r15),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%ecx
mov    $0x1,%eax
or     %ebp,%ecx
jne    11bb <main+0x9b>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@TPACKET_V1 = global i32 0
@PACKET_RX_RING = global i32 0
@PACKET_TX_RING = global i32 0
@TPACKET_V2 = global i32 0
@TPACKET_V3 = global i32 0
@.str = [22 x i8] c"OK. All tests passed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = load i32, i32* @TPACKET_V1
%4 = load i32, i32* @PACKET_RX_RING
%5 = call i32 @test_tpacket(i32 %3, i32 %4)
%6 = load i32, i32* %2
%7 = or i32 %6, %5
store i32 %7, i32* %2
%8 = load i32, i32* @TPACKET_V1
%9 = load i32, i32* @PACKET_TX_RING
%10 = call i32 @test_tpacket(i32 %8, i32 %9)
%11 = load i32, i32* %2
%12 = or i32 %11, %10
store i32 %12, i32* %2
%13 = load i32, i32* @TPACKET_V2
%14 = load i32, i32* @PACKET_RX_RING
%15 = call i32 @test_tpacket(i32 %13, i32 %14)
%16 = load i32, i32* %2
%17 = or i32 %16, %15
store i32 %17, i32* %2
%18 = load i32, i32* @TPACKET_V2
%19 = load i32, i32* @PACKET_TX_RING
%20 = call i32 @test_tpacket(i32 %18, i32 %19)
%21 = load i32, i32* %2
%22 = or i32 %21, %20
store i32 %22, i32* %2
%23 = load i32, i32* @TPACKET_V3
%24 = load i32, i32* @PACKET_RX_RING
%25 = call i32 @test_tpacket(i32 %23, i32 %24)
%26 = load i32, i32* %2
%27 = or i32 %26, %25
store i32 %27, i32* %2
%28 = load i32, i32* @TPACKET_V3
%29 = load i32, i32* @PACKET_TX_RING
%30 = call i32 @test_tpacket(i32 %28, i32 %29)
%31 = load i32, i32* %2
%32 = or i32 %31, %30
store i32 %32, i32* %2
%33 = load i32, i32* %2
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %0
store i32 1, i32* %1
br label %38
36: ; preds = %0
%37 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %38
38: ; preds = %36, %35
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@TPACKET_V1 = global i32 0
@PACKET_RX_RING = global i32 0
@PACKET_TX_RING = global i32 0
@TPACKET_V2 = global i32 0
@TPACKET_V3 = global i32 0
@str = [21 x i8] c"OK. All tests passed\00"
define i32 @main() {
%1 = load i32, i32* @TPACKET_V1
%2 = load i32, i32* @PACKET_RX_RING
%3 = tail call i32 @test_tpacket(i32 %1, i32 %2)
%4 = load i32, i32* @TPACKET_V1
%5 = load i32, i32* @PACKET_TX_RING
%6 = tail call i32 @test_tpacket(i32 %4, i32 %5)
%7 = or i32 %6, %3
%8 = load i32, i32* @TPACKET_V2
%9 = load i32, i32* @PACKET_RX_RING
%10 = tail call i32 @test_tpacket(i32 %8, i32 %9)
%11 = or i32 %7, %10
%12 = load i32, i32* @TPACKET_V2
%13 = load i32, i32* @PACKET_TX_RING
%14 = tail call i32 @test_tpacket(i32 %12, i32 %13)
%15 = or i32 %11, %14
%16 = load i32, i32* @TPACKET_V3
%17 = load i32, i32* @PACKET_RX_RING
%18 = tail call i32 @test_tpacket(i32 %16, i32 %17)
%19 = or i32 %15, %18
%20 = load i32, i32* @TPACKET_V3
%21 = load i32, i32* @PACKET_TX_RING
%22 = tail call i32 @test_tpacket(i32 %20, i32 %21)
%23 = or i32 %19, %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %0
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %0, %25
%28 = phi i32 [ 0, %25 ], [ 1, %0 ]
ret i32 %28
}