#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*/ IPPROTO_TCP;
int LOG_CONS;
int LOG_PERROR;
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ add_redirect_rule2(char *, int, char *, int,
                                      int /*<<< orphan*/, char *);
int /*<<< orphan*/ delete_redirect_rule(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ get_redirect_rule(char *, int, int /*<<< orphan*/,
                                     int /*<<< orphan*/ *, int /*<<< orphan*/,
                                     int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                     int /*<<< orphan*/, int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ init_redirect();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ shutdown_redirect();
int main(int argc, char **argv) {
  openlog("testipfwrdrd", LOG_CONS | LOG_PERROR, LOG_USER);
  init_redirect();
  delete_redirect_rule("lo", 2222, IPPROTO_TCP);
  add_redirect_rule2("lo", 2222, "10.1.1.16", 4444, IPPROTO_TCP, "miniupnpd");
  get_redirect_rule("lo", 2222, IPPROTO_TCP, NULL, 0, NULL, NULL, 0, NULL,
                    NULL);
  shutdown_redirect();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
mov    0x2e52(%rip),%rax
or     (%rax),%esi
mov    0x2e59(%rip),%rax
mov    (%rax),%edx
lea    0xe68(%rip),%rdi
call   1080 <openlog@plt>
mov    $0x0,%al
call   1030 <init_redirect@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
lea    0xe59(%rip),%rdi
mov    $0x8ae,%esi
call   1040 <delete_redirect_rule@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%r8d
lea    0xe3e(%rip),%rdi
mov    $0x8ae,%esi
lea    0xe35(%rip),%rdx
mov    $0x115c,%ecx
lea    0xe33(%rip),%r9
call   1050 <add_redirect_rule2@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edx
lea    0xe11(%rip),%rdi
mov    $0x8ae,%esi
xor    %eax,%eax
mov    %eax,%r9d
xor    %r8d,%r8d
mov    %r9,%rcx
movq   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x18(%rsp)
call   1060 <get_redirect_rule@plt>
mov    $0x0,%al
call   1070 <shutdown_redirect@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0x2e5a(%rip),%rax
mov    0x2e63(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e68(%rip),%rax
mov    (%rax),%edx
lea    0xe77(%rip),%rdi
call   1080 <openlog@plt>
xor    %eax,%eax
call   1030 <init_redirect@plt>
mov    0x2e44(%rip),%rbx
mov    (%rbx),%edx
lea    0xe68(%rip),%r14
mov    %r14,%rdi
mov    $0x8ae,%esi
call   1040 <delete_redirect_rule@plt>
mov    (%rbx),%r8d
lea    0xe54(%rip),%rdx
lea    0xe57(%rip),%r9
mov    %r14,%rdi
mov    $0x8ae,%esi
mov    $0x115c,%ecx
call   1050 <add_redirect_rule2@plt>
mov    (%rbx),%edx
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%rsp)
movl   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
mov    %r14,%rdi
mov    $0x8ae,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1060 <get_redirect_rule@plt>
xor    %eax,%eax
call   1070 <shutdown_redirect@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"testipfwrdrd\00"
@LOG_CONS = global i32 0
@LOG_PERROR = global i32 0
@LOG_USER = global i32 0
@.str.1 = [3 x i8] c"lo\00"
@IPPROTO_TCP = global i32 0
@.str.2 = [10 x i8] c"10.1.1.16\00"
@.str.3 = [10 x i8] c"miniupnpd\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @LOG_CONS
%7 = load i32, i32* @LOG_PERROR
%8 = or i32 %6, %7
%9 = load i32, i32* @LOG_USER
%10 = call i32 @openlog(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = call i32 (...) @init_redirect()
%12 = load i32, i32* @IPPROTO_TCP
%13 = call i32 @delete_redirect_rule(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2222, i32 %12)
%14 = load i32, i32* @IPPROTO_TCP
%15 = call i32 @add_redirect_rule2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2222, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 4444, i32 %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32, i32* @IPPROTO_TCP
%17 = call i32 @get_redirect_rule(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2222, i32 %16, i32* null, i32 0, i32* null, i32* null, i32 0, i32* null, i32* null)
%18 = call i32 (...) @shutdown_redirect()
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"testipfwrdrd\00"
@LOG_CONS = global i32 0
@LOG_PERROR = global i32 0
@LOG_USER = global i32 0
@.str.1 = [3 x i8] c"lo\00"
@IPPROTO_TCP = global i32 0
@.str.2 = [10 x i8] c"10.1.1.16\00"
@.str.3 = [10 x i8] c"miniupnpd\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @LOG_CONS
%4 = load i32, i32* @LOG_PERROR
%5 = or i32 %4, %3
%6 = load i32, i32* @LOG_USER
%7 = tail call i32 @openlog(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = tail call i32 (...) @init_redirect()
%9 = load i32, i32* @IPPROTO_TCP
%10 = tail call i32 @delete_redirect_rule(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2222, i32 %9)
%11 = load i32, i32* @IPPROTO_TCP
%12 = tail call i32 @add_redirect_rule2(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2222, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 4444, i32 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* @IPPROTO_TCP
%14 = tail call i32 @get_redirect_rule(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2222, i32 %13, i32* null, i32 0, i32* null, i32* null, i32 0, i32* null, i32* null)
%15 = tail call i32 (...) @shutdown_redirect()
ret i32 0
}