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

/* Variables and functions */
int IPPROTO_UDP;
int /*<<< orphan*/ iptables_fw_destroy_mention(char *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, unsigned short);
int _fw_delete_redir(unsigned short eport, int proto) {
  char tmpbuf[128];
  char *netproto = (proto == IPPROTO_UDP ? "udp" : "tcp");
  snprintf(tmpbuf, sizeof(tmpbuf), "%s dpt:%d", netproto, eport);
  iptables_fw_destroy_mention("nat", "PREROUTING", tmpbuf);
  printf("redirect remove eport %d\n", eport);
  printf("redirect remove proto %s\n", proto == IPPROTO_UDP ? "UDP" : "TCP");
  return 0;
}


x86 assembly (clang, -O0):
<_fw_delete_redir>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
lea    0xeac(%rip),%rax
lea    0xea1(%rip),%rcx
cmp    %esi,%edx
cmove  %rcx,%rax
mov    %rax,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rcx
mov    $0x80,%esi
lea    0xe82(%rip),%rdx
movzwl -0x2(%rbp),%r8d
call   1050 <snprintf@plt>
lea    -0x90(%rbp),%rdx
lea    0xe74(%rip),%rdi
lea    0xe71(%rip),%rsi
call   1030 <iptables_fw_destroy_mention@plt>
movzwl -0x2(%rbp),%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%ecx
mov    0x2e12(%rip),%rax
mov    (%rax),%edx
lea    0xe8a(%rip),%rsi
lea    0xe7f(%rip),%rax
cmp    %edx,%ecx
cmove  %rax,%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_fw_delete_redir>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2e90(%rip),%r15
cmp    %esi,(%r15)
lea    0xeae(%rip),%rax
lea    0xeab(%rip),%rcx
cmove  %rax,%rcx
lea    0xea4(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x80,%esi
mov    %ebp,%r8d
call   1050 <snprintf@plt>
lea    0xe94(%rip),%rdi
lea    0xe91(%rip),%rsi
mov    %r14,%rdx
call   1030 <iptables_fw_destroy_mention@plt>
lea    0xe8d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %ebx,(%r15)
lea    0xeae(%rip),%rax
lea    0xeab(%rip),%rsi
cmove  %rax,%rsi
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@IPPROTO_UDP = global i32 0
@.str = [4 x i8] c"udp\00"
@.str.1 = [4 x i8] c"tcp\00"
@.str.2 = [10 x i8] c"%s dpt:%d\00"
@.str.3 = [4 x i8] c"nat\00"
@.str.4 = [11 x i8] c"PREROUTING\00"
@.str.5 = [26 x i8] c"redirect remove eport %d\0A\00"
@.str.6 = [26 x i8] c"redirect remove proto %s\0A\00"
@.str.7 = [4 x i8] c"UDP\00"
@.str.8 = [4 x i8] c"TCP\00"
define i32 @_fw_delete_redir(i16 zeroext %0, i32 %1) {
%3 = alloca i16
%4 = alloca i32
%5 = alloca [128 x i8]
%6 = alloca i8*
store i16 %0, i16* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = load i32, i32* @IPPROTO_UDP
%9 = icmp eq i32 %7, %8
%10 = zext i1 %9 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
store i8* %11, i8** %6
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%13 = load i8*, i8** %6
%14 = load i16, i16* %3
%15 = call i32 @snprintf(i8* %12, i32 128, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %13, i16 zeroext %14)
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%17 = call i32 @iptables_fw_destroy_mention(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %16)
%18 = load i16, i16* %3
%19 = zext i16 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %4
%22 = load i32, i32* @IPPROTO_UDP
%23 = icmp eq i32 %21, %22
%24 = zext i1 %23 to i64
%25 = select i1 %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %25)
ret i32 0
}

LLVM IR (-O2):
@IPPROTO_UDP = global i32 0
@.str = [4 x i8] c"udp\00"
@.str.1 = [4 x i8] c"tcp\00"
@.str.2 = [10 x i8] c"%s dpt:%d\00"
@.str.3 = [4 x i8] c"nat\00"
@.str.4 = [11 x i8] c"PREROUTING\00"
@.str.5 = [26 x i8] c"redirect remove eport %d\0A\00"
@.str.6 = [26 x i8] c"redirect remove proto %s\0A\00"
@.str.7 = [4 x i8] c"UDP\00"
@.str.8 = [4 x i8] c"TCP\00"
define i32 @_fw_delete_redir(i16 zeroext %0, i32 %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @IPPROTO_UDP
%6 = icmp eq i32 %5, %1
%7 = select i1 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0)
%8 = call i32 @snprintf(i8* %4, i32 128, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %7, i16 zeroext %0)
%9 = call i32 @iptables_fw_destroy_mention(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%10 = zext i16 %0 to i32
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @IPPROTO_UDP
%13 = icmp eq i32 %12, %1
%14 = select i1 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %14)
ret i32 0
}