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


x86 assembly (clang, -O0):
<iptables_create_new_chain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1187 <iptables_create_new_chain+0x57>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    $0x64,%esi
lea    0xe9e(%rip),%rdx
lea    0xea3(%rip),%rcx
lea    0xea5(%rip),%r8
lea    0xea1(%rip),%r9
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    11b0 <iptables_create_new_chain+0x80>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%r9
mov    $0x64,%esi
lea    0xe68(%rip),%rdx
lea    0xe6a(%rip),%rcx
lea    0xe6f(%rip),%r8
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x80(%rbp),%rdi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1050 <popen@plt>
mov    %rax,-0x88(%rbp)
cmp    $0x0,%rax
jne    11e0 <iptables_create_new_chain+0xb0>
movq   $0x1,-0x8(%rbp)
jmp    11f4 <iptables_create_new_chain+0xc4>
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_create_new_chain>:
sub    $0x78,%rsp
mov    %rdi,%r9
test   %rsi,%rsi
je     115e <iptables_create_new_chain+0x2e>
mov    %r9,(%rsp)
lea    0xeb9(%rip),%rdx
lea    0xebe(%rip),%rcx
lea    0xec0(%rip),%r8
lea    0xebc(%rip),%r9
jmp    1173 <iptables_create_new_chain+0x43>
lea    0xe9e(%rip),%rdx
lea    0xea0(%rip),%rcx
lea    0xea5(%rip),%r8
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xe90(%rip),%rsi
lea    0x10(%rsp),%rdi
xor    %eax,%eax
call   1050 <popen@plt>
test   %rax,%rax
je     11ab <iptables_create_new_chain+0x7b>
mov    %rax,%rdi
call   1030 <pclose@plt>
xor    %eax,%eax
add    $0x78,%rsp
ret
mov    $0x1,%eax
add    $0x78,%rsp
ret

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