#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int, int);
int sprintf(char *, char *, char *, char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ system(char *);
void delete_proxy_cmd(char *addr, int portNumber, char *namespace) {
  int cmdlen;
  char *cmd;
  cmd = (char *)malloc(sizeof(char) * 200);
  memset(cmd, (int)'\0', 200);
  cmdlen = sprintf(cmd,
                   "ip netns exec %s %s -t nat -D PREROUTING -p tcp --dport %d "
                   "-j DNAT --to-destination %s:22 ",
                   namespace, "/sbin/iptables", portNumber, addr);
  fprintf(stdout, "%s\n", cmd);
  system(cmd);
  memset(cmd, (int)'\0', 200);
  cmdlen =
      sprintf(cmd, "ip netns exec %s %s -D FORWARD -p tcp -s %s -j ACCEPT ",
              namespace, "/sbin/iptables", addr);
  fprintf(stdout, "%s\n", cmd);
  system(cmd);
  memset(cmd, (int)'\0', 200);
  cmdlen = sprintf(
      cmd,
      "ip netns exec %s %s -t nat -D POSTROUTING -p tcp -s %s -j MASQUERADE ",
      namespace, "/sbin/iptables", addr);
  fprintf(stdout, "%s\n", cmd);
  system(cmd);
  free(cmd);
}


x86 assembly (clang, -O0):
<delete_proxy_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0xc8,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0xc(%rbp),%r8d
mov    -0x8(%rbp),%r9
lea    0xe58(%rip),%rsi
lea    0xeac(%rip),%rcx
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe9d(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <system@plt>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%r8
lea    0xe70(%rip),%rsi
lea    0xe56(%rip),%rcx
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe47(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <system@plt>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%r8
lea    0xe51(%rip),%rsi
lea    0xe00(%rip),%rcx
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xdf1(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <system@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete_proxy_cmd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%r14
mov    $0xc8,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
lea    0xe6a(%rip),%rsi
lea    0xebe(%rip),%r12
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %ebp,%r8d
mov    %r14,%r9
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    0x2e26(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xea6(%rip),%r13
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    0x0(%rbp),%edi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1050 <memset@plt>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    0x0(%rbp),%edi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [91 x i8] c"ip netns exec %s %s -t nat -D PREROUTING -p tcp --dport %d -j DNAT --to-destination %s:22 \00"
@.str.1 = [15 x i8] c"/sbin/iptables\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [55 x i8] c"ip netns exec %s %s -D FORWARD -p tcp -s %s -j ACCEPT \00"
@.str.4 = [70 x i8] c"ip netns exec %s %s -t nat -D POSTROUTING -p tcp -s %s -j MASQUERADE \00"
define void @delete_proxy_cmd(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = call i64 @malloc(i32 200)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %8
%11 = load i8*, i8** %8
%12 = call i32 @memset(i8* %11, i32 0, i32 200)
%13 = load i8*, i8** %8
%14 = load i8*, i8** %6
%15 = load i32, i32* %5
%16 = load i8*, i8** %4
%17 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0), i8* %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %15, i8* %16)
store i32 %17, i32* %7
%18 = load i32, i32* @stdout
%19 = load i8*, i8** %8
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %8
%22 = call i32 @system(i8* %21)
%23 = load i8*, i8** %8
%24 = call i32 @memset(i8* %23, i32 0, i32 200)
%25 = load i8*, i8** %8
%26 = load i8*, i8** %6
%27 = load i8*, i8** %4
%28 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i8* %26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %27)
store i32 %28, i32* %7
%29 = load i32, i32* @stdout
%30 = load i8*, i8** %8
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load i8*, i8** %8
%33 = call i32 @system(i8* %32)
%34 = load i8*, i8** %8
%35 = call i32 @memset(i8* %34, i32 0, i32 200)
%36 = load i8*, i8** %8
%37 = load i8*, i8** %6
%38 = load i8*, i8** %4
%39 = call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0), i8* %37, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %38)
store i32 %39, i32* %7
%40 = load i32, i32* @stdout
%41 = load i8*, i8** %8
%42 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %8
%44 = call i32 @system(i8* %43)
%45 = load i8*, i8** %8
%46 = call i32 @free(i8* %45)
ret void
}

LLVM IR (-O2):
@.str = [91 x i8] c"ip netns exec %s %s -t nat -D PREROUTING -p tcp --dport %d -j DNAT --to-destination %s:22 \00"
@.str.1 = [15 x i8] c"/sbin/iptables\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [55 x i8] c"ip netns exec %s %s -D FORWARD -p tcp -s %s -j ACCEPT \00"
@.str.4 = [70 x i8] c"ip netns exec %s %s -t nat -D POSTROUTING -p tcp -s %s -j MASQUERADE \00"
define void @delete_proxy_cmd(i8* %0, i32 %1, i8* %2) {
%4 = tail call i64 @malloc(i32 200)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @memset(i8* %5, i32 0, i32 200)
%7 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @.str, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %0)
%8 = load i32, i32* @stdout
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%10 = tail call i32 @system(i8* %5)
%11 = tail call i32 @memset(i8* %5, i32 0, i32 200)
%12 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%15 = tail call i32 @system(i8* %5)
%16 = tail call i32 @memset(i8* %5, i32 0, i32 200)
%17 = tail call i32 (i8*, i8*, i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%18 = load i32, i32* @stdout
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%20 = tail call i32 @system(i8* %5)
%21 = tail call i32 @free(i8* %5)
ret void
}