#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*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
int removeRules(char *address, char *source_addr, char *dest_addr) {
  char command[500];
  strcpy(command, "iptables -t nat -D PREROUTING -p tcp --dport 9898 -s ");
  strcat(command, source_addr);
  strcat(command, " -d ");
  strcat(command, address);
  strcat(command, " -j DNAT --to-destination ");
  strcat(command, dest_addr);
  printf("Command 1: %s\n", command);
  system(command);
  strcpy(command, "iptables -t nat -D POSTROUTING -p tcp -s ");
  strcat(command, source_addr);
  strcat(command, " -d ");
  strcat(command, dest_addr);
  strcat(command, " -j SNAT --to-source ");
  strcat(command, address);
  printf("Command 2: %s\n", command);
  system(command);
  strcpy(command, "iptables -t nat -D PREROUTING -p tcp --dport 9898 -s ");
  strcat(command, dest_addr);
  strcat(command, " -d ");
  strcat(command, address);
  strcat(command, " -j DNAT --to-destination ");
  strcat(command, source_addr);
  printf("Command 3: %s\n", command);
  system(command);
  strcpy(command, "iptables -t nat -D POSTROUTING -p tcp -s ");
  strcat(command, dest_addr);
  strcat(command, " -d ");
  strcat(command, source_addr);
  strcat(command, " -j SNAT --to-source ");
  strcat(command, address);
  printf("Command 4: %s\n", command);
  system(command);
  return 1;
}


x86 assembly (clang, -O0):
<removeRules>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x210(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1050 <printf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <system@plt>
lea    -0x210(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <system@plt>
lea    -0x210(%rbp),%rdi
lea    0xd8b(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x210(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xd9e(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xd80(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rsi
lea    0xdd6(%rip),%rdi
call   1050 <printf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <system@plt>
lea    -0x210(%rbp),%rdi
lea    0xd68(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x210(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xd16(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xd4c(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x210(%rbp),%rsi
lea    0xd5d(%rip),%rdi
call   1050 <printf@plt>
lea    -0x210(%rbp),%rdi
call   1040 <system@plt>
mov    $0x1,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeRules>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1f8,%rsp
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xe9f(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
lea    0xeb8(%rip),%r13
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
lea    0xe93(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
lea    0xe8c(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
lea    0xdcd(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
lea    0xdd8(%rip),%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
lea    0xe3a(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
lea    0xdd1(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
lea    0xdec(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    $0x1,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [54 x i8] c"iptables -t nat -D PREROUTING -p tcp --dport 9898 -s \00"
@.str.1 = [5 x i8] c" -d \00"
@.str.2 = [27 x i8] c" -j DNAT --to-destination \00"
@.str.3 = [15 x i8] c"Command 1: %s\0A\00"
@.str.4 = [42 x i8] c"iptables -t nat -D POSTROUTING -p tcp -s \00"
@.str.5 = [22 x i8] c" -j SNAT --to-source \00"
@.str.6 = [15 x i8] c"Command 2: %s\0A\00"
@.str.7 = [15 x i8] c"Command 3: %s\0A\00"
@.str.8 = [15 x i8] c"Command 4: %s\0A\00"
define i32 @removeRules(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [500 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%11 = load i8*, i8** %5
%12 = call i32 @strcat(i8* %10, i8* %11)
%13 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%14 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%16 = load i8*, i8** %4
%17 = call i32 @strcat(i8* %15, i8* %16)
%18 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%21 = load i8*, i8** %6
%22 = call i32 @strcat(i8* %20, i8* %21)
%23 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%26 = call i32 @system(i8* %25)
%27 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%28 = call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%29 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%30 = load i8*, i8** %5
%31 = call i32 @strcat(i8* %29, i8* %30)
%32 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%34 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%35 = load i8*, i8** %6
%36 = call i32 @strcat(i8* %34, i8* %35)
%37 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%38 = call i32 @strcat(i8* %37, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%39 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%40 = load i8*, i8** %4
%41 = call i32 @strcat(i8* %39, i8* %40)
%42 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%43 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%45 = call i32 @system(i8* %44)
%46 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%47 = call i32 @strcpy(i8* %46, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%48 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%49 = load i8*, i8** %6
%50 = call i32 @strcat(i8* %48, i8* %49)
%51 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%52 = call i32 @strcat(i8* %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%53 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%54 = load i8*, i8** %4
%55 = call i32 @strcat(i8* %53, i8* %54)
%56 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%57 = call i32 @strcat(i8* %56, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%58 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%59 = load i8*, i8** %5
%60 = call i32 @strcat(i8* %58, i8* %59)
%61 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%62 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %61)
%63 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%64 = call i32 @system(i8* %63)
%65 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%66 = call i32 @strcpy(i8* %65, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%67 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%68 = load i8*, i8** %6
%69 = call i32 @strcat(i8* %67, i8* %68)
%70 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%71 = call i32 @strcat(i8* %70, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%72 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%73 = load i8*, i8** %5
%74 = call i32 @strcat(i8* %72, i8* %73)
%75 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%76 = call i32 @strcat(i8* %75, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%77 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%78 = load i8*, i8** %4
%79 = call i32 @strcat(i8* %77, i8* %78)
%80 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%81 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %80)
%82 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%83 = call i32 @system(i8* %82)
ret i32 1
}

LLVM IR (-O2):
@.str = [54 x i8] c"iptables -t nat -D PREROUTING -p tcp --dport 9898 -s \00"
@.str.1 = [5 x i8] c" -d \00"
@.str.2 = [27 x i8] c" -j DNAT --to-destination \00"
@.str.3 = [15 x i8] c"Command 1: %s\0A\00"
@.str.4 = [42 x i8] c"iptables -t nat -D POSTROUTING -p tcp -s \00"
@.str.5 = [22 x i8] c" -j SNAT --to-source \00"
@.str.6 = [15 x i8] c"Command 2: %s\0A\00"
@.str.7 = [15 x i8] c"Command 3: %s\0A\00"
@.str.8 = [15 x i8] c"Command 4: %s\0A\00"
define i32 @removeRules(i8* %0, i8* %1, i8* %2) {
%4 = alloca [500 x i8]
%5 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @strcat(i8* %5, i8* %1)
%8 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @strcat(i8* %5, i8* %0)
%10 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @strcat(i8* %5, i8* %2)
%12 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%13 = call i32 @system(i8* %5)
%14 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @strcat(i8* %5, i8* %1)
%16 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @strcat(i8* %5, i8* %2)
%18 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @strcat(i8* %5, i8* %0)
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%21 = call i32 @system(i8* %5)
%22 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @strcat(i8* %5, i8* %2)
%24 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @strcat(i8* %5, i8* %0)
%26 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @strcat(i8* %5, i8* %1)
%28 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %5)
%29 = call i32 @system(i8* %5)
%30 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 @strcat(i8* %5, i8* %2)
%32 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @strcat(i8* %5, i8* %1)
%34 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 @strcat(i8* %5, i8* %0)
%36 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %5)
%37 = call i32 @system(i8* %5)
ret i32 1
}