#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);
  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)
cmpl   $0x0,-0x8(%rbp)
je     11dd <main+0xbd>
movl   $0x1,-0x4(%rbp)
jmp    11f0 <main+0xd0>
lea    0xe1c(%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),%r15
mov    (%r15),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%ebx
mov    0x0(%rbp),%edi
mov    0x2e7b(%rip),%r12
mov    (%r12),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%ebp
or     %ebx,%ebp
mov    0x2e5f(%rip),%rbx
mov    (%rbx),%edi
mov    (%r15),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%r14d
mov    (%rbx),%edi
mov    (%r12),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%ebx
or     %r14d,%ebx
or     %ebp,%ebx
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%esi
call   1040 <test_tpacket@plt>
mov    %eax,%ecx
mov    $0x1,%eax
or     %ebx,%ecx
jne    11aa <main+0x8a>
lea    0xe5d(%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* %2
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %0
store i32 1, i32* %1
br label %33
31: ; preds = %0
%32 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %33
33: ; preds = %31, %30
%34 = load i32, i32* %1
ret i32 %34
}

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 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %23
23: ; preds = %0, %21
%24 = phi i32 [ 0, %21 ], [ 1, %0 ]
ret i32 %24
}