#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*/ LOG_DEBUG;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ _debug(char *, int, int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int fscanf(int /*<<< orphan*/ *, char *, unsigned long long *, char *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char const *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
unsigned long long int iptables_fw_total_download() {
  FILE *output;
  const char *script;
  char target[4096];
  int rc;
  unsigned long long int counter;
  script = "iptables -v -n -x -t mangle -L POSTROUTING";
  output = popen(script, "r");
  if (!output) {
    _debug("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/src/"
           "fw_iptables.c",
           963, LOG_ERR, "popen(): %s", strerror(errno));
    return 0;
  }
  while (('\n' != fgetc(output)) && !feof(output)) {
  }
  while (('\n' != fgetc(output)) && !feof(output)) {
  }
  while (!feof(output)) {
    rc = fscanf(output, "%*s %llu %s ", &counter, target);
    if (2 == rc && !strcmp(target, "ndsINC")) {
      _debug("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/"
             "src/fw_iptables.c",
             974, LOG_DEBUG, "Total incoming Bytes=%llu", counter);
      pclose(output);
      return counter;
    }
    while (('\n' != fgetc(output)) && !feof(output)) {
    }
  }
  pclose(output);
  _debug("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/src/"
         "fw_iptables.c",
         983, LOG_WARNING, "Can't find target %s in mangle table", "ndsINC");
  return 0;
}


