#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 iptables_flush_chain(const char *chain_name, size_t use_xlock) {
  char cmd[100];
  if (use_xlock)
    snprintf(cmd, 100, "%s %s %s", "iptables", "-w -F", chain_name);
  else
    snprintf(cmd, 100, "%s %s %s", "iptables", "-F", chain_name);
  FILE *in;
  extern FILE *popen();
  if (!(in = popen(cmd, "r"))) {
    return 1;
  }
  pclose(in);
  return 0;
}


x86 assembly (clang, -O0):
<iptables_flush_chain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117a <iptables_flush_chain+0x4a>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%r9
mov    $0x64,%esi
lea    0xe9e(%rip),%rdx
lea    0xea0(%rip),%rcx
lea    0xea2(%rip),%r8
call   1040 <snprintf@plt>
jmp    11a1 <iptables_flush_chain+0x71>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%r9
mov    $0x64,%esi
lea    0xe72(%rip),%rdx
lea    0xe74(%rip),%rcx
lea    0xe79(%rip),%r8
call   1040 <snprintf@plt>
lea    -0x80(%rbp),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1050 <popen@plt>
mov    %rax,-0x88(%rbp)
cmp    $0x0,%rax
jne    11d1 <iptables_flush_chain+0xa1>
movq   $0x1,-0x8(%rbp)
jmp    11e5 <iptables_flush_chain+0xb5>
mov    -0x88(%rbp),%rdi
call   1030 <pclose@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iptables_flush_chain>:
push   %rbx
sub    $0x70,%rsp
mov    %rdi,%r9
test   %rsi,%rsi
lea    0xed3(%rip),%rax
lea    0xec9(%rip),%r8
cmove  %rax,%r8
lea    0xeac(%rip),%rdx
lea    0xeae(%rip),%rcx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <snprintf@plt>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <popen@plt>
test   %rax,%rax
je     118d <iptables_flush_chain+0x5d>
mov    %rax,%rdi
call   1030 <pclose@plt>
xor    %eax,%eax
jmp    1192 <iptables_flush_chain+0x62>
mov    $0x1,%eax
add    $0x70,%rsp
pop    %rbx
ret

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

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