#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 int /*<<< orphan*/ u_int64_t;
typedef int /*<<< orphan*/ desc;

/* Variables and functions */
int /*<<< orphan*/ IPPROTO_TCP;
scalar_t__ get_redirect_rule(char *, int, int /*<<< orphan*/, char *, int,
                             unsigned short *, char *, int,
                             int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ list_rules();
int /*<<< orphan*/ printf(char *, ...);
int main(int arc, char **argv) {
  char buf[32];
  char desc[64];
  unsigned short iport;
  u_int64_t packets = 0;
  u_int64_t bytes = 0;
  list_rules();
  if (get_redirect_rule("xl1", 4662, IPPROTO_TCP, buf, 32, &iport, desc,
                        sizeof(desc), &packets, &bytes) < 0)
    printf("get_redirect_rule() failed\n");
  else {
    printf("\n%s:%d '%s' packets=%llu bytes=%llu\n", buf, (int)iport, desc,
           packets, bytes);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    $0x0,%al
call   1050 <list_rules@plt>
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
lea    -0x30(%rbp),%rcx
lea    -0x70(%rbp),%r11
lea    0xe8a(%rip),%rdi
mov    $0x1236,%esi
mov    $0x20,%r8d
lea    -0x72(%rbp),%r9
lea    -0x78(%rbp),%r10
lea    -0x7c(%rbp),%rax
mov    %r11,(%rsp)
movl   $0x40,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1040 <get_redirect_rule@plt>
cmp    $0x0,%rax
jge    11c5 <main+0x95>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e7 <main+0xb7>
lea    -0x30(%rbp),%rsi
movzwl -0x72(%rbp),%edx
lea    -0x70(%rbp),%rcx
mov    -0x78(%rbp),%r8d
mov    -0x7c(%rbp),%r9d
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x78,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
xor    %eax,%eax
call   1060 <list_rules@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rax
lea    0xc(%rsp),%r10
lea    0x30(%rsp),%r11
lea    0xe86(%rip),%rdi
lea    0x10(%rsp),%rcx
lea    0x6(%rsp),%r9
mov    $0x1236,%esi
mov    $0x20,%r8d
push   %rax
push   %r10
push   $0x40
push   %r11
call   1050 <get_redirect_rule@plt>
add    $0x20,%rsp
test   %rax,%rax
js     11cd <main+0x8d>
movzwl 0x6(%rsp),%edx
mov    0xc(%rsp),%r8d
mov    0x8(%rsp),%r9d
lea    0xe4a(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x30(%rsp),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d9 <main+0x99>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x78,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"xl1\00"
@IPPROTO_TCP = global i32 0
@.str.1 = [28 x i8] c"get_redirect_rule() failed\0A\00"
@.str.2 = [37 x i8] c"\0A%s:%d '%s' packets=%llu bytes=%llu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32 x i8]
%7 = alloca [64 x i8]
%8 = alloca i16
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
store i32 0, i32* %10
%11 = call i32 (...) @list_rules()
%12 = load i32, i32* @IPPROTO_TCP
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%15 = call i64 @get_redirect_rule(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4662, i32 %12, i8* %13, i32 32, i16* %8, i8* %14, i32 64, i32* %9, i32* %10)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %27
19: ; preds = %2
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%21 = load i16, i16* %8
%22 = zext i16 %21 to i32
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%24 = load i32, i32* %9
%25 = load i32, i32* %10
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %20, i32 %22, i8* %23, i32 %24, i32 %25)
br label %27
27: ; preds = %19, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"xl1\00"
@IPPROTO_TCP = global i32 0
@.str.2 = [37 x i8] c"\0A%s:%d '%s' packets=%llu bytes=%llu\0A\00"
@str = [27 x i8] c"get_redirect_rule() failed\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32 x i8]
%4 = alloca [64 x i8]
%5 = alloca i16
%6 = alloca i32
%7 = alloca i32
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%10 = bitcast i16* %5 to i8*
%11 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%12 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%13 = tail call i32 (...) @list_rules()
%14 = load i32, i32* @IPPROTO_TCP
%15 = call i64 @get_redirect_rule(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4662, i32 %14, i8* %8, i32 32, i16* %5, i8* %9, i32 64, i32* %6, i32* %7)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %25
19: ; preds = %2
%20 = load i16, i16* %5
%21 = zext i16 %20 to i32
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %8, i32 %21, i8* %9, i32 %22, i32 %23)
br label %25
25: ; preds = %19, %17
ret i32 0
}