x86 assembly (clang, -O0):
<iptables_fw_total_download>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
lea    0xe6e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1202 <iptables_fw_total_download+0x82>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1034(%rbp)
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x1034(%rbp),%edx
mov    %rax,%r8
lea    0xe4b(%rip),%rdi
mov    $0x3c3,%esi
lea    0xed0(%rip),%rcx
mov    $0x0,%al
call   1080 <_debug@plt>
movq   $0x0,-0x8(%rbp)
jmp    13f8 <iptables_fw_total_download+0x278>
jmp    1207 <iptables_fw_total_download+0x87>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
movsbl %al,%edx
xor    %eax,%eax
mov    $0xa,%ecx
cmp    %edx,%ecx
mov    %al,-0x1035(%rbp)
je     123f <iptables_fw_total_download+0xbf>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x1035(%rbp)
mov    -0x1035(%rbp),%al
test   $0x1,%al
jne    1252 <iptables_fw_total_download+0xd2>
jmp    1257 <iptables_fw_total_download+0xd7>
jmp    1207 <iptables_fw_total_download+0x87>
jmp    125c <iptables_fw_total_download+0xdc>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
movsbl %al,%edx
xor    %eax,%eax
mov    $0xa,%ecx
cmp    %edx,%ecx
mov    %al,-0x1036(%rbp)
je     1294 <iptables_fw_total_download+0x114>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x1036(%rbp)
mov    -0x1036(%rbp),%al
test   $0x1,%al
jne    12a7 <iptables_fw_total_download+0x127>
jmp    12ac <iptables_fw_total_download+0x12c>
jmp    125c <iptables_fw_total_download+0xdc>
jmp    12b1 <iptables_fw_total_download+0x131>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12cf <iptables_fw_total_download+0x14f>
jmp    13bd <iptables_fw_total_download+0x23d>
mov    -0x10(%rbp),%rdi
lea    -0x1020(%rbp),%rcx
lea    0xde9(%rip),%rsi
lea    -0x1030(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,-0x1024(%rbp)
mov    $0x2,%eax
cmp    -0x1024(%rbp),%eax
jne    1363 <iptables_fw_total_download+0x1e3>
lea    -0x1020(%rbp),%rdi
lea    0xdc5(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1363 <iptables_fw_total_download+0x1e3>
mov    0x2ca9(%rip),%rax
mov    (%rax),%edx
mov    -0x1030(%rbp),%r8
lea    0xcf6(%rip),%rdi
mov    $0x3ce,%esi
lea    0xd9b(%rip),%rcx
mov    $0x0,%al
call   1080 <_debug@plt>
mov    -0x10(%rbp),%rdi
call   1030 <pclose@plt>
mov    -0x1030(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    13f8 <iptables_fw_total_download+0x278>
jmp    1368 <iptables_fw_total_download+0x1e8>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
movsbl %al,%edx
xor    %eax,%eax
mov    $0xa,%ecx
cmp    %edx,%ecx
mov    %al,-0x1037(%rbp)
je     13a0 <iptables_fw_total_download+0x220>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x1037(%rbp)
mov    -0x1037(%rbp),%al
test   $0x1,%al
jne    13b3 <iptables_fw_total_download+0x233>
jmp    13b8 <iptables_fw_total_download+0x238>
jmp    1368 <iptables_fw_total_download+0x1e8>
jmp    12b1 <iptables_fw_total_download+0x131>
mov    -0x10(%rbp),%rdi
call   1030 <pclose@plt>
mov    0x2c1b(%rip),%rax
mov    (%rax),%edx
lea    0xc57(%rip),%rdi
mov    $0x3d7,%esi
lea    0xd16(%rip),%rcx
lea    0xcee(%rip),%r8
mov    $0x0,%al
call   1080 <_debug@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iptables_fw_total_download>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
lea    0xe78(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1080 <popen@plt>
test   %rax,%rax
je     1213 <iptables_fw_total_download+0xa3>
mov    %rax,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0xa,%al
je     11cc <iptables_fw_total_download+0x5c>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     11a0 <iptables_fw_total_download+0x30>
jmp    11cc <iptables_fw_total_download+0x5c>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11d8 <iptables_fw_total_download+0x68>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0xa,%al
jne    11c0 <iptables_fw_total_download+0x50>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     1260 <iptables_fw_total_download+0xf0>
mov    %rbx,%rdi
call   1030 <pclose@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%edx
lea    0xe31(%rip),%rdi
lea    0xef5(%rip),%rcx
lea    0xecd(%rip),%r8
xor    %ebx,%ebx
mov    $0x3d7,%esi
jmp    1244 <iptables_fw_total_download+0xd4>
mov    0x2da6(%rip),%rax
mov    (%rax),%ebp
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdfc(%rip),%rdi
lea    0xe86(%rip),%rcx
xor    %ebx,%ebx
mov    $0x3c3,%esi
mov    %ebp,%edx
mov    %rax,%r8
xor    %eax,%eax
call   1070 <_debug@plt>
mov    %rbx,%rax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe63(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
mov    $0x4973646e,%r13d
mov    $0x434e49,%ebp
jmp    1290 <iptables_fw_total_download+0x120>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11e4 <iptables_fw_total_download+0x74>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <fscanf@plt>
cmp    $0x2,%eax
jne    12c0 <iptables_fw_total_download+0x150>
mov    0x10(%rsp),%eax
xor    %r13d,%eax
mov    0x13(%rsp),%ecx
xor    %ebp,%ecx
or     %eax,%ecx
je     12da <iptables_fw_total_download+0x16a>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0xa,%al
je     1280 <iptables_fw_total_download+0x110>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     12c0 <iptables_fw_total_download+0x150>
jmp    1280 <iptables_fw_total_download+0x110>
mov    0x2cef(%rip),%rax
mov    (%rax),%edx
mov    0x8(%rsp),%r8
lea    0xd3e(%rip),%rdi
lea    0xde8(%rip),%rcx
mov    $0x3ce,%esi
xor    %eax,%eax
call   1070 <_debug@plt>
mov    %rbx,%rdi
call   1030 <pclose@plt>
mov    0x8(%rsp),%rbx
jmp    124b <iptables_fw_total_download+0xdb>

LLVM IR (-O0):
@.str = [43 x i8] c"iptables -v -n -x -t mangle -L POSTROUTING\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/src/fw_iptables.c\00"
@LOG_ERR = global i32 0
@.str.3 = [12 x i8] c"popen(): %s\00"
@errno = global i32 0
@.str.4 = [13 x i8] c"%*s %llu %s \00"
@.str.5 = [7 x i8] c"ndsINC\00"
@LOG_DEBUG = global i32 0
@.str.6 = [26 x i8] c"Total incoming Bytes=%llu\00"
@LOG_WARNING = global i32 0
@.str.7 = [37 x i8] c"Can't find target %s in mangle table\00"
define i64 @iptables_fw_total_download() {
%1 = alloca i64
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca [4096 x i8]
%5 = alloca i32
%6 = alloca i64
store i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8** %3
%7 = load i8*, i8** %3
%8 = call i32* @popen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp ne i32* %9, null
br i1 %10, label %16, label %11
11: ; preds = %0
%12 = load i32, i32* @LOG_ERR
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = call i32 (i8*, i32, i32, i8*, ...) @_debug(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0), i32 963, i32 %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %14)
store i64 0, i64* %1
br label %87
16: ; preds = %0
br label %17
17: ; preds = %29, %16
%18 = load i32*, i32** %2
%19 = call signext i8 @fgetc(i32* %18)
%20 = sext i8 %19 to i32
%21 = icmp ne i32 10, %20
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i32*, i32** %2
%24 = call i32 @feof(i32* %23)
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
br label %27
27: ; preds = %22, %17
%28 = phi i1 [ false, %17 ], [ %26, %22 ]
br i1 %28, label %29, label %30
29: ; preds = %27
br label %17
30: ; preds = %27
br label %31
31: ; preds = %43, %30
%32 = load i32*, i32** %2
%33 = call signext i8 @fgetc(i32* %32)
%34 = sext i8 %33 to i32
%35 = icmp ne i32 10, %34
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i32*, i32** %2
%38 = call i32 @feof(i32* %37)
%39 = icmp ne i32 %38, 0
%40 = xor i1 %39, true
br label %41
41: ; preds = %36, %31
%42 = phi i1 [ false, %31 ], [ %40, %36 ]
br i1 %42, label %43, label %44
43: ; preds = %41
br label %31
44: ; preds = %41
br label %45
45: ; preds = %81, %44
%46 = load i32*, i32** %2
%47 = call i32 @feof(i32* %46)
%48 = icmp ne i32 %47, 0
%49 = xor i1 %48, true
br i1 %49, label %50, label %82
50: ; preds = %45
%51 = load i32*, i32** %2
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%53 = call i32 @fscanf(i32* %51, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i64* %6, i8* %52)
store i32 %53, i32* %5
%54 = load i32, i32* %5
%55 = icmp eq i32 2, %54
br i1 %55, label %56, label %67
56: ; preds = %50
%57 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%58 = call i32 @strcmp(i8* %57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%59 = icmp ne i32 %58, 0
br i1 %59, label %67, label %60
60: ; preds = %56
%61 = load i32, i32* @LOG_DEBUG
%62 = load i64, i64* %6
%63 = call i32 (i8*, i32, i32, i8*, ...) @_debug(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0), i32 974, i32 %61, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 %62)
%64 = load i32*, i32** %2
%65 = call i32 @pclose(i32* %64)
%66 = load i64, i64* %6
store i64 %66, i64* %1
br label %87
67: ; preds = %56, %50
br label %68
68: ; preds = %80, %67
%69 = load i32*, i32** %2
%70 = call signext i8 @fgetc(i32* %69)
%71 = sext i8 %70 to i32
%72 = icmp ne i32 10, %71
br i1 %72, label %73, label %78
73: ; preds = %68
%74 = load i32*, i32** %2
%75 = call i32 @feof(i32* %74)
%76 = icmp ne i32 %75, 0
%77 = xor i1 %76, true
br label %78
78: ; preds = %73, %68
%79 = phi i1 [ false, %68 ], [ %77, %73 ]
br i1 %79, label %80, label %81
80: ; preds = %78
br label %68
81: ; preds = %78
br label %45
82: ; preds = %45
%83 = load i32*, i32** %2
%84 = call i32 @pclose(i32* %83)
%85 = load i32, i32* @LOG_WARNING
%86 = call i32 (i8*, i32, i32, i8*, ...) @_debug(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0), i32 983, i32 %85, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
store i64 0, i64* %1
br label %87
87: ; preds = %82, %60, %11
%88 = load i64, i64* %1
ret i64 %88
}

LLVM IR (-O2):
@.str = [43 x i8] c"iptables -v -n -x -t mangle -L POSTROUTING\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lynxis/nodogsplash/refs/heads/master/src/fw_iptables.c\00"
@LOG_ERR = global i32 0
@.str.3 = [12 x i8] c"popen(): %s\00"
@errno = global i32 0
@.str.4 = [13 x i8] c"%*s %llu %s \00"
@.str.5 = [7 x i8] c"ndsINC\00"
@LOG_DEBUG = global i32 0
@.str.6 = [26 x i8] c"Total incoming Bytes=%llu\00"
@LOG_WARNING = global i32 0
@.str.7 = [37 x i8] c"Can't find target %s in mangle table\00"
define i64 @iptables_fw_total_download() {
%1 = alloca [4096 x i8]
%2 = alloca i64
%3 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%4 = bitcast i64* %2 to i8*
%5 = tail call i32* @popen(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = load i32, i32* @LOG_ERR
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 (i8*, i32, i32, i8*, ...) @_debug(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0), i32 963, i32 %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %10)
br label %54
12: ; preds = %0, %15
%13 = tail call signext i8 @fgetc(i32* %5)
%14 = icmp eq i8 %13, 10
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i32 @feof(i32* %5)
%17 = icmp eq i32 %16, 0
br i1 %17, label %12, label %18
18: ; preds = %12, %15
br label %19
19: ; preds = %18, %22
%20 = tail call signext i8 @fgetc(i32* %5)
%21 = icmp eq i8 %20, 10
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = tail call i32 @feof(i32* %5)
%24 = icmp eq i32 %23, 0
br i1 %24, label %19, label %25
25: ; preds = %19, %22
%26 = call i32 @feof(i32* %5)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %50
28: ; preds = %25, %47
%29 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i64* %2, i8* %3)
%30 = icmp eq i32 %29, 2
br i1 %30, label %32, label %31
31: ; preds = %32, %28
br label %41
32: ; preds = %28
%33 = call i32 @bcmp(i8* dereferenceable(7) %3, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 7)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %31
35: ; preds = %32
%36 = load i32, i32* @LOG_DEBUG
%37 = load i64, i64* %2
%38 = call i32 (i8*, i32, i32, i8*, ...) @_debug(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0), i32 974, i32 %36, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 %37)
%39 = call i32 @pclose(i32* %5)
%40 = load i64, i64* %2
br label %54
41: ; preds = %31, %44
%42 = call signext i8 @fgetc(i32* %5)
%43 = icmp eq i8 %42, 10
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = call i32 @feof(i32* %5)
%46 = icmp eq i32 %45, 0
br i1 %46, label %41, label %47
47: ; preds = %41, %44
%48 = call i32 @feof(i32* %5)
%49 = icmp eq i32 %48, 0
br i1 %49, label %28, label %50
50: ; preds = %47, %25
%51 = call i32 @pclose(i32* %5)
%52 = load i32, i32* @LOG_WARNING
%53 = call i32 (i8*, i32, i32, i8*, ...) @_debug(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.2, i64 0, i64 0), i32 983, i32 %52, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %54
54: ; preds = %50, %35, %7
%55 = phi i64 [ %40, %35 ], [ 0, %50 ], [ 0, %7 ]
ret i64 %55
}