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

/* Variables and functions */
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char const *,
                            size_t);
size_t iptables_delete_rule_from_chain(const char *chain_name,
                                       size_t rule_index, size_t use_xlock) {
  char cmd[100];
  if (use_xlock)
    snprintf(cmd, 100, "%s %s %s %zu", "iptables", "-w -D", chain_name,
             rule_index);
  else
    snprintf(cmd, 100, "%s %s %s %zu", "iptables", "-D", chain_name,
             rule_index);
  FILE *in;
  extern FILE *popen();
  if (!(in = popen(cmd, "r"))) {
    return 1;
  }
  pclose(in);
  return 0;
}


x86 assembly (clang, -O0):
<iptables_delete_rule_from_chain>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1189 <iptables_delete_rule_from_chain+0x59>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%r9
mov    -0x18(%rbp),%rax
mov    $0x64,%esi
lea    0xe93(%rip),%rdx
lea    0xe99(%rip),%rcx
lea    0xe9b(%rip),%r8
mov    %rax,(%rsp)
call   1040 <snprintf@plt>
jmp    11bb <iptables_delete_rule_from_chain+0x8b>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%r9
mov    -0x18(%rbp),%rax
mov    $0x64,%esi
lea    0xe5c(%rip),%rdx
lea    0xe62(%rip),%rcx
lea    0xe67(%rip),%r8
mov    %rax,(%rsp)
call   1040 <snprintf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1050 <popen@plt>
mov    %rax,-0x98(%rbp)
cmp    $0x0,%rax
jne    11ee <iptables_delete_rule_from_chain+0xbe>
movq   $0x1,-0x8(%rbp)
jmp    1202 <iptables_delete_rule_from_chain+0xd2>
mov    -0x98(%rbp),%rdi
call   1030 <pclose@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iptables_delete_rule_from_chain>:
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%r9
test   %rdx,%rdx
lea    0xed4(%rip),%rax
lea    0xeca(%rip),%r8
cmove  %rax,%r8
mov    %rsi,(%rsp)
lea    0xea5(%rip),%rdx
lea    0xeab(%rip),%rcx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <snprintf@plt>
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <popen@plt>
test   %rax,%rax
je     1196 <iptables_delete_rule_from_chain+0x66>
mov    %rax,%rdi
call   1030 <pclose@plt>
xor    %eax,%eax
jmp    119b <iptables_delete_rule_from_chain+0x6b>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%s %s %s %zu\00"
@.str.1 = [9 x i8] c"iptables\00"
@.str.2 = [6 x i8] c"-w -D\00"
@.str.3 = [3 x i8] c"-D\00"
@.str.4 = [2 x i8] c"r\00"
define i64 @iptables_delete_rule_from_chain(i8* %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca [100 x i8]
%9 = alloca i32*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%10 = load i64, i64* %7
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = load i64, i64* %6
%16 = call i32 @snprintf(i8* %13, i32 100, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %14, i64 %15)
br label %22
17: ; preds = %3
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%19 = load i8*, i8** %5
%20 = load i64, i64* %6
%21 = call i32 @snprintf(i8* %18, i32 100, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %19, i64 %20)
br label %22
22: ; preds = %17, %12
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%24 = call i32* (i8*, i8*, ...) bitcast (i32* (...)* @popen to i32* (i8*, i8*, ...)*)(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %24, i32** %9
%25 = icmp ne i32* %24, null
br i1 %25, label %27, label %26
26: ; preds = %22
store i64 1, i64* %4
br label %30
27: ; preds = %22
%28 = load i32*, i32** %9
%29 = call i32 @pclose(i32* %28)
store i64 0, i64* %4
br label %30
30: ; preds = %27, %26
%31 = load i64, i64* %4
ret i64 %31
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s %s %s %zu\00"
@.str.1 = [9 x i8] c"iptables\00"
@.str.2 = [6 x i8] c"-w -D\00"
@.str.3 = [3 x i8] c"-D\00"
@.str.4 = [2 x i8] c"r\00"
define i64 @iptables_delete_rule_from_chain(i8* %0, i64 %1, i64 %2) {
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = icmp eq i64 %2, 0
%7 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%8 = call i32 @snprintf(i8* %5, i32 100, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %0, i64 %1)
%9 = call i32* (i8*, i8*, ...) bitcast (i32* (...)* @popen to i32* (i8*, i8*, ...)*)(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %13, label %11
11: ; preds = %3
%12 = call i32 @pclose(i32* %9)
br label %13
13: ; preds = %3, %11
%14 = phi i64 [ 0, %11 ], [ 1, %3 ]
ret i64 %14
}