Coder Social home page Coder Social logo

immunant / c2rust Goto Github PK

View Code? Open in Web Editor NEW
3.7K 3.7K 203.0 78.76 MB

Migrate C code to Rust

Home Page: https://c2rust.com/

License: Other

C++ 2.34% CMake 0.08% Rust 77.31% Python 6.26% Shell 0.71% C 1.81% Dockerfile 0.02% HTML 9.51% CSS 0.13% Lua 1.65% Emacs Lisp 0.01% Nix 0.01% Handlebars 0.03% Vim Script 0.12%
memory-safety migration rust security-hardening translation transpiler

c2rust's People

Contributors

64kramsystem avatar afetisov avatar ahomescu avatar aneksteind avatar blinklad avatar boyland-pf avatar bytewife avatar centril avatar chrysn avatar dependabot[bot] avatar dgherzka avatar fw-immunant avatar glguy avatar hakuyume avatar harpocrates avatar jameysharp avatar kkysen avatar legneato avatar marcograss avatar milahu avatar mjgarton avatar nnethercote avatar orowith2os avatar petrochenkov avatar rinon avatar saldivarcher avatar spernsteiner avatar thedan64 avatar thedataking avatar varkor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

c2rust's Issues

Tracking Issue: Translation nightly features

This is the tracking issue for generated code which requires nightly to run:

  • Assembly - asm - rust-lang/rust#29722 asm! stabilized since 1.59.0
  • Intrinsics for atomic operations - core_intrinsics - Unlikely to ever be stabilized itself, no tracking issue
  • Ptr to ptr offset calculation - ptr_wrapping_offset_from - rust-lang/rust#41079 wrapping_offset_from removed and offset_from added in 1.47.0, still const unstable.
  • Labels for breaks in relooper - label_break_value - rust-lang/rust#48594
  • Opaque extern types - extern_types - rust-lang/rust#43467
  • Thread Local variables - thread_local - rust-lang/rust#29594
  • Cast const ptr to usize - const_raw_ptr_to_usize_cast - rust-lang/rust#51910 const_raw_ptr_to_usize_cast removed, no longer needed either, and impossible in C as well
  • Cast const slice to pointer - const_slice_as_ptr - [].as_ptr() const since 1.32.0
  • C-compatible variadic functions - c_variadics - rust-lang/rust#44930
  • Libc types - libc - Now generating Cargo.toml files which use the libc crate

bindgen-style enums?

bindgen currently supports 4 different enum representations, each of which has their place in different circumstances. It would be very useful to be able to choose other enum representations, especially if we had the ability to scope that configuration to specific enums.

Hex literals

A minor issue, but we're using a lot of hex literals in our code and these are lost by the c2rust conversion.

Allow whitelisting of flexible array members

We have two options here since we always need the programmer to make a determination:

  1. update the sources to use C99-style flexible array members,
  2. mark/whitelist non-C99 flexible array members in a configuration file.

The second option seems most appropriate in two cases:

  • when tracking upstream C sources,
  • when the non-C99 flexible array members are in system headers.

local static const variable translated to non-compiling code with global static initializer

#include <stdlib.h>
int main() {
    static const size_t val = 1ULL << ((((unsigned)(sizeof(size_t) == 4 ? 30 : 31))
)-1);
    size_t x =  val;
    int ret = 0;
    while (x) {
        ret += 1;
        x >>=1;
    }
    return x;
}

translates to

#![allow
( dead_code , mutable_transmutes , non_camel_case_types , non_snake_case ,
non_upper_case_globals , unused_mut )]
#![feature ( libc , used )]
extern crate libc;
pub type size_t = libc::c_ulong;
#[export_name = "main"]
pub unsafe extern "C" fn main_0() -> libc::c_int {
    static mut val: size_t = 0;
    let mut x: size_t = val;
    let mut ret: libc::c_int = 0i32;
    while 0 != x { ret += 1i32; x >>= 1i32 }
    return x as libc::c_int;
}
unsafe extern "C" fn run_static_initializers() -> () {
    val =
        (1u64 <<
             ((if ::std::mem::size_of::<size_t>() as libc::c_ulong ==
                      4i32 as libc::c_ulong {
                   30i32
               } else { 31i32 }) as
                  libc::c_uint).wrapping_sub(1i32 as libc::c_uint)) as size_t
}
#[used]
#[cfg_attr ( target_os = "linux" , link_section = ".init_array" )]
#[cfg_attr ( target_os = "windows" , link_section = ".CRT$XIB" )]
#[cfg_attr ( target_os = "macos" , link_section = "__DATA,__mod_init_func" )]
static INIT_ARRAY: [unsafe extern "C" fn() -> (); 1] =
    [run_static_initializers];

which won't compile due to the static initializers being unable to reference a local variable

However if I change things up just a bit and remove one of the useless casts

#include <stdlib.h>
int main() {
    static const size_t val = 1ULL << (sizeof(size_t) == 4 ? 30 : 31);
    size_t x =  val;
    int ret = 0;
    while (x) {
        ret += 1;
        x >>=1;
    }
    return x;
}

it works "fine"

#![allow
( dead_code , mutable_transmutes , non_camel_case_types , non_snake_case ,
non_upper_case_globals , unused_mut )]
#![feature ( libc )]
extern crate libc;
pub type size_t = libc::c_ulong;
#[export_name = "main"]
pub unsafe extern "C" fn main_0() -> libc::c_int {
    static mut val: size_t =
        unsafe {
            (1u64 <<
                 if ::std::mem::size_of::<size_t>() as libc::c_ulong ==
                        4i32 as libc::c_ulong {
                     30i32
                 } else { 31i32 }) as size_t
        };
    let mut x: size_t = val;
    let mut ret: libc::c_int = 0i32;
    while 0 != x { ret += 1i32; x >>= 1i32 }
    return x as libc::c_int;
}

though I still think it's too bad that it is a static mut in this case... I suppose part of it is due to sizeof<> not being a const expr?

c2rust skips building of one function

In order to reproduce, copy-paste the following code into the website and observe the errors after trying to compile:

# 1 "afl-fuzz-single.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "afl-fuzz-single.c"
# 23 "afl-fuzz-single.c"
# 1 "config.h" 1
# 20 "config.h"
# 1 "types.h" 1
# 20 "types.h"
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h" 1 3 4
# 9 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h" 3 4
# 1 "/usr/include/stdint.h" 1 3 4
# 26 "/usr/include/stdint.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 1 3 4
# 33 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 424 "/usr/include/features.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 1 3 4
# 427 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
# 428 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/long-double.h" 1 3 4
# 429 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 2 3 4
# 425 "/usr/include/features.h" 2 3 4
# 448 "/usr/include/features.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 1 3 4
# 10 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/gnu/stubs-64.h" 1 3 4
# 11 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 2 3 4
# 449 "/usr/include/features.h" 2 3 4
# 34 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 2 3 4
# 27 "/usr/include/stdint.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/types.h" 1 3 4
# 27 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
# 28 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4



# 30 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4
typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;


typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;

typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;







typedef long int __quad_t;
typedef unsigned long int __u_quad_t;







typedef long int __intmax_t;
typedef unsigned long int __uintmax_t;
# 130 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/typesizes.h" 1 3 4
# 131 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4


typedef unsigned long int __dev_t;
typedef unsigned int __uid_t;
typedef unsigned int __gid_t;
typedef unsigned long int __ino_t;
typedef unsigned long int __ino64_t;
typedef unsigned int __mode_t;
typedef unsigned long int __nlink_t;
typedef long int __off_t;
typedef long int __off64_t;
typedef int __pid_t;
typedef struct { int __val[2]; } __fsid_t;
typedef long int __clock_t;
typedef unsigned long int __rlim_t;
typedef unsigned long int __rlim64_t;
typedef unsigned int __id_t;
typedef long int __time_t;
typedef unsigned int __useconds_t;
typedef long int __suseconds_t;

typedef int __daddr_t;
typedef int __key_t;


typedef int __clockid_t;


typedef void * __timer_t;


typedef long int __blksize_t;




typedef long int __blkcnt_t;
typedef long int __blkcnt64_t;


typedef unsigned long int __fsblkcnt_t;
typedef unsigned long int __fsblkcnt64_t;


typedef unsigned long int __fsfilcnt_t;
typedef unsigned long int __fsfilcnt64_t;


typedef long int __fsword_t;

typedef long int __ssize_t;


typedef long int __syscall_slong_t;

typedef unsigned long int __syscall_ulong_t;



typedef __off64_t __loff_t;
typedef char *__caddr_t;


typedef long int __intptr_t;


typedef unsigned int __socklen_t;




typedef int __sig_atomic_t;
# 28 "/usr/include/stdint.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/wchar.h" 1 3 4
# 29 "/usr/include/stdint.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
# 30 "/usr/include/stdint.h" 2 3 4




# 1 "/usr/include/x86_64-linux-gnu/bits/stdint-intn.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/bits/stdint-intn.h" 3 4
typedef __int8_t int8_t;
typedef __int16_t int16_t;
typedef __int32_t int32_t;
typedef __int64_t int64_t;
# 35 "/usr/include/stdint.h" 2 3 4


# 1 "/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h" 3 4
typedef __uint8_t uint8_t;
typedef __uint16_t uint16_t;
typedef __uint32_t uint32_t;
typedef __uint64_t uint64_t;
# 38 "/usr/include/stdint.h" 2 3 4





typedef signed char int_least8_t;
typedef short int int_least16_t;
typedef int int_least32_t;

typedef long int int_least64_t;






typedef unsigned char uint_least8_t;
typedef unsigned short int uint_least16_t;
typedef unsigned int uint_least32_t;

typedef unsigned long int uint_least64_t;
# 68 "/usr/include/stdint.h" 3 4
typedef signed char int_fast8_t;

typedef long int int_fast16_t;
typedef long int int_fast32_t;
typedef long int int_fast64_t;
# 81 "/usr/include/stdint.h" 3 4
typedef unsigned char uint_fast8_t;

typedef unsigned long int uint_fast16_t;
typedef unsigned long int uint_fast32_t;
typedef unsigned long int uint_fast64_t;
# 97 "/usr/include/stdint.h" 3 4
typedef long int intptr_t;


typedef unsigned long int uintptr_t;
# 111 "/usr/include/stdint.h" 3 4
typedef __intmax_t intmax_t;
typedef __uintmax_t uintmax_t;
# 10 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h" 2 3 4
# 21 "types.h" 2
# 1 "/usr/include/stdlib.h" 1 3 4
# 25 "/usr/include/stdlib.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 1 3 4
# 26 "/usr/include/stdlib.h" 2 3 4





# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 216 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 3 4
typedef long unsigned int size_t;
# 328 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 3 4
typedef int wchar_t;
# 32 "/usr/include/stdlib.h" 2 3 4







# 1 "/usr/include/x86_64-linux-gnu/bits/waitflags.h" 1 3 4
# 52 "/usr/include/x86_64-linux-gnu/bits/waitflags.h" 3 4
typedef enum
{
  P_ALL,
  P_PID,
  P_PGID
} idtype_t;
# 40 "/usr/include/stdlib.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/waitstatus.h" 1 3 4
# 41 "/usr/include/stdlib.h" 2 3 4
# 55 "/usr/include/stdlib.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/floatn.h" 1 3 4
# 120 "/usr/include/x86_64-linux-gnu/bits/floatn.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/floatn-common.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/bits/floatn-common.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/long-double.h" 1 3 4
# 25 "/usr/include/x86_64-linux-gnu/bits/floatn-common.h" 2 3 4
# 121 "/usr/include/x86_64-linux-gnu/bits/floatn.h" 2 3 4
# 56 "/usr/include/stdlib.h" 2 3 4


typedef struct
  {
    int quot;
    int rem;
  } div_t;



typedef struct
  {
    long int quot;
    long int rem;
  } ldiv_t;





__extension__ typedef struct
  {
    long long int quot;
    long long int rem;
  } lldiv_t;
# 97 "/usr/include/stdlib.h" 3 4
extern size_t __ctype_get_mb_cur_max (void) __attribute__ ((__nothrow__ , __leaf__)) ;



extern double atof (const char *__nptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;

extern int atoi (const char *__nptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;

extern long int atol (const char *__nptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;



__extension__ extern long long int atoll (const char *__nptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;



extern double strtod (const char *__restrict __nptr,
        char **__restrict __endptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));



extern float strtof (const char *__restrict __nptr,
       char **__restrict __endptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));

extern long double strtold (const char *__restrict __nptr,
       char **__restrict __endptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
# 176 "/usr/include/stdlib.h" 3 4
extern long int strtol (const char *__restrict __nptr,
   char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));

extern unsigned long int strtoul (const char *__restrict __nptr,
      char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));



__extension__
extern long long int strtoq (const char *__restrict __nptr,
        char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));

__extension__
extern unsigned long long int strtouq (const char *__restrict __nptr,
           char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));




__extension__
extern long long int strtoll (const char *__restrict __nptr,
         char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));

__extension__
extern unsigned long long int strtoull (const char *__restrict __nptr,
     char **__restrict __endptr, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
# 385 "/usr/include/stdlib.h" 3 4
extern char *l64a (long int __n) __attribute__ ((__nothrow__ , __leaf__)) ;


extern long int a64l (const char *__s)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;




# 1 "/usr/include/x86_64-linux-gnu/sys/types.h" 1 3 4
# 27 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4






typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;




typedef __loff_t loff_t;



typedef __ino_t ino_t;
# 60 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
typedef __dev_t dev_t;




typedef __gid_t gid_t;




typedef __mode_t mode_t;




typedef __nlink_t nlink_t;




typedef __uid_t uid_t;





typedef __off_t off_t;
# 98 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
typedef __pid_t pid_t;





typedef __id_t id_t;




typedef __ssize_t ssize_t;





typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;





typedef __key_t key_t;




# 1 "/usr/include/x86_64-linux-gnu/bits/types/clock_t.h" 1 3 4






typedef __clock_t clock_t;
# 128 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4

# 1 "/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h" 1 3 4






typedef __clockid_t clockid_t;
# 130 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/types/time_t.h" 1 3 4






typedef __time_t time_t;
# 131 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/types/timer_t.h" 1 3 4






typedef __timer_t timer_t;
# 132 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4
# 145 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 146 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4



typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
# 178 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));

typedef int register_t __attribute__ ((__mode__ (__word__)));
# 194 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 1 "/usr/include/endian.h" 1 3 4
# 36 "/usr/include/endian.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/endian.h" 1 3 4
# 37 "/usr/include/endian.h" 2 3 4
# 60 "/usr/include/endian.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 1 3 4
# 28 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
# 29 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 2 3 4






# 1 "/usr/include/x86_64-linux-gnu/bits/byteswap-16.h" 1 3 4
# 36 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 2 3 4
# 44 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 3 4
static __inline unsigned int
__bswap_32 (unsigned int __bsx)
{
  return __builtin_bswap32 (__bsx);
}
# 108 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 3 4
static __inline __uint64_t
__bswap_64 (__uint64_t __bsx)
{
  return __builtin_bswap64 (__bsx);
}
# 61 "/usr/include/endian.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/uintn-identity.h" 1 3 4
# 32 "/usr/include/x86_64-linux-gnu/bits/uintn-identity.h" 3 4
static __inline __uint16_t
__uint16_identity (__uint16_t __x)
{
  return __x;
}

static __inline __uint32_t
__uint32_identity (__uint32_t __x)
{
  return __x;
}

static __inline __uint64_t
__uint64_identity (__uint64_t __x)
{
  return __x;
}
# 62 "/usr/include/endian.h" 2 3 4
# 195 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4


# 1 "/usr/include/x86_64-linux-gnu/sys/select.h" 1 3 4
# 30 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/select.h" 1 3 4
# 22 "/usr/include/x86_64-linux-gnu/bits/select.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
# 23 "/usr/include/x86_64-linux-gnu/bits/select.h" 2 3 4
# 31 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4


# 1 "/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h" 1 3 4



# 1 "/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h" 1 3 4




typedef struct
{
  unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
} __sigset_t;
# 5 "/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h" 2 3 4


typedef __sigset_t sigset_t;
# 34 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4



# 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h" 1 3 4







struct timeval
{
  __time_t tv_sec;
  __suseconds_t tv_usec;
};
# 38 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4

# 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h" 1 3 4







struct timespec
{
  __time_t tv_sec;
  __syscall_slong_t tv_nsec;
};
# 40 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4



typedef __suseconds_t suseconds_t;





typedef long int __fd_mask;
# 59 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4
typedef struct
  {






    __fd_mask __fds_bits[1024 / (8 * (int) sizeof (__fd_mask))];


  } fd_set;






typedef __fd_mask fd_mask;
# 91 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4

# 101 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4
extern int select (int __nfds, fd_set *__restrict __readfds,
     fd_set *__restrict __writefds,
     fd_set *__restrict __exceptfds,
     struct timeval *__restrict __timeout);
# 113 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4
extern int pselect (int __nfds, fd_set *__restrict __readfds,
      fd_set *__restrict __writefds,
      fd_set *__restrict __exceptfds,
      const struct timespec *__restrict __timeout,
      const __sigset_t *__restrict __sigmask);
# 126 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4

# 198 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4







# 1 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 1 3 4
# 41 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/sysmacros.h" 1 3 4
# 42 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 2 3 4
# 71 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 3 4


extern unsigned int gnu_dev_major (__dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern unsigned int gnu_dev_minor (__dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern __dev_t gnu_dev_makedev (unsigned int __major, unsigned int __minor) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
# 85 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 3 4

# 206 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4






typedef __blksize_t blksize_t;






typedef __blkcnt_t blkcnt_t;



typedef __fsblkcnt_t fsblkcnt_t;



typedef __fsfilcnt_t fsfilcnt_t;
# 254 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 1 3 4
# 23 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h" 1 3 4
# 77 "/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h" 1 3 4
# 21 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
# 22 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h" 2 3 4
# 65 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h" 3 4
struct __pthread_rwlock_arch_t
{
  unsigned int __readers;
  unsigned int __writers;
  unsigned int __wrphase_futex;
  unsigned int __writers_futex;
  unsigned int __pad3;
  unsigned int __pad4;

  int __cur_writer;
  int __shared;
  signed char __rwelision;




  unsigned char __pad1[7];


  unsigned long int __pad2;


  unsigned int __flags;
# 99 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h" 3 4
};
# 78 "/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h" 2 3 4




typedef struct __pthread_internal_list
{
  struct __pthread_internal_list *__prev;
  struct __pthread_internal_list *__next;
} __pthread_list_t;
# 118 "/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h" 3 4
struct __pthread_mutex_s
{
  int __lock ;
  unsigned int __count;
  int __owner;

  unsigned int __nusers;



  int __kind;
 




  short __spins; short __elision;
  __pthread_list_t __list;
# 145 "/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h" 3 4
 
};




struct __pthread_cond_s
{
  __extension__ union
  {
    __extension__ unsigned long long int __wseq;
    struct
    {
      unsigned int __low;
      unsigned int __high;
    } __wseq32;
  };
  __extension__ union
  {
    __extension__ unsigned long long int __g1_start;
    struct
    {
      unsigned int __low;
      unsigned int __high;
    } __g1_start32;
  };
  unsigned int __g_refs[2] ;
  unsigned int __g_size[2];
  unsigned int __g1_orig_size;
  unsigned int __wrefs;
  unsigned int __g_signals[2];
};
# 24 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 2 3 4



typedef unsigned long int pthread_t;




typedef union
{
  char __size[4];
  int __align;
} pthread_mutexattr_t;




typedef union
{
  char __size[4];
  int __align;
} pthread_condattr_t;



typedef unsigned int pthread_key_t;



typedef int pthread_once_t;


union pthread_attr_t
{
  char __size[56];
  long int __align;
};

typedef union pthread_attr_t pthread_attr_t;




typedef union
{
  struct __pthread_mutex_s __data;
  char __size[40];
  long int __align;
} pthread_mutex_t;


typedef union
{
  struct __pthread_cond_s __data;
  char __size[48];
  __extension__ long long int __align;
} pthread_cond_t;





typedef union
{
  struct __pthread_rwlock_arch_t __data;
  char __size[56];
  long int __align;
} pthread_rwlock_t;

typedef union
{
  char __size[8];
  long int __align;
} pthread_rwlockattr_t;





typedef volatile int pthread_spinlock_t;




typedef union
{
  char __size[32];
  long int __align;
} pthread_barrier_t;

typedef union
{
  char __size[4];
  int __align;
} pthread_barrierattr_t;
# 255 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4



# 395 "/usr/include/stdlib.h" 2 3 4






extern long int random (void) __attribute__ ((__nothrow__ , __leaf__));


extern void srandom (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__));





extern char *initstate (unsigned int __seed, char *__statebuf,
   size_t __statelen) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));



extern char *setstate (char *__statebuf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));







struct random_data
  {
    int32_t *fptr;
    int32_t *rptr;
    int32_t *state;
    int rand_type;
    int rand_deg;
    int rand_sep;
    int32_t *end_ptr;
  };

extern int random_r (struct random_data *__restrict __buf,
       int32_t *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));

extern int srandom_r (unsigned int __seed, struct random_data *__buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));

extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
   size_t __statelen,
   struct random_data *__restrict __buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));

extern int setstate_r (char *__restrict __statebuf,
         struct random_data *__restrict __buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));





extern int rand (void) __attribute__ ((__nothrow__ , __leaf__));

extern void srand (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__));



extern int rand_r (unsigned int *__seed) __attribute__ ((__nothrow__ , __leaf__));







extern double drand48 (void) __attribute__ ((__nothrow__ , __leaf__));
extern double erand48 (unsigned short int __xsubi[3]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern long int lrand48 (void) __attribute__ ((__nothrow__ , __leaf__));
extern long int nrand48 (unsigned short int __xsubi[3])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern long int mrand48 (void) __attribute__ ((__nothrow__ , __leaf__));
extern long int jrand48 (unsigned short int __xsubi[3])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern void srand48 (long int __seedval) __attribute__ ((__nothrow__ , __leaf__));
extern unsigned short int *seed48 (unsigned short int __seed16v[3])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
extern void lcong48 (unsigned short int __param[7]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));





struct drand48_data
  {
    unsigned short int __x[3];
    unsigned short int __old_x[3];
    unsigned short int __c;
    unsigned short int __init;
    __extension__ unsigned long long int __a;

  };


extern int drand48_r (struct drand48_data *__restrict __buffer,
        double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int erand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));


extern int lrand48_r (struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int nrand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));


extern int mrand48_r (struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern int jrand48_r (unsigned short int __xsubi[3],
        struct drand48_data *__restrict __buffer,
        long int *__restrict __result)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));


extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));

extern int seed48_r (unsigned short int __seed16v[3],
       struct drand48_data *__buffer) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));

extern int lcong48_r (unsigned short int __param[7],
        struct drand48_data *__buffer)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));




extern void *malloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;

extern void *calloc (size_t __nmemb, size_t __size)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;






extern void *realloc (void *__ptr, size_t __size)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__));
# 563 "/usr/include/stdlib.h" 3 4
extern void free (void *__ptr) __attribute__ ((__nothrow__ , __leaf__));


# 1 "/usr/include/alloca.h" 1 3 4
# 24 "/usr/include/alloca.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 25 "/usr/include/alloca.h" 2 3 4







extern void *alloca (size_t __size) __attribute__ ((__nothrow__ , __leaf__));






# 567 "/usr/include/stdlib.h" 2 3 4





extern void *valloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;




extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;




extern void *aligned_alloc (size_t __alignment, size_t __size)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (2))) ;



extern void abort (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));



extern int atexit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));







extern int at_quick_exit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));






extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));





extern void exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));





extern void quick_exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));





extern void _Exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__));




extern char *getenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;
# 644 "/usr/include/stdlib.h" 3 4
extern int putenv (char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));





extern int setenv (const char *__name, const char *__value, int __replace)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));


extern int unsetenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));






extern int clearenv (void) __attribute__ ((__nothrow__ , __leaf__));
# 672 "/usr/include/stdlib.h" 3 4
extern char *mktemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
# 685 "/usr/include/stdlib.h" 3 4
extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) ;
# 707 "/usr/include/stdlib.h" 3 4
extern int mkstemps (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) ;
# 728 "/usr/include/stdlib.h" 3 4
extern char *mkdtemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;
# 781 "/usr/include/stdlib.h" 3 4
extern int system (const char *__command) ;
# 797 "/usr/include/stdlib.h" 3 4
extern char *realpath (const char *__restrict __name,
         char *__restrict __resolved) __attribute__ ((__nothrow__ , __leaf__)) ;






typedef int (*__compar_fn_t) (const void *, const void *);
# 817 "/usr/include/stdlib.h" 3 4
extern void *bsearch (const void *__key, const void *__base,
        size_t __nmemb, size_t __size, __compar_fn_t __compar)
     __attribute__ ((__nonnull__ (1, 2, 5))) ;







extern void qsort (void *__base, size_t __nmemb, size_t __size,
     __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));
# 837 "/usr/include/stdlib.h" 3 4
extern int abs (int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;
extern long int labs (long int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;


__extension__ extern long long int llabs (long long int __x)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;






extern div_t div (int __numer, int __denom)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;
extern ldiv_t ldiv (long int __numer, long int __denom)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;


__extension__ extern lldiv_t lldiv (long long int __numer,
        long long int __denom)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ;
# 869 "/usr/include/stdlib.h" 3 4
extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;




extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;




extern char *gcvt (double __value, int __ndigit, char *__buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) ;




extern char *qecvt (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;
extern char *qfcvt (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ;
extern char *qgcvt (long double __value, int __ndigit, char *__buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) ;




extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign, char *__restrict __buf,
     size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));
extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
     int *__restrict __sign, char *__restrict __buf,
     size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));

extern int qecvt_r (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign,
      char *__restrict __buf, size_t __len)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));
extern int qfcvt_r (long double __value, int __ndigit,
      int *__restrict __decpt, int *__restrict __sign,
      char *__restrict __buf, size_t __len)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5)));





extern int mblen (const char *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));


extern int mbtowc (wchar_t *__restrict __pwc,
     const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));


extern int wctomb (char *__s, wchar_t __wchar) __attribute__ ((__nothrow__ , __leaf__));



extern size_t mbstowcs (wchar_t *__restrict __pwcs,
   const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__));

extern size_t wcstombs (char *__restrict __s,
   const wchar_t *__restrict __pwcs, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__));







extern int rpmatch (const char *__response) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;
# 954 "/usr/include/stdlib.h" 3 4
extern int getsubopt (char **__restrict __optionp,
        char *const *__restrict __tokens,
        char **__restrict __valuep)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3))) ;
# 1006 "/usr/include/stdlib.h" 3 4
extern int getloadavg (double __loadavg[], int __nelem)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
# 1016 "/usr/include/stdlib.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/stdlib-float.h" 1 3 4
# 1017 "/usr/include/stdlib.h" 2 3 4
# 1026 "/usr/include/stdlib.h" 3 4

# 22 "types.h" 2


# 23 "types.h"
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;

typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
# 21 "config.h" 2
# 24 "afl-fuzz-single.c" 2

# 1 "debug.h" 1
# 26 "afl-fuzz-single.c" 2
# 1 "alloc-inl.h" 1
# 20 "alloc-inl.h"
# 1 "/usr/include/stdio.h" 1 3 4
# 27 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 1 3 4
# 28 "/usr/include/stdio.h" 2 3 4





# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 34 "/usr/include/stdio.h" 2 3 4


# 1 "/usr/include/x86_64-linux-gnu/bits/types/__FILE.h" 1 3 4




# 4 "/usr/include/x86_64-linux-gnu/bits/types/__FILE.h" 3 4
struct _IO_FILE;
typedef struct _IO_FILE __FILE;
# 37 "/usr/include/stdio.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/types/FILE.h" 1 3 4



struct _IO_FILE;


typedef struct _IO_FILE FILE;
# 38 "/usr/include/stdio.h" 2 3 4



# 1 "/usr/include/x86_64-linux-gnu/bits/libio.h" 1 3 4
# 35 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/_G_config.h" 1 3 4
# 19 "/usr/include/x86_64-linux-gnu/bits/_G_config.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 20 "/usr/include/x86_64-linux-gnu/bits/_G_config.h" 2 3 4

# 1 "/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h" 1 3 4
# 13 "/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h" 3 4
typedef struct
{
  int __count;
  union
  {
    unsigned int __wch;
    char __wchb[4];
  } __value;
} __mbstate_t;
# 22 "/usr/include/x86_64-linux-gnu/bits/_G_config.h" 2 3 4




typedef struct
{
  __off_t __pos;
  __mbstate_t __state;
} _G_fpos_t;
typedef struct
{
  __off64_t __pos;
  __mbstate_t __state;
} _G_fpos64_t;
# 36 "/usr/include/x86_64-linux-gnu/bits/libio.h" 2 3 4
# 53 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h" 1 3 4
# 40 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 54 "/usr/include/x86_64-linux-gnu/bits/libio.h" 2 3 4
# 149 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4
struct _IO_jump_t; struct _IO_FILE;




typedef void _IO_lock_t;





struct _IO_marker {
  struct _IO_marker *_next;
  struct _IO_FILE *_sbuf;



  int _pos;
# 177 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4
};


enum __codecvt_result
{
  __codecvt_ok,
  __codecvt_partial,
  __codecvt_error,
  __codecvt_noconv
};
# 245 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4
struct _IO_FILE {
  int _flags;




  char* _IO_read_ptr;
  char* _IO_read_end;
  char* _IO_read_base;
  char* _IO_write_base;
  char* _IO_write_ptr;
  char* _IO_write_end;
  char* _IO_buf_base;
  char* _IO_buf_end;

  char *_IO_save_base;
  char *_IO_backup_base;
  char *_IO_save_end;

  struct _IO_marker *_markers;

  struct _IO_FILE *_chain;

  int _fileno;



  int _flags2;

  __off_t _old_offset;



  unsigned short _cur_column;
  signed char _vtable_offset;
  char _shortbuf[1];



  _IO_lock_t *_lock;
# 293 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4
  __off64_t _offset;







  void *__pad1;
  void *__pad2;
  void *__pad3;
  void *__pad4;

  size_t __pad5;
  int _mode;

  char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];

};


typedef struct _IO_FILE _IO_FILE;


struct _IO_FILE_plus;

extern struct _IO_FILE_plus _IO_2_1_stdin_;
extern struct _IO_FILE_plus _IO_2_1_stdout_;
extern struct _IO_FILE_plus _IO_2_1_stderr_;
# 337 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4
typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);







typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf,
     size_t __n);







typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);


typedef int __io_close_fn (void *__cookie);
# 389 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4
extern int __underflow (_IO_FILE *);
extern int __uflow (_IO_FILE *);
extern int __overflow (_IO_FILE *, int);
# 433 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4
extern int _IO_getc (_IO_FILE *__fp);
extern int _IO_putc (int __c, _IO_FILE *__fp);
extern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
extern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));

extern int _IO_peekc_locked (_IO_FILE *__fp);





extern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
extern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
extern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
# 462 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4
extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
   __gnuc_va_list, int *__restrict);
extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
    __gnuc_va_list);
extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);

extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);

extern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
# 42 "/usr/include/stdio.h" 2 3 4




typedef __gnuc_va_list va_list;
# 78 "/usr/include/stdio.h" 3 4
typedef _G_fpos_t fpos_t;
# 131 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/stdio_lim.h" 1 3 4
# 132 "/usr/include/stdio.h" 2 3 4



extern struct _IO_FILE *stdin;
extern struct _IO_FILE *stdout;
extern struct _IO_FILE *stderr;






extern int remove (const char *__filename) __attribute__ ((__nothrow__ , __leaf__));

extern int rename (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__));



extern int renameat (int __oldfd, const char *__old, int __newfd,
       const char *__new) __attribute__ ((__nothrow__ , __leaf__));







extern FILE *tmpfile (void) ;
# 173 "/usr/include/stdio.h" 3 4
extern char *tmpnam (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ;




extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ;
# 190 "/usr/include/stdio.h" 3 4
extern char *tempnam (const char *__dir, const char *__pfx)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;







extern int fclose (FILE *__stream);




extern int fflush (FILE *__stream);
# 213 "/usr/include/stdio.h" 3 4
extern int fflush_unlocked (FILE *__stream);
# 232 "/usr/include/stdio.h" 3 4
extern FILE *fopen (const char *__restrict __filename,
      const char *__restrict __modes) ;




extern FILE *freopen (const char *__restrict __filename,
        const char *__restrict __modes,
        FILE *__restrict __stream) ;
# 265 "/usr/include/stdio.h" 3 4
extern FILE *fdopen (int __fd, const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) ;
# 278 "/usr/include/stdio.h" 3 4
extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
  __attribute__ ((__nothrow__ , __leaf__)) ;




extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__ , __leaf__)) ;





extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));



extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
      int __modes, size_t __n) __attribute__ ((__nothrow__ , __leaf__));




extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
         size_t __size) __attribute__ ((__nothrow__ , __leaf__));


extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));







extern int fprintf (FILE *__restrict __stream,
      const char *__restrict __format, ...);




extern int printf (const char *__restrict __format, ...);

extern int sprintf (char *__restrict __s,
      const char *__restrict __format, ...) __attribute__ ((__nothrow__));





extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
       __gnuc_va_list __arg);




extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);

extern int vsprintf (char *__restrict __s, const char *__restrict __format,
       __gnuc_va_list __arg) __attribute__ ((__nothrow__));



extern int snprintf (char *__restrict __s, size_t __maxlen,
       const char *__restrict __format, ...)
     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4)));

extern int vsnprintf (char *__restrict __s, size_t __maxlen,
        const char *__restrict __format, __gnuc_va_list __arg)
     __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0)));
# 365 "/usr/include/stdio.h" 3 4
extern int vdprintf (int __fd, const char *__restrict __fmt,
       __gnuc_va_list __arg)
     __attribute__ ((__format__ (__printf__, 2, 0)));
extern int dprintf (int __fd, const char *__restrict __fmt, ...)
     __attribute__ ((__format__ (__printf__, 2, 3)));







extern int fscanf (FILE *__restrict __stream,
     const char *__restrict __format, ...) ;




extern int scanf (const char *__restrict __format, ...) ;

extern int sscanf (const char *__restrict __s,
     const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__));
# 395 "/usr/include/stdio.h" 3 4
extern int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __asm__ ("" "__isoc99_fscanf")

                               ;
extern int scanf (const char *__restrict __format, ...) __asm__ ("" "__isoc99_scanf")
                              ;
extern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) __asm__ ("" "__isoc99_sscanf") __attribute__ ((__nothrow__ , __leaf__))

                      ;
# 420 "/usr/include/stdio.h" 3 4
extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
      __gnuc_va_list __arg)
     __attribute__ ((__format__ (__scanf__, 2, 0))) ;





extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
     __attribute__ ((__format__ (__scanf__, 1, 0))) ;


extern int vsscanf (const char *__restrict __s,
      const char *__restrict __format, __gnuc_va_list __arg)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__scanf__, 2, 0)));
# 443 "/usr/include/stdio.h" 3 4
extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vfscanf")



     __attribute__ ((__format__ (__scanf__, 2, 0))) ;
extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vscanf")

     __attribute__ ((__format__ (__scanf__, 1, 0))) ;
extern int vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vsscanf") __attribute__ ((__nothrow__ , __leaf__))



     __attribute__ ((__format__ (__scanf__, 2, 0)));
# 477 "/usr/include/stdio.h" 3 4
extern int fgetc (FILE *__stream);
extern int getc (FILE *__stream);





extern int getchar (void);
# 495 "/usr/include/stdio.h" 3 4
extern int getc_unlocked (FILE *__stream);
extern int getchar_unlocked (void);
# 506 "/usr/include/stdio.h" 3 4
extern int fgetc_unlocked (FILE *__stream);
# 517 "/usr/include/stdio.h" 3 4
extern int fputc (int __c, FILE *__stream);
extern int putc (int __c, FILE *__stream);





extern int putchar (int __c);
# 537 "/usr/include/stdio.h" 3 4
extern int fputc_unlocked (int __c, FILE *__stream);







extern int putc_unlocked (int __c, FILE *__stream);
extern int putchar_unlocked (int __c);






extern int getw (FILE *__stream);


extern int putw (int __w, FILE *__stream);







extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
     ;
# 603 "/usr/include/stdio.h" 3 4
extern __ssize_t __getdelim (char **__restrict __lineptr,
          size_t *__restrict __n, int __delimiter,
          FILE *__restrict __stream) ;
extern __ssize_t getdelim (char **__restrict __lineptr,
        size_t *__restrict __n, int __delimiter,
        FILE *__restrict __stream) ;







extern __ssize_t getline (char **__restrict __lineptr,
       size_t *__restrict __n,
       FILE *__restrict __stream) ;







extern int fputs (const char *__restrict __s, FILE *__restrict __stream);





extern int puts (const char *__s);






extern int ungetc (int __c, FILE *__stream);






extern size_t fread (void *__restrict __ptr, size_t __size,
       size_t __n, FILE *__restrict __stream) ;




extern size_t fwrite (const void *__restrict __ptr, size_t __size,
        size_t __n, FILE *__restrict __s);
# 673 "/usr/include/stdio.h" 3 4
extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
         size_t __n, FILE *__restrict __stream) ;
extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
          size_t __n, FILE *__restrict __stream);







extern int fseek (FILE *__stream, long int __off, int __whence);




extern long int ftell (FILE *__stream) ;




extern void rewind (FILE *__stream);
# 707 "/usr/include/stdio.h" 3 4
extern int fseeko (FILE *__stream, __off_t __off, int __whence);




extern __off_t ftello (FILE *__stream) ;
# 731 "/usr/include/stdio.h" 3 4
extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);




extern int fsetpos (FILE *__stream, const fpos_t *__pos);
# 757 "/usr/include/stdio.h" 3 4
extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));

extern int feof (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;

extern int ferror (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;



extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;







extern void perror (const char *__s);





# 1 "/usr/include/x86_64-linux-gnu/bits/sys_errlist.h" 1 3 4
# 26 "/usr/include/x86_64-linux-gnu/bits/sys_errlist.h" 3 4
extern int sys_nerr;
extern const char *const sys_errlist[];
# 782 "/usr/include/stdio.h" 2 3 4




extern int fileno (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;




extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
# 800 "/usr/include/stdio.h" 3 4
extern FILE *popen (const char *__command, const char *__modes) ;





extern int pclose (FILE *__stream);





extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__));
# 840 "/usr/include/stdio.h" 3 4
extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));



extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;


extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
# 868 "/usr/include/stdio.h" 3 4

# 21 "alloc-inl.h" 2

# 1 "/usr/include/string.h" 1 3 4
# 26 "/usr/include/string.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 1 3 4
# 27 "/usr/include/string.h" 2 3 4






# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 34 "/usr/include/string.h" 2 3 4
# 42 "/usr/include/string.h" 3 4
extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
       size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));


extern void *memmove (void *__dest, const void *__src, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));





extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
        int __c, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));




extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern int memcmp (const void *__s1, const void *__s2, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
# 90 "/usr/include/string.h" 3 4
extern void *memchr (const void *__s, int __c, size_t __n)
      __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
# 121 "/usr/include/string.h" 3 4
extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));

extern char *strncpy (char *__restrict __dest,
        const char *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));


extern char *strcat (char *__restrict __dest, const char *__restrict __src)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));

extern char *strncat (char *__restrict __dest, const char *__restrict __src,
        size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));


extern int strcmp (const char *__s1, const char *__s2)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));

extern int strncmp (const char *__s1, const char *__s2, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));


extern int strcoll (const char *__s1, const char *__s2)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));

extern size_t strxfrm (char *__restrict __dest,
         const char *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));



# 1 "/usr/include/x86_64-linux-gnu/bits/types/locale_t.h" 1 3 4
# 22 "/usr/include/x86_64-linux-gnu/bits/types/locale_t.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h" 1 3 4
# 28 "/usr/include/x86_64-linux-gnu/bits/types/__locale_t.h" 3 4
struct __locale_struct
{

  struct __locale_data *__locales[13];


  const unsigned short int *__ctype_b;
  const int *__ctype_tolower;
  const int *__ctype_toupper;


  const char *__names[13];
};

typedef struct __locale_struct *__locale_t;
# 23 "/usr/include/x86_64-linux-gnu/bits/types/locale_t.h" 2 3 4

typedef __locale_t locale_t;
# 153 "/usr/include/string.h" 2 3 4


extern int strcoll_l (const char *__s1, const char *__s2, locale_t __l)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));


extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
    locale_t __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));





extern char *strdup (const char *__s)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));






extern char *strndup (const char *__string, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
# 225 "/usr/include/string.h" 3 4
extern char *strchr (const char *__s, int __c)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
# 252 "/usr/include/string.h" 3 4
extern char *strrchr (const char *__s, int __c)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
# 272 "/usr/include/string.h" 3 4
extern size_t strcspn (const char *__s, const char *__reject)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));


extern size_t strspn (const char *__s, const char *__accept)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
# 302 "/usr/include/string.h" 3 4
extern char *strpbrk (const char *__s, const char *__accept)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
# 329 "/usr/include/string.h" 3 4
extern char *strstr (const char *__haystack, const char *__needle)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));




extern char *strtok (char *__restrict __s, const char *__restrict __delim)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));



extern char *__strtok_r (char *__restrict __s,
    const char *__restrict __delim,
    char **__restrict __save_ptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));

extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
         char **__restrict __save_ptr)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
# 384 "/usr/include/string.h" 3 4
extern size_t strlen (const char *__s)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));




extern size_t strnlen (const char *__string, size_t __maxlen)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));




extern char *strerror (int __errnum) __attribute__ ((__nothrow__ , __leaf__));
# 409 "/usr/include/string.h" 3 4
extern int strerror_r (int __errnum, char *__buf, size_t __buflen) __asm__ ("" "__xpg_strerror_r") __attribute__ ((__nothrow__ , __leaf__))

                        __attribute__ ((__nonnull__ (2)));
# 427 "/usr/include/string.h" 3 4
extern char *strerror_l (int __errnum, locale_t __l) __attribute__ ((__nothrow__ , __leaf__));



# 1 "/usr/include/strings.h" 1 3 4
# 23 "/usr/include/strings.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 24 "/usr/include/strings.h" 2 3 4










extern int bcmp (const void *__s1, const void *__s2, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));


extern void bcopy (const void *__src, void *__dest, size_t __n)
  __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));


extern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
# 68 "/usr/include/strings.h" 3 4
extern char *index (const char *__s, int __c)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
# 96 "/usr/include/strings.h" 3 4
extern char *rindex (const char *__s, int __c)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));






extern int ffs (int __i) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));





extern int ffsl (long int __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
__extension__ extern int ffsll (long long int __ll)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));



extern int strcasecmp (const char *__s1, const char *__s2)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));


extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));






extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));



extern int strncasecmp_l (const char *__s1, const char *__s2,
     size_t __n, locale_t __loc)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4)));



# 432 "/usr/include/string.h" 2 3 4



extern void explicit_bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));



extern char *strsep (char **__restrict __stringp,
       const char *__restrict __delim)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));




extern char *strsignal (int __sig) __attribute__ ((__nothrow__ , __leaf__));


extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));



extern char *__stpncpy (char *__restrict __dest,
   const char *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
extern char *stpncpy (char *__restrict __dest,
        const char *__restrict __src, size_t __n)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
# 498 "/usr/include/string.h" 3 4

# 23 "alloc-inl.h" 2
# 64 "alloc-inl.h"

# 64 "alloc-inl.h"
static inline void* DFL_ck_alloc(u32 size) {
  void* ret;

  if (!size) return 
# 67 "alloc-inl.h" 3 4
                   ((void *)0)
# 67 "alloc-inl.h"
                       ;

  do { if ((size) > 0x40000000) do { fprintf(
# 69 "alloc-inl.h" 3 4
 stderr
# 69 "alloc-inl.h"
 , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad alloc request: %u bytes", (size)); fprintf(
# 69 "alloc-inl.h" 3 4
 stderr
# 69 "alloc-inl.h"
 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 69); abort(); } while (0); } while (0);
  ret = malloc(size + 6);
  do { if (!(ret)) do { fprintf(
# 71 "alloc-inl.h" 3 4
 stderr
# 71 "alloc-inl.h"
 , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Out of memory: can't allocate %u bytes", (size)); fprintf(
# 71 "alloc-inl.h" 3 4
 stderr
# 71 "alloc-inl.h"
 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 71); abort(); } while (0); } while (0);

  ret += 6;

  (((u16*)(ret))[-3]) = 0xFF00;
  (((u32*)(ret))[-1]) = size;

  return memset(ret, 0, size);
}


static inline void* DFL_ck_realloc(void* orig, u32 size) {
  void* ret;
  u32 old_size = 0;

  if (!size) {

    if (orig) {

      do { if ((orig) && (((u16*)(orig))[-3]) != 0xFF00) { if ((((u16*)(orig))[-3]) == 0xFE00) do { fprintf(
# 90 "alloc-inl.h" 3 4
     stderr
# 90 "alloc-inl.h"
     , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Use after free."); fprintf(
# 90 "alloc-inl.h" 3 4
     stderr
# 90 "alloc-inl.h"
     , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 90); abort(); } while (0); else do { fprintf(
# 90 "alloc-inl.h" 3 4
     stderr
# 90 "alloc-inl.h"
     , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad alloc canary."); fprintf(
# 90 "alloc-inl.h" 3 4
     stderr
# 90 "alloc-inl.h"
     , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 90); abort(); } while (0); } } while (0);







      free(orig - 6);

    }

    return 
# 102 "alloc-inl.h" 3 4
          ((void *)0)
# 102 "alloc-inl.h"
              ;

  }

  if (orig) {

    do { if ((orig) && (((u16*)(orig))[-3]) != 0xFF00) { if ((((u16*)(orig))[-3]) == 0xFE00) do { fprintf(
# 108 "alloc-inl.h" 3 4
   stderr
# 108 "alloc-inl.h"
   , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Use after free."); fprintf(
# 108 "alloc-inl.h" 3 4
   stderr
# 108 "alloc-inl.h"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 108); abort(); } while (0); else do { fprintf(
# 108 "alloc-inl.h" 3 4
   stderr
# 108 "alloc-inl.h"
   , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad alloc canary."); fprintf(
# 108 "alloc-inl.h" 3 4
   stderr
# 108 "alloc-inl.h"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 108); abort(); } while (0); } } while (0);


    (((u16*)(orig))[-3]) = 0xFE00;


    old_size = (((u32*)(orig))[-1]);
    orig -= 6;

    do { if ((old_size) > 0x40000000) do { fprintf(
# 117 "alloc-inl.h" 3 4
   stderr
# 117 "alloc-inl.h"
   , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad alloc request: %u bytes", (old_size)); fprintf(
# 117 "alloc-inl.h" 3 4
   stderr
# 117 "alloc-inl.h"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 117); abort(); } while (0); } while (0);

  }

  do { if ((size) > 0x40000000) do { fprintf(
# 121 "alloc-inl.h" 3 4
 stderr
# 121 "alloc-inl.h"
 , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad alloc request: %u bytes", (size)); fprintf(
# 121 "alloc-inl.h" 3 4
 stderr
# 121 "alloc-inl.h"
 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 121); abort(); } while (0); } while (0);



  ret = realloc(orig, size + 6);
  do { if (!(ret)) do { fprintf(
# 126 "alloc-inl.h" 3 4
 stderr
# 126 "alloc-inl.h"
 , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Out of memory: can't allocate %u bytes", (size)); fprintf(
# 126 "alloc-inl.h" 3 4
 stderr
# 126 "alloc-inl.h"
 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 126); abort(); } while (0); } while (0);
# 149 "alloc-inl.h"
  ret += 6;

  (((u16*)(ret))[-3]) = 0xFF00;
  (((u32*)(ret))[-1]) = size;

  if (size > old_size)
    memset(ret + old_size, 0, size - old_size);

  return ret;
}


static inline void* DFL_ck_realloc_chunk(void* orig, u32 size) {



  if (orig) {

    do { if ((orig) && (((u16*)(orig))[-3]) != 0xFF00) { if ((((u16*)(orig))[-3]) == 0xFE00) do { fprintf(
# 167 "alloc-inl.h" 3 4
   stderr
# 167 "alloc-inl.h"
   , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Use after free."); fprintf(
# 167 "alloc-inl.h" 3 4
   stderr
# 167 "alloc-inl.h"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 167); abort(); } while (0); else do { fprintf(
# 167 "alloc-inl.h" 3 4
   stderr
# 167 "alloc-inl.h"
   , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad alloc canary."); fprintf(
# 167 "alloc-inl.h" 3 4
   stderr
# 167 "alloc-inl.h"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 167); abort(); } while (0); } } while (0);

    if ((((u32*)(orig))[-1]) >= size) return orig;

    size += 256;

  }



  return DFL_ck_realloc(orig, size);
}


static inline u8* DFL_ck_strdup(u8* str) {
  void* ret;
  u32 size;

  if (!str) return 
# 185 "alloc-inl.h" 3 4
                  ((void *)0)
# 185 "alloc-inl.h"
                      ;

  size = strlen((char*)str) + 1;

  do { if ((size) > 0x40000000) do { fprintf(
# 189 "alloc-inl.h" 3 4
 stderr
# 189 "alloc-inl.h"
 , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad alloc request: %u bytes", (size)); fprintf(
# 189 "alloc-inl.h" 3 4
 stderr
# 189 "alloc-inl.h"
 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 189); abort(); } while (0); } while (0);
  ret = malloc(size + 6);
  do { if (!(ret)) do { fprintf(
# 191 "alloc-inl.h" 3 4
 stderr
# 191 "alloc-inl.h"
 , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Out of memory: can't allocate %u bytes", (size)); fprintf(
# 191 "alloc-inl.h" 3 4
 stderr
# 191 "alloc-inl.h"
 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 191); abort(); } while (0); } while (0);

  ret += 6;

  (((u16*)(ret))[-3]) = 0xFF00;
  (((u32*)(ret))[-1]) = size;

  return memcpy(ret, str, size);
}


static inline void* DFL_ck_memdup(void* mem, u32 size) {
  void* ret;

  if (!mem || !size) return 
# 205 "alloc-inl.h" 3 4
                           ((void *)0)
# 205 "alloc-inl.h"
                               ;

  do { if ((size) > 0x40000000) do { fprintf(
# 207 "alloc-inl.h" 3 4
 stderr
# 207 "alloc-inl.h"
 , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad alloc request: %u bytes", (size)); fprintf(
# 207 "alloc-inl.h" 3 4
 stderr
# 207 "alloc-inl.h"
 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 207); abort(); } while (0); } while (0);
  ret = malloc(size + 6);
  do { if (!(ret)) do { fprintf(
# 209 "alloc-inl.h" 3 4
 stderr
# 209 "alloc-inl.h"
 , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Out of memory: can't allocate %u bytes", (size)); fprintf(
# 209 "alloc-inl.h" 3 4
 stderr
# 209 "alloc-inl.h"
 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 209); abort(); } while (0); } while (0);

  ret += 6;

  (((u16*)(ret))[-3]) = 0xFF00;
  (((u32*)(ret))[-1]) = size;

  return memcpy(ret, mem, size);
}


static inline u8* DFL_ck_memdup_str(u8* mem, u32 size) {
  u8* ret;

  if (!mem || !size) return 
# 223 "alloc-inl.h" 3 4
                           ((void *)0)
# 223 "alloc-inl.h"
                               ;

  do { if ((size) > 0x40000000) do { fprintf(
# 225 "alloc-inl.h" 3 4
 stderr
# 225 "alloc-inl.h"
 , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad alloc request: %u bytes", (size)); fprintf(
# 225 "alloc-inl.h" 3 4
 stderr
# 225 "alloc-inl.h"
 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 225); abort(); } while (0); } while (0);
  ret = malloc(size + 6 + 1);
  do { if (!(ret)) do { fprintf(
# 227 "alloc-inl.h" 3 4
 stderr
# 227 "alloc-inl.h"
 , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Out of memory: can't allocate %u bytes", (size)); fprintf(
# 227 "alloc-inl.h" 3 4
 stderr
# 227 "alloc-inl.h"
 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 227); abort(); } while (0); } while (0);

  ret += 6;

  (((u16*)(ret))[-3]) = 0xFF00;
  (((u32*)(ret))[-1]) = size;

  memcpy(ret, mem, size);
  ret[size] = 0;

  return ret;
}


static inline void DFL_ck_free(void* mem) {

  if (mem) {

    do { if ((mem) && (((u16*)(mem))[-3]) != 0xFF00) { if ((((u16*)(mem))[-3]) == 0xFE00) do { fprintf(
# 245 "alloc-inl.h" 3 4
   stderr
# 245 "alloc-inl.h"
   , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Use after free."); fprintf(
# 245 "alloc-inl.h" 3 4
   stderr
# 245 "alloc-inl.h"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 245); abort(); } while (0); else do { fprintf(
# 245 "alloc-inl.h" 3 4
   stderr
# 245 "alloc-inl.h"
   , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad alloc canary."); fprintf(
# 245 "alloc-inl.h" 3 4
   stderr
# 245 "alloc-inl.h"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "alloc-inl.h", 245); abort(); } while (0); } } while (0);
# 254 "alloc-inl.h"
    (((u16*)(mem))[-3]) = 0xFE00;

    free(mem - 6);

  }

}
# 27 "afl-fuzz-single.c" 2


# 1 "/usr/include/unistd.h" 1 3 4
# 27 "/usr/include/unistd.h" 3 4

# 205 "/usr/include/unistd.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/posix_opt.h" 1 3 4
# 206 "/usr/include/unistd.h" 2 3 4



# 1 "/usr/include/x86_64-linux-gnu/bits/environments.h" 1 3 4
# 22 "/usr/include/x86_64-linux-gnu/bits/environments.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
# 23 "/usr/include/x86_64-linux-gnu/bits/environments.h" 2 3 4
# 210 "/usr/include/unistd.h" 2 3 4
# 229 "/usr/include/unistd.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 230 "/usr/include/unistd.h" 2 3 4
# 258 "/usr/include/unistd.h" 3 4

# 258 "/usr/include/unistd.h" 3 4
typedef __useconds_t useconds_t;
# 277 "/usr/include/unistd.h" 3 4
typedef __socklen_t socklen_t;
# 290 "/usr/include/unistd.h" 3 4
extern int access (const char *__name, int __type) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
# 307 "/usr/include/unistd.h" 3 4
extern int faccessat (int __fd, const char *__file, int __type, int __flag)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) ;
# 337 "/usr/include/unistd.h" 3 4
extern __off_t lseek (int __fd, __off_t __offset, int __whence) __attribute__ ((__nothrow__ , __leaf__));
# 356 "/usr/include/unistd.h" 3 4
extern int close (int __fd);






extern ssize_t read (int __fd, void *__buf, size_t __nbytes) ;





extern ssize_t write (int __fd, const void *__buf, size_t __n) ;
# 379 "/usr/include/unistd.h" 3 4
extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
        __off_t __offset) ;






extern ssize_t pwrite (int __fd, const void *__buf, size_t __n,
         __off_t __offset) ;
# 420 "/usr/include/unistd.h" 3 4
extern int pipe (int __pipedes[2]) __attribute__ ((__nothrow__ , __leaf__)) ;
# 435 "/usr/include/unistd.h" 3 4
extern unsigned int alarm (unsigned int __seconds) __attribute__ ((__nothrow__ , __leaf__));
# 447 "/usr/include/unistd.h" 3 4
extern unsigned int sleep (unsigned int __seconds);







extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval)
     __attribute__ ((__nothrow__ , __leaf__));






extern int usleep (__useconds_t __useconds);
# 472 "/usr/include/unistd.h" 3 4
extern int pause (void);



extern int chown (const char *__file, __uid_t __owner, __gid_t __group)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;



extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __attribute__ ((__nothrow__ , __leaf__)) ;




extern int lchown (const char *__file, __uid_t __owner, __gid_t __group)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;






extern int fchownat (int __fd, const char *__file, __uid_t __owner,
       __gid_t __group, int __flag)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) ;



extern int chdir (const char *__path) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;



extern int fchdir (int __fd) __attribute__ ((__nothrow__ , __leaf__)) ;
# 514 "/usr/include/unistd.h" 3 4
extern char *getcwd (char *__buf, size_t __size) __attribute__ ((__nothrow__ , __leaf__)) ;
# 528 "/usr/include/unistd.h" 3 4
extern char *getwd (char *__buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__)) ;




extern int dup (int __fd) __attribute__ ((__nothrow__ , __leaf__)) ;


extern int dup2 (int __fd, int __fd2) __attribute__ ((__nothrow__ , __leaf__));
# 546 "/usr/include/unistd.h" 3 4
extern char **__environ;







extern int execve (const char *__path, char *const __argv[],
     char *const __envp[]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));




extern int fexecve (int __fd, char *const __argv[], char *const __envp[])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));




extern int execv (const char *__path, char *const __argv[])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));



extern int execle (const char *__path, const char *__arg, ...)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));



extern int execl (const char *__path, const char *__arg, ...)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));



extern int execvp (const char *__file, char *const __argv[])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));




extern int execlp (const char *__file, const char *__arg, ...)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
# 601 "/usr/include/unistd.h" 3 4
extern int nice (int __inc) __attribute__ ((__nothrow__ , __leaf__)) ;




extern void _exit (int __status) __attribute__ ((__noreturn__));





# 1 "/usr/include/x86_64-linux-gnu/bits/confname.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/bits/confname.h" 3 4
enum
  {
    _PC_LINK_MAX,

    _PC_MAX_CANON,

    _PC_MAX_INPUT,

    _PC_NAME_MAX,

    _PC_PATH_MAX,

    _PC_PIPE_BUF,

    _PC_CHOWN_RESTRICTED,

    _PC_NO_TRUNC,

    _PC_VDISABLE,

    _PC_SYNC_IO,

    _PC_ASYNC_IO,

    _PC_PRIO_IO,

    _PC_SOCK_MAXBUF,

    _PC_FILESIZEBITS,

    _PC_REC_INCR_XFER_SIZE,

    _PC_REC_MAX_XFER_SIZE,

    _PC_REC_MIN_XFER_SIZE,

    _PC_REC_XFER_ALIGN,

    _PC_ALLOC_SIZE_MIN,

    _PC_SYMLINK_MAX,

    _PC_2_SYMLINKS

  };


enum
  {
    _SC_ARG_MAX,

    _SC_CHILD_MAX,

    _SC_CLK_TCK,

    _SC_NGROUPS_MAX,

    _SC_OPEN_MAX,

    _SC_STREAM_MAX,

    _SC_TZNAME_MAX,

    _SC_JOB_CONTROL,

    _SC_SAVED_IDS,

    _SC_REALTIME_SIGNALS,

    _SC_PRIORITY_SCHEDULING,

    _SC_TIMERS,

    _SC_ASYNCHRONOUS_IO,

    _SC_PRIORITIZED_IO,

    _SC_SYNCHRONIZED_IO,

    _SC_FSYNC,

    _SC_MAPPED_FILES,

    _SC_MEMLOCK,

    _SC_MEMLOCK_RANGE,

    _SC_MEMORY_PROTECTION,

    _SC_MESSAGE_PASSING,

    _SC_SEMAPHORES,

    _SC_SHARED_MEMORY_OBJECTS,

    _SC_AIO_LISTIO_MAX,

    _SC_AIO_MAX,

    _SC_AIO_PRIO_DELTA_MAX,

    _SC_DELAYTIMER_MAX,

    _SC_MQ_OPEN_MAX,

    _SC_MQ_PRIO_MAX,

    _SC_VERSION,

    _SC_PAGESIZE,


    _SC_RTSIG_MAX,

    _SC_SEM_NSEMS_MAX,

    _SC_SEM_VALUE_MAX,

    _SC_SIGQUEUE_MAX,

    _SC_TIMER_MAX,




    _SC_BC_BASE_MAX,

    _SC_BC_DIM_MAX,

    _SC_BC_SCALE_MAX,

    _SC_BC_STRING_MAX,

    _SC_COLL_WEIGHTS_MAX,

    _SC_EQUIV_CLASS_MAX,

    _SC_EXPR_NEST_MAX,

    _SC_LINE_MAX,

    _SC_RE_DUP_MAX,

    _SC_CHARCLASS_NAME_MAX,


    _SC_2_VERSION,

    _SC_2_C_BIND,

    _SC_2_C_DEV,

    _SC_2_FORT_DEV,

    _SC_2_FORT_RUN,

    _SC_2_SW_DEV,

    _SC_2_LOCALEDEF,


    _SC_PII,

    _SC_PII_XTI,

    _SC_PII_SOCKET,

    _SC_PII_INTERNET,

    _SC_PII_OSI,

    _SC_POLL,

    _SC_SELECT,

    _SC_UIO_MAXIOV,

    _SC_IOV_MAX = _SC_UIO_MAXIOV,

    _SC_PII_INTERNET_STREAM,

    _SC_PII_INTERNET_DGRAM,

    _SC_PII_OSI_COTS,

    _SC_PII_OSI_CLTS,

    _SC_PII_OSI_M,

    _SC_T_IOV_MAX,



    _SC_THREADS,

    _SC_THREAD_SAFE_FUNCTIONS,

    _SC_GETGR_R_SIZE_MAX,

    _SC_GETPW_R_SIZE_MAX,

    _SC_LOGIN_NAME_MAX,

    _SC_TTY_NAME_MAX,

    _SC_THREAD_DESTRUCTOR_ITERATIONS,

    _SC_THREAD_KEYS_MAX,

    _SC_THREAD_STACK_MIN,

    _SC_THREAD_THREADS_MAX,

    _SC_THREAD_ATTR_STACKADDR,

    _SC_THREAD_ATTR_STACKSIZE,

    _SC_THREAD_PRIORITY_SCHEDULING,

    _SC_THREAD_PRIO_INHERIT,

    _SC_THREAD_PRIO_PROTECT,

    _SC_THREAD_PROCESS_SHARED,


    _SC_NPROCESSORS_CONF,

    _SC_NPROCESSORS_ONLN,

    _SC_PHYS_PAGES,

    _SC_AVPHYS_PAGES,

    _SC_ATEXIT_MAX,

    _SC_PASS_MAX,


    _SC_XOPEN_VERSION,

    _SC_XOPEN_XCU_VERSION,

    _SC_XOPEN_UNIX,

    _SC_XOPEN_CRYPT,

    _SC_XOPEN_ENH_I18N,

    _SC_XOPEN_SHM,


    _SC_2_CHAR_TERM,

    _SC_2_C_VERSION,

    _SC_2_UPE,


    _SC_XOPEN_XPG2,

    _SC_XOPEN_XPG3,

    _SC_XOPEN_XPG4,


    _SC_CHAR_BIT,

    _SC_CHAR_MAX,

    _SC_CHAR_MIN,

    _SC_INT_MAX,

    _SC_INT_MIN,

    _SC_LONG_BIT,

    _SC_WORD_BIT,

    _SC_MB_LEN_MAX,

    _SC_NZERO,

    _SC_SSIZE_MAX,

    _SC_SCHAR_MAX,

    _SC_SCHAR_MIN,

    _SC_SHRT_MAX,

    _SC_SHRT_MIN,

    _SC_UCHAR_MAX,

    _SC_UINT_MAX,

    _SC_ULONG_MAX,

    _SC_USHRT_MAX,


    _SC_NL_ARGMAX,

    _SC_NL_LANGMAX,

    _SC_NL_MSGMAX,

    _SC_NL_NMAX,

    _SC_NL_SETMAX,

    _SC_NL_TEXTMAX,


    _SC_XBS5_ILP32_OFF32,

    _SC_XBS5_ILP32_OFFBIG,

    _SC_XBS5_LP64_OFF64,

    _SC_XBS5_LPBIG_OFFBIG,


    _SC_XOPEN_LEGACY,

    _SC_XOPEN_REALTIME,

    _SC_XOPEN_REALTIME_THREADS,


    _SC_ADVISORY_INFO,

    _SC_BARRIERS,

    _SC_BASE,

    _SC_C_LANG_SUPPORT,

    _SC_C_LANG_SUPPORT_R,

    _SC_CLOCK_SELECTION,

    _SC_CPUTIME,

    _SC_THREAD_CPUTIME,

    _SC_DEVICE_IO,

    _SC_DEVICE_SPECIFIC,

    _SC_DEVICE_SPECIFIC_R,

    _SC_FD_MGMT,

    _SC_FIFO,

    _SC_PIPE,

    _SC_FILE_ATTRIBUTES,

    _SC_FILE_LOCKING,

    _SC_FILE_SYSTEM,

    _SC_MONOTONIC_CLOCK,

    _SC_MULTI_PROCESS,

    _SC_SINGLE_PROCESS,

    _SC_NETWORKING,

    _SC_READER_WRITER_LOCKS,

    _SC_SPIN_LOCKS,

    _SC_REGEXP,

    _SC_REGEX_VERSION,

    _SC_SHELL,

    _SC_SIGNALS,

    _SC_SPAWN,

    _SC_SPORADIC_SERVER,

    _SC_THREAD_SPORADIC_SERVER,

    _SC_SYSTEM_DATABASE,

    _SC_SYSTEM_DATABASE_R,

    _SC_TIMEOUTS,

    _SC_TYPED_MEMORY_OBJECTS,

    _SC_USER_GROUPS,

    _SC_USER_GROUPS_R,

    _SC_2_PBS,

    _SC_2_PBS_ACCOUNTING,

    _SC_2_PBS_LOCATE,

    _SC_2_PBS_MESSAGE,

    _SC_2_PBS_TRACK,

    _SC_SYMLOOP_MAX,

    _SC_STREAMS,

    _SC_2_PBS_CHECKPOINT,


    _SC_V6_ILP32_OFF32,

    _SC_V6_ILP32_OFFBIG,

    _SC_V6_LP64_OFF64,

    _SC_V6_LPBIG_OFFBIG,


    _SC_HOST_NAME_MAX,

    _SC_TRACE,

    _SC_TRACE_EVENT_FILTER,

    _SC_TRACE_INHERIT,

    _SC_TRACE_LOG,


    _SC_LEVEL1_ICACHE_SIZE,

    _SC_LEVEL1_ICACHE_ASSOC,

    _SC_LEVEL1_ICACHE_LINESIZE,

    _SC_LEVEL1_DCACHE_SIZE,

    _SC_LEVEL1_DCACHE_ASSOC,

    _SC_LEVEL1_DCACHE_LINESIZE,

    _SC_LEVEL2_CACHE_SIZE,

    _SC_LEVEL2_CACHE_ASSOC,

    _SC_LEVEL2_CACHE_LINESIZE,

    _SC_LEVEL3_CACHE_SIZE,

    _SC_LEVEL3_CACHE_ASSOC,

    _SC_LEVEL3_CACHE_LINESIZE,

    _SC_LEVEL4_CACHE_SIZE,

    _SC_LEVEL4_CACHE_ASSOC,

    _SC_LEVEL4_CACHE_LINESIZE,



    _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,

    _SC_RAW_SOCKETS,


    _SC_V7_ILP32_OFF32,

    _SC_V7_ILP32_OFFBIG,

    _SC_V7_LP64_OFF64,

    _SC_V7_LPBIG_OFFBIG,


    _SC_SS_REPL_MAX,


    _SC_TRACE_EVENT_NAME_MAX,

    _SC_TRACE_NAME_MAX,

    _SC_TRACE_SYS_MAX,

    _SC_TRACE_USER_EVENT_MAX,


    _SC_XOPEN_STREAMS,


    _SC_THREAD_ROBUST_PRIO_INHERIT,

    _SC_THREAD_ROBUST_PRIO_PROTECT

  };


enum
  {
    _CS_PATH,


    _CS_V6_WIDTH_RESTRICTED_ENVS,



    _CS_GNU_LIBC_VERSION,

    _CS_GNU_LIBPTHREAD_VERSION,


    _CS_V5_WIDTH_RESTRICTED_ENVS,



    _CS_V7_WIDTH_RESTRICTED_ENVS,



    _CS_LFS_CFLAGS = 1000,

    _CS_LFS_LDFLAGS,

    _CS_LFS_LIBS,

    _CS_LFS_LINTFLAGS,

    _CS_LFS64_CFLAGS,

    _CS_LFS64_LDFLAGS,

    _CS_LFS64_LIBS,

    _CS_LFS64_LINTFLAGS,


    _CS_XBS5_ILP32_OFF32_CFLAGS = 1100,

    _CS_XBS5_ILP32_OFF32_LDFLAGS,

    _CS_XBS5_ILP32_OFF32_LIBS,

    _CS_XBS5_ILP32_OFF32_LINTFLAGS,

    _CS_XBS5_ILP32_OFFBIG_CFLAGS,

    _CS_XBS5_ILP32_OFFBIG_LDFLAGS,

    _CS_XBS5_ILP32_OFFBIG_LIBS,

    _CS_XBS5_ILP32_OFFBIG_LINTFLAGS,

    _CS_XBS5_LP64_OFF64_CFLAGS,

    _CS_XBS5_LP64_OFF64_LDFLAGS,

    _CS_XBS5_LP64_OFF64_LIBS,

    _CS_XBS5_LP64_OFF64_LINTFLAGS,

    _CS_XBS5_LPBIG_OFFBIG_CFLAGS,

    _CS_XBS5_LPBIG_OFFBIG_LDFLAGS,

    _CS_XBS5_LPBIG_OFFBIG_LIBS,

    _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,


    _CS_POSIX_V6_ILP32_OFF32_CFLAGS,

    _CS_POSIX_V6_ILP32_OFF32_LDFLAGS,

    _CS_POSIX_V6_ILP32_OFF32_LIBS,

    _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,

    _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,

    _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,

    _CS_POSIX_V6_ILP32_OFFBIG_LIBS,

    _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,

    _CS_POSIX_V6_LP64_OFF64_CFLAGS,

    _CS_POSIX_V6_LP64_OFF64_LDFLAGS,

    _CS_POSIX_V6_LP64_OFF64_LIBS,

    _CS_POSIX_V6_LP64_OFF64_LINTFLAGS,

    _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,

    _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,

    _CS_POSIX_V6_LPBIG_OFFBIG_LIBS,

    _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,


    _CS_POSIX_V7_ILP32_OFF32_CFLAGS,

    _CS_POSIX_V7_ILP32_OFF32_LDFLAGS,

    _CS_POSIX_V7_ILP32_OFF32_LIBS,

    _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS,

    _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS,

    _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS,

    _CS_POSIX_V7_ILP32_OFFBIG_LIBS,

    _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS,

    _CS_POSIX_V7_LP64_OFF64_CFLAGS,

    _CS_POSIX_V7_LP64_OFF64_LDFLAGS,

    _CS_POSIX_V7_LP64_OFF64_LIBS,

    _CS_POSIX_V7_LP64_OFF64_LINTFLAGS,

    _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS,

    _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS,

    _CS_POSIX_V7_LPBIG_OFFBIG_LIBS,

    _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS,


    _CS_V6_ENV,

    _CS_V7_ENV

  };
# 613 "/usr/include/unistd.h" 2 3 4


extern long int pathconf (const char *__path, int __name)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern long int fpathconf (int __fd, int __name) __attribute__ ((__nothrow__ , __leaf__));


extern long int sysconf (int __name) __attribute__ ((__nothrow__ , __leaf__));



extern size_t confstr (int __name, char *__buf, size_t __len) __attribute__ ((__nothrow__ , __leaf__));




extern __pid_t getpid (void) __attribute__ ((__nothrow__ , __leaf__));


extern __pid_t getppid (void) __attribute__ ((__nothrow__ , __leaf__));


extern __pid_t getpgrp (void) __attribute__ ((__nothrow__ , __leaf__));


extern __pid_t __getpgid (__pid_t __pid) __attribute__ ((__nothrow__ , __leaf__));

extern __pid_t getpgid (__pid_t __pid) __attribute__ ((__nothrow__ , __leaf__));






extern int setpgid (__pid_t __pid, __pid_t __pgid) __attribute__ ((__nothrow__ , __leaf__));
# 663 "/usr/include/unistd.h" 3 4
extern int setpgrp (void) __attribute__ ((__nothrow__ , __leaf__));






extern __pid_t setsid (void) __attribute__ ((__nothrow__ , __leaf__));



extern __pid_t getsid (__pid_t __pid) __attribute__ ((__nothrow__ , __leaf__));



extern __uid_t getuid (void) __attribute__ ((__nothrow__ , __leaf__));


extern __uid_t geteuid (void) __attribute__ ((__nothrow__ , __leaf__));


extern __gid_t getgid (void) __attribute__ ((__nothrow__ , __leaf__));


extern __gid_t getegid (void) __attribute__ ((__nothrow__ , __leaf__));




extern int getgroups (int __size, __gid_t __list[]) __attribute__ ((__nothrow__ , __leaf__)) ;
# 703 "/usr/include/unistd.h" 3 4
extern int setuid (__uid_t __uid) __attribute__ ((__nothrow__ , __leaf__)) ;




extern int setreuid (__uid_t __ruid, __uid_t __euid) __attribute__ ((__nothrow__ , __leaf__)) ;




extern int seteuid (__uid_t __uid) __attribute__ ((__nothrow__ , __leaf__)) ;






extern int setgid (__gid_t __gid) __attribute__ ((__nothrow__ , __leaf__)) ;




extern int setregid (__gid_t __rgid, __gid_t __egid) __attribute__ ((__nothrow__ , __leaf__)) ;




extern int setegid (__gid_t __gid) __attribute__ ((__nothrow__ , __leaf__)) ;
# 759 "/usr/include/unistd.h" 3 4
extern __pid_t fork (void) __attribute__ ((__nothrow__));







extern __pid_t vfork (void) __attribute__ ((__nothrow__ , __leaf__));





extern char *ttyname (int __fd) __attribute__ ((__nothrow__ , __leaf__));



extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) ;



extern int isatty (int __fd) __attribute__ ((__nothrow__ , __leaf__));




extern int ttyslot (void) __attribute__ ((__nothrow__ , __leaf__));




extern int link (const char *__from, const char *__to)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))) ;




extern int linkat (int __fromfd, const char *__from, int __tofd,
     const char *__to, int __flags)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4))) ;




extern int symlink (const char *__from, const char *__to)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))) ;




extern ssize_t readlink (const char *__restrict __path,
    char *__restrict __buf, size_t __len)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))) ;




extern int symlinkat (const char *__from, int __tofd,
        const char *__to) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 3))) ;


extern ssize_t readlinkat (int __fd, const char *__restrict __path,
      char *__restrict __buf, size_t __len)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3))) ;



extern int unlink (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));



extern int unlinkat (int __fd, const char *__name, int __flag)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));



extern int rmdir (const char *__path) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));



extern __pid_t tcgetpgrp (int __fd) __attribute__ ((__nothrow__ , __leaf__));


extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __attribute__ ((__nothrow__ , __leaf__));






extern char *getlogin (void);







extern int getlogin_r (char *__name, size_t __name_len) __attribute__ ((__nonnull__ (1)));




extern int setlogin (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));







# 1 "/usr/include/x86_64-linux-gnu/bits/getopt_posix.h" 1 3 4
# 27 "/usr/include/x86_64-linux-gnu/bits/getopt_posix.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/getopt_core.h" 1 3 4
# 28 "/usr/include/x86_64-linux-gnu/bits/getopt_core.h" 3 4








extern char *optarg;
# 50 "/usr/include/x86_64-linux-gnu/bits/getopt_core.h" 3 4
extern int optind;




extern int opterr;



extern int optopt;
# 91 "/usr/include/x86_64-linux-gnu/bits/getopt_core.h" 3 4
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
       __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));


# 28 "/usr/include/x86_64-linux-gnu/bits/getopt_posix.h" 2 3 4


# 49 "/usr/include/x86_64-linux-gnu/bits/getopt_posix.h" 3 4

# 873 "/usr/include/unistd.h" 2 3 4







extern int gethostname (char *__name, size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));






extern int sethostname (const char *__name, size_t __len)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;



extern int sethostid (long int __id) __attribute__ ((__nothrow__ , __leaf__)) ;





extern int getdomainname (char *__name, size_t __len)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;
extern int setdomainname (const char *__name, size_t __len)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;





extern int vhangup (void) __attribute__ ((__nothrow__ , __leaf__));


extern int revoke (const char *__file) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;







extern int profil (unsigned short int *__sample_buffer, size_t __size,
     size_t __offset, unsigned int __scale)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));





extern int acct (const char *__name) __attribute__ ((__nothrow__ , __leaf__));



extern char *getusershell (void) __attribute__ ((__nothrow__ , __leaf__));
extern void endusershell (void) __attribute__ ((__nothrow__ , __leaf__));
extern void setusershell (void) __attribute__ ((__nothrow__ , __leaf__));





extern int daemon (int __nochdir, int __noclose) __attribute__ ((__nothrow__ , __leaf__)) ;






extern int chroot (const char *__path) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;



extern char *getpass (const char *__prompt) __attribute__ ((__nonnull__ (1)));







extern int fsync (int __fd);
# 970 "/usr/include/unistd.h" 3 4
extern long int gethostid (void);


extern void sync (void) __attribute__ ((__nothrow__ , __leaf__));





extern int getpagesize (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));




extern int getdtablesize (void) __attribute__ ((__nothrow__ , __leaf__));
# 994 "/usr/include/unistd.h" 3 4
extern int truncate (const char *__file, __off_t __length)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ;
# 1017 "/usr/include/unistd.h" 3 4
extern int ftruncate (int __fd, __off_t __length) __attribute__ ((__nothrow__ , __leaf__)) ;
# 1038 "/usr/include/unistd.h" 3 4
extern int brk (void *__addr) __attribute__ ((__nothrow__ , __leaf__)) ;





extern void *sbrk (intptr_t __delta) __attribute__ ((__nothrow__ , __leaf__));
# 1059 "/usr/include/unistd.h" 3 4
extern long int syscall (long int __sysno, ...) __attribute__ ((__nothrow__ , __leaf__));
# 1082 "/usr/include/unistd.h" 3 4
extern int lockf (int __fd, int __cmd, __off_t __len) ;
# 1118 "/usr/include/unistd.h" 3 4
extern int fdatasync (int __fildes);
# 1167 "/usr/include/unistd.h" 3 4
int getentropy (void *__buffer, size_t __length) ;








# 30 "afl-fuzz-single.c" 2


# 1 "/usr/include/time.h" 1 3 4
# 29 "/usr/include/time.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 30 "/usr/include/time.h" 2 3 4



# 1 "/usr/include/x86_64-linux-gnu/bits/time.h" 1 3 4
# 34 "/usr/include/time.h" 2 3 4





# 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h" 1 3 4






struct tm
{
  int tm_sec;
  int tm_min;
  int tm_hour;
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_wday;
  int tm_yday;
  int tm_isdst;


  long int tm_gmtoff;
  const char *tm_zone;




};
# 40 "/usr/include/time.h" 2 3 4
# 48 "/usr/include/time.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_itimerspec.h" 1 3 4







struct itimerspec
  {
    struct timespec it_interval;
    struct timespec it_value;
  };
# 49 "/usr/include/time.h" 2 3 4
struct sigevent;
# 68 "/usr/include/time.h" 3 4




extern clock_t clock (void) __attribute__ ((__nothrow__ , __leaf__));


extern time_t time (time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));


extern double difftime (time_t __time1, time_t __time0)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));


extern time_t mktime (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));





extern size_t strftime (char *__restrict __s, size_t __maxsize,
   const char *__restrict __format,
   const struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));
# 104 "/usr/include/time.h" 3 4
extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
     const char *__restrict __format,
     const struct tm *__restrict __tp,
     locale_t __loc) __attribute__ ((__nothrow__ , __leaf__));
# 119 "/usr/include/time.h" 3 4
extern struct tm *gmtime (const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));



extern struct tm *localtime (const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));




extern struct tm *gmtime_r (const time_t *__restrict __timer,
       struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));



extern struct tm *localtime_r (const time_t *__restrict __timer,
          struct tm *__restrict __tp) __attribute__ ((__nothrow__ , __leaf__));




extern char *asctime (const struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));


extern char *ctime (const time_t *__timer) __attribute__ ((__nothrow__ , __leaf__));






extern char *asctime_r (const struct tm *__restrict __tp,
   char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));


extern char *ctime_r (const time_t *__restrict __timer,
        char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));




extern char *__tzname[2];
extern int __daylight;
extern long int __timezone;




extern char *tzname[2];



extern void tzset (void) __attribute__ ((__nothrow__ , __leaf__));



extern int daylight;
extern long int timezone;





extern int stime (const time_t *__when) __attribute__ ((__nothrow__ , __leaf__));
# 196 "/usr/include/time.h" 3 4
extern time_t timegm (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));


extern time_t timelocal (struct tm *__tp) __attribute__ ((__nothrow__ , __leaf__));


extern int dysize (int __year) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
# 211 "/usr/include/time.h" 3 4
extern int nanosleep (const struct timespec *__requested_time,
        struct timespec *__remaining);



extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __attribute__ ((__nothrow__ , __leaf__));


extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __attribute__ ((__nothrow__ , __leaf__));


extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
     __attribute__ ((__nothrow__ , __leaf__));






extern int clock_nanosleep (clockid_t __clock_id, int __flags,
       const struct timespec *__req,
       struct timespec *__rem);


extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __attribute__ ((__nothrow__ , __leaf__));




extern int timer_create (clockid_t __clock_id,
    struct sigevent *__restrict __evp,
    timer_t *__restrict __timerid) __attribute__ ((__nothrow__ , __leaf__));


extern int timer_delete (timer_t __timerid) __attribute__ ((__nothrow__ , __leaf__));


extern int timer_settime (timer_t __timerid, int __flags,
     const struct itimerspec *__restrict __value,
     struct itimerspec *__restrict __ovalue) __attribute__ ((__nothrow__ , __leaf__));


extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
     __attribute__ ((__nothrow__ , __leaf__));


extern int timer_getoverrun (timer_t __timerid) __attribute__ ((__nothrow__ , __leaf__));





extern int timespec_get (struct timespec *__ts, int __base)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
# 307 "/usr/include/time.h" 3 4

# 33 "afl-fuzz-single.c" 2
# 1 "/usr/include/errno.h" 1 3 4
# 28 "/usr/include/errno.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/errno.h" 1 3 4
# 26 "/usr/include/x86_64-linux-gnu/bits/errno.h" 3 4
# 1 "/usr/include/linux/errno.h" 1 3 4
# 1 "/usr/include/x86_64-linux-gnu/asm/errno.h" 1 3 4
# 1 "/usr/include/asm-generic/errno.h" 1 3 4




# 1 "/usr/include/asm-generic/errno-base.h" 1 3 4
# 6 "/usr/include/asm-generic/errno.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/asm/errno.h" 2 3 4
# 1 "/usr/include/linux/errno.h" 2 3 4
# 27 "/usr/include/x86_64-linux-gnu/bits/errno.h" 2 3 4
# 29 "/usr/include/errno.h" 2 3 4








extern int *__errno_location (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
# 57 "/usr/include/errno.h" 3 4

# 34 "afl-fuzz-single.c" 2
# 1 "/usr/include/signal.h" 1 3 4
# 27 "/usr/include/signal.h" 3 4



# 1 "/usr/include/x86_64-linux-gnu/bits/signum.h" 1 3 4
# 26 "/usr/include/x86_64-linux-gnu/bits/signum.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/signum-generic.h" 1 3 4
# 27 "/usr/include/x86_64-linux-gnu/bits/signum.h" 2 3 4
# 31 "/usr/include/signal.h" 2 3 4

# 1 "/usr/include/x86_64-linux-gnu/bits/types/sig_atomic_t.h" 1 3 4







typedef __sig_atomic_t sig_atomic_t;
# 33 "/usr/include/signal.h" 2 3 4
# 57 "/usr/include/signal.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/types/siginfo_t.h" 1 3 4



# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
# 5 "/usr/include/x86_64-linux-gnu/bits/types/siginfo_t.h" 2 3 4

# 1 "/usr/include/x86_64-linux-gnu/bits/types/__sigval_t.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/bits/types/__sigval_t.h" 3 4
union sigval
{
  int sival_int;
  void *sival_ptr;
};

typedef union sigval __sigval_t;
# 7 "/usr/include/x86_64-linux-gnu/bits/types/siginfo_t.h" 2 3 4
# 16 "/usr/include/x86_64-linux-gnu/bits/types/siginfo_t.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/siginfo-arch.h" 1 3 4
# 17 "/usr/include/x86_64-linux-gnu/bits/types/siginfo_t.h" 2 3 4
# 36 "/usr/include/x86_64-linux-gnu/bits/types/siginfo_t.h" 3 4
typedef struct
  {
    int si_signo;

    int si_errno;

    int si_code;





    int __pad0;


    union
      {
 int _pad[((128 / sizeof (int)) - 4)];


 struct
   {
     __pid_t si_pid;
     __uid_t si_uid;
   } _kill;


 struct
   {
     int si_tid;
     int si_overrun;
     __sigval_t si_sigval;
   } _timer;


 struct
   {
     __pid_t si_pid;
     __uid_t si_uid;
     __sigval_t si_sigval;
   } _rt;


 struct
   {
     __pid_t si_pid;
     __uid_t si_uid;
     int si_status;
     __clock_t si_utime;
     __clock_t si_stime;
   } _sigchld;


 struct
   {
     void *si_addr;
    
     short int si_addr_lsb;
     union
       {

  struct
    {
      void *_lower;
      void *_upper;
    } _addr_bnd;

  __uint32_t _pkey;
       } _bounds;
   } _sigfault;


 struct
   {
     long int si_band;
     int si_fd;
   } _sigpoll;



 struct
   {
     void *_call_addr;
     int _syscall;
     unsigned int _arch;
   } _sigsys;

      } _sifields;
  } siginfo_t ;
# 58 "/usr/include/signal.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/siginfo-consts.h" 1 3 4
# 35 "/usr/include/x86_64-linux-gnu/bits/siginfo-consts.h" 3 4
enum
{
  SI_ASYNCNL = -60,
  SI_TKILL = -6,
  SI_SIGIO,

  SI_ASYNCIO,
  SI_MESGQ,
  SI_TIMER,





  SI_QUEUE,
  SI_USER,
  SI_KERNEL = 0x80
# 63 "/usr/include/x86_64-linux-gnu/bits/siginfo-consts.h" 3 4
};




enum
{
  ILL_ILLOPC = 1,

  ILL_ILLOPN,

  ILL_ILLADR,

  ILL_ILLTRP,

  ILL_PRVOPC,

  ILL_PRVREG,

  ILL_COPROC,

  ILL_BADSTK

};


enum
{
  FPE_INTDIV = 1,

  FPE_INTOVF,

  FPE_FLTDIV,

  FPE_FLTOVF,

  FPE_FLTUND,

  FPE_FLTRES,

  FPE_FLTINV,

  FPE_FLTSUB

};


enum
{
  SEGV_MAPERR = 1,

  SEGV_ACCERR,

  SEGV_BNDERR,

  SEGV_PKUERR

};


enum
{
  BUS_ADRALN = 1,

  BUS_ADRERR,

  BUS_OBJERR,

  BUS_MCEERR_AR,

  BUS_MCEERR_AO

};
# 151 "/usr/include/x86_64-linux-gnu/bits/siginfo-consts.h" 3 4
enum
{
  CLD_EXITED = 1,

  CLD_KILLED,

  CLD_DUMPED,

  CLD_TRAPPED,

  CLD_STOPPED,

  CLD_CONTINUED

};


enum
{
  POLL_IN = 1,

  POLL_OUT,

  POLL_MSG,

  POLL_ERR,

  POLL_PRI,

  POLL_HUP

};
# 59 "/usr/include/signal.h" 2 3 4



# 1 "/usr/include/x86_64-linux-gnu/bits/types/sigval_t.h" 1 3 4
# 16 "/usr/include/x86_64-linux-gnu/bits/types/sigval_t.h" 3 4
typedef __sigval_t sigval_t;
# 63 "/usr/include/signal.h" 2 3 4



# 1 "/usr/include/x86_64-linux-gnu/bits/types/sigevent_t.h" 1 3 4



# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
# 5 "/usr/include/x86_64-linux-gnu/bits/types/sigevent_t.h" 2 3 4
# 22 "/usr/include/x86_64-linux-gnu/bits/types/sigevent_t.h" 3 4
typedef struct sigevent
  {
    __sigval_t sigev_value;
    int sigev_signo;
    int sigev_notify;

    union
      {
 int _pad[((64 / sizeof (int)) - 4)];



 __pid_t _tid;

 struct
   {
     void (*_function) (__sigval_t);
     pthread_attr_t *_attribute;
   } _sigev_thread;
      } _sigev_un;
  } sigevent_t;
# 67 "/usr/include/signal.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/sigevent-consts.h" 1 3 4
# 27 "/usr/include/x86_64-linux-gnu/bits/sigevent-consts.h" 3 4
enum
{
  SIGEV_SIGNAL = 0,

  SIGEV_NONE,

  SIGEV_THREAD,


  SIGEV_THREAD_ID = 4


};
# 68 "/usr/include/signal.h" 2 3 4




typedef void (*__sighandler_t) (int);




extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler)
     __attribute__ ((__nothrow__ , __leaf__));
# 88 "/usr/include/signal.h" 3 4
extern __sighandler_t signal (int __sig, __sighandler_t __handler)
     __attribute__ ((__nothrow__ , __leaf__));
# 112 "/usr/include/signal.h" 3 4
extern int kill (__pid_t __pid, int __sig) __attribute__ ((__nothrow__ , __leaf__));






extern int killpg (__pid_t __pgrp, int __sig) __attribute__ ((__nothrow__ , __leaf__));



extern int raise (int __sig) __attribute__ ((__nothrow__ , __leaf__));



extern __sighandler_t ssignal (int __sig, __sighandler_t __handler)
     __attribute__ ((__nothrow__ , __leaf__));
extern int gsignal (int __sig) __attribute__ ((__nothrow__ , __leaf__));




extern void psignal (int __sig, const char *__s);


extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
# 170 "/usr/include/signal.h" 3 4
extern int sigblock (int __mask) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));


extern int sigsetmask (int __mask) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));


extern int siggetmask (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
# 190 "/usr/include/signal.h" 3 4
typedef __sighandler_t sig_t;





extern int sigemptyset (sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern int sigfillset (sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern int sigaddset (sigset_t *__set, int __signo) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern int sigdelset (sigset_t *__set, int __signo) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern int sigismember (const sigset_t *__set, int __signo)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
# 226 "/usr/include/signal.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/sigaction.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/bits/sigaction.h" 3 4
struct sigaction
  {


    union
      {

 __sighandler_t sa_handler;

 void (*sa_sigaction) (int, siginfo_t *, void *);
      }
    __sigaction_handler;







    __sigset_t sa_mask;


    int sa_flags;


    void (*sa_restorer) (void);
  };
# 227 "/usr/include/signal.h" 2 3 4


extern int sigprocmask (int __how, const sigset_t *__restrict __set,
   sigset_t *__restrict __oset) __attribute__ ((__nothrow__ , __leaf__));






extern int sigsuspend (const sigset_t *__set) __attribute__ ((__nonnull__ (1)));


extern int sigaction (int __sig, const struct sigaction *__restrict __act,
        struct sigaction *__restrict __oact) __attribute__ ((__nothrow__ , __leaf__));


extern int sigpending (sigset_t *__set) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));







extern int sigwait (const sigset_t *__restrict __set, int *__restrict __sig)
     __attribute__ ((__nonnull__ (1, 2)));







extern int sigwaitinfo (const sigset_t *__restrict __set,
   siginfo_t *__restrict __info) __attribute__ ((__nonnull__ (1)));






extern int sigtimedwait (const sigset_t *__restrict __set,
    siginfo_t *__restrict __info,
    const struct timespec *__restrict __timeout)
     __attribute__ ((__nonnull__ (1)));



extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val)
     __attribute__ ((__nothrow__ , __leaf__));
# 286 "/usr/include/signal.h" 3 4
extern const char *const _sys_siglist[(64 + 1)];
extern const char *const sys_siglist[(64 + 1)];



# 1 "/usr/include/x86_64-linux-gnu/bits/sigcontext.h" 1 3 4
# 31 "/usr/include/x86_64-linux-gnu/bits/sigcontext.h" 3 4
struct _fpx_sw_bytes
{
  __uint32_t magic1;
  __uint32_t extended_size;
  __uint64_t xstate_bv;
  __uint32_t xstate_size;
  __uint32_t __glibc_reserved1[7];
};

struct _fpreg
{
  unsigned short significand[4];
  unsigned short exponent;
};

struct _fpxreg
{
  unsigned short significand[4];
  unsigned short exponent;
  unsigned short __glibc_reserved1[3];
};

struct _xmmreg
{
  __uint32_t element[4];
};
# 123 "/usr/include/x86_64-linux-gnu/bits/sigcontext.h" 3 4
struct _fpstate
{

  __uint16_t cwd;
  __uint16_t swd;
  __uint16_t ftw;
  __uint16_t fop;
  __uint64_t rip;
  __uint64_t rdp;
  __uint32_t mxcsr;
  __uint32_t mxcr_mask;
  struct _fpxreg _st[8];
  struct _xmmreg _xmm[16];
  __uint32_t __glibc_reserved1[24];
};

struct sigcontext
{
  __uint64_t r8;
  __uint64_t r9;
  __uint64_t r10;
  __uint64_t r11;
  __uint64_t r12;
  __uint64_t r13;
  __uint64_t r14;
  __uint64_t r15;
  __uint64_t rdi;
  __uint64_t rsi;
  __uint64_t rbp;
  __uint64_t rbx;
  __uint64_t rdx;
  __uint64_t rax;
  __uint64_t rcx;
  __uint64_t rsp;
  __uint64_t rip;
  __uint64_t eflags;
  unsigned short cs;
  unsigned short gs;
  unsigned short fs;
  unsigned short __pad0;
  __uint64_t err;
  __uint64_t trapno;
  __uint64_t oldmask;
  __uint64_t cr2;
  __extension__ union
    {
      struct _fpstate * fpstate;
      __uint64_t __fpstate_word;
    };
  __uint64_t __reserved1 [8];
};



struct _xsave_hdr
{
  __uint64_t xstate_bv;
  __uint64_t __glibc_reserved1[2];
  __uint64_t __glibc_reserved2[5];
};

struct _ymmh_state
{
  __uint32_t ymmh_space[64];
};

struct _xstate
{
  struct _fpstate fpstate;
  struct _xsave_hdr xstate_hdr;
  struct _ymmh_state ymmh;
};
# 292 "/usr/include/signal.h" 2 3 4


extern int sigreturn (struct sigcontext *__scp) __attribute__ ((__nothrow__ , __leaf__));






# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 302 "/usr/include/signal.h" 2 3 4

# 1 "/usr/include/x86_64-linux-gnu/bits/types/stack_t.h" 1 3 4
# 23 "/usr/include/x86_64-linux-gnu/bits/types/stack_t.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/bits/types/stack_t.h" 2 3 4


typedef struct
  {
    void *ss_sp;
    int ss_flags;
    size_t ss_size;
  } stack_t;
# 304 "/usr/include/signal.h" 2 3 4


# 1 "/usr/include/x86_64-linux-gnu/sys/ucontext.h" 1 3 4
# 37 "/usr/include/x86_64-linux-gnu/sys/ucontext.h" 3 4
__extension__ typedef long long int greg_t;
# 46 "/usr/include/x86_64-linux-gnu/sys/ucontext.h" 3 4
typedef greg_t gregset_t[23];
# 101 "/usr/include/x86_64-linux-gnu/sys/ucontext.h" 3 4
struct _libc_fpxreg
{
  unsigned short int significand[4];
  unsigned short int exponent;
  unsigned short int __glibc_reserved1[3];
};

struct _libc_xmmreg
{
  __uint32_t element[4];
};

struct _libc_fpstate
{

  __uint16_t cwd;
  __uint16_t swd;
  __uint16_t ftw;
  __uint16_t fop;
  __uint64_t rip;
  __uint64_t rdp;
  __uint32_t mxcsr;
  __uint32_t mxcr_mask;
  struct _libc_fpxreg _st[8];
  struct _libc_xmmreg _xmm[16];
  __uint32_t __glibc_reserved1[24];
};


typedef struct _libc_fpstate *fpregset_t;


typedef struct
  {
    gregset_t gregs;

    fpregset_t fpregs;
    __extension__ unsigned long long __reserved1 [8];
} mcontext_t;


typedef struct ucontext_t
  {
    unsigned long int uc_flags;
    struct ucontext_t *uc_link;
    stack_t uc_stack;
    mcontext_t uc_mcontext;
    sigset_t uc_sigmask;
    struct _libc_fpstate __fpregs_mem;
  } ucontext_t;
# 307 "/usr/include/signal.h" 2 3 4







extern int siginterrupt (int __sig, int __interrupt) __attribute__ ((__nothrow__ , __leaf__));

# 1 "/usr/include/x86_64-linux-gnu/bits/sigstack.h" 1 3 4
# 317 "/usr/include/signal.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/ss_flags.h" 1 3 4
# 27 "/usr/include/x86_64-linux-gnu/bits/ss_flags.h" 3 4
enum
{
  SS_ONSTACK = 1,

  SS_DISABLE

};
# 318 "/usr/include/signal.h" 2 3 4



extern int sigaltstack (const stack_t *__restrict __ss,
   stack_t *__restrict __oss) __attribute__ ((__nothrow__ , __leaf__));




# 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_sigstack.h" 1 3 4
# 23 "/usr/include/x86_64-linux-gnu/bits/types/struct_sigstack.h" 3 4
struct sigstack
  {
    void *ss_sp;
    int ss_onstack;
  };
# 328 "/usr/include/signal.h" 2 3 4







extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__deprecated__));
# 359 "/usr/include/signal.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/sigthread.h" 1 3 4
# 31 "/usr/include/x86_64-linux-gnu/bits/sigthread.h" 3 4
extern int pthread_sigmask (int __how,
       const __sigset_t *__restrict __newmask,
       __sigset_t *__restrict __oldmask)__attribute__ ((__nothrow__ , __leaf__));


extern int pthread_kill (pthread_t __threadid, int __signo) __attribute__ ((__nothrow__ , __leaf__));
# 360 "/usr/include/signal.h" 2 3 4






extern int __libc_current_sigrtmin (void) __attribute__ ((__nothrow__ , __leaf__));

extern int __libc_current_sigrtmax (void) __attribute__ ((__nothrow__ , __leaf__));





# 35 "afl-fuzz-single.c" 2
# 1 "/usr/include/dirent.h" 1 3 4
# 27 "/usr/include/dirent.h" 3 4

# 61 "/usr/include/dirent.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/dirent.h" 1 3 4
# 22 "/usr/include/x86_64-linux-gnu/bits/dirent.h" 3 4
struct dirent
  {

    __ino_t d_ino;
    __off_t d_off;




    unsigned short int d_reclen;
    unsigned char d_type;
    char d_name[256];
  };
# 62 "/usr/include/dirent.h" 2 3 4
# 97 "/usr/include/dirent.h" 3 4
enum
  {
    DT_UNKNOWN = 0,

    DT_FIFO = 1,

    DT_CHR = 2,

    DT_DIR = 4,

    DT_BLK = 6,

    DT_REG = 8,

    DT_LNK = 10,

    DT_SOCK = 12,

    DT_WHT = 14

  };
# 127 "/usr/include/dirent.h" 3 4
typedef struct __dirstream DIR;






extern DIR *opendir (const char *__name) __attribute__ ((__nonnull__ (1)));






extern DIR *fdopendir (int __fd);







extern int closedir (DIR *__dirp) __attribute__ ((__nonnull__ (1)));
# 162 "/usr/include/dirent.h" 3 4
extern struct dirent *readdir (DIR *__dirp) __attribute__ ((__nonnull__ (1)));
# 183 "/usr/include/dirent.h" 3 4
extern int readdir_r (DIR *__restrict __dirp,
        struct dirent *__restrict __entry,
        struct dirent **__restrict __result)
     __attribute__ ((__nonnull__ (1, 2, 3))) __attribute__ ((__deprecated__));
# 209 "/usr/include/dirent.h" 3 4
extern void rewinddir (DIR *__dirp) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));





extern void seekdir (DIR *__dirp, long int __pos) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern long int telldir (DIR *__dirp) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));





extern int dirfd (DIR *__dirp) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
# 233 "/usr/include/dirent.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/posix1_lim.h" 1 3 4
# 160 "/usr/include/x86_64-linux-gnu/bits/posix1_lim.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/local_lim.h" 1 3 4
# 38 "/usr/include/x86_64-linux-gnu/bits/local_lim.h" 3 4
# 1 "/usr/include/linux/limits.h" 1 3 4
# 39 "/usr/include/x86_64-linux-gnu/bits/local_lim.h" 2 3 4
# 161 "/usr/include/x86_64-linux-gnu/bits/posix1_lim.h" 2 3 4
# 234 "/usr/include/dirent.h" 2 3 4
# 245 "/usr/include/dirent.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 246 "/usr/include/dirent.h" 2 3 4
# 255 "/usr/include/dirent.h" 3 4
extern int scandir (const char *__restrict __dir,
      struct dirent ***__restrict __namelist,
      int (*__selector) (const struct dirent *),
      int (*__cmp) (const struct dirent **,
      const struct dirent **))
     __attribute__ ((__nonnull__ (1, 2)));
# 325 "/usr/include/dirent.h" 3 4
extern int alphasort (const struct dirent **__e1,
        const struct dirent **__e2)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
# 353 "/usr/include/dirent.h" 3 4
extern __ssize_t getdirentries (int __fd, char *__restrict __buf,
    size_t __nbytes,
    __off_t *__restrict __basep)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));
# 402 "/usr/include/dirent.h" 3 4

# 36 "afl-fuzz-single.c" 2

# 1 "/usr/include/x86_64-linux-gnu/sys/fcntl.h" 1 3 4
# 1 "/usr/include/fcntl.h" 1 3 4
# 28 "/usr/include/fcntl.h" 3 4







# 1 "/usr/include/x86_64-linux-gnu/bits/fcntl.h" 1 3 4
# 35 "/usr/include/x86_64-linux-gnu/bits/fcntl.h" 3 4
struct flock
  {
    short int l_type;
    short int l_whence;

    __off_t l_start;
    __off_t l_len;




    __pid_t l_pid;
  };
# 61 "/usr/include/x86_64-linux-gnu/bits/fcntl.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h" 1 3 4
# 380 "/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h" 3 4

# 454 "/usr/include/x86_64-linux-gnu/bits/fcntl-linux.h" 3 4

# 61 "/usr/include/x86_64-linux-gnu/bits/fcntl.h" 2 3 4
# 36 "/usr/include/fcntl.h" 2 3 4
# 78 "/usr/include/fcntl.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/stat.h" 1 3 4
# 46 "/usr/include/x86_64-linux-gnu/bits/stat.h" 3 4
struct stat
  {
    __dev_t st_dev;




    __ino_t st_ino;







    __nlink_t st_nlink;
    __mode_t st_mode;

    __uid_t st_uid;
    __gid_t st_gid;

    int __pad0;

    __dev_t st_rdev;




    __off_t st_size;



    __blksize_t st_blksize;

    __blkcnt_t st_blocks;
# 91 "/usr/include/x86_64-linux-gnu/bits/stat.h" 3 4
    struct timespec st_atim;
    struct timespec st_mtim;
    struct timespec st_ctim;
# 106 "/usr/include/x86_64-linux-gnu/bits/stat.h" 3 4
    __syscall_slong_t __glibc_reserved[3];
# 115 "/usr/include/x86_64-linux-gnu/bits/stat.h" 3 4
  };
# 79 "/usr/include/fcntl.h" 2 3 4
# 147 "/usr/include/fcntl.h" 3 4
extern int fcntl (int __fd, int __cmd, ...);
# 157 "/usr/include/fcntl.h" 3 4
extern int open (const char *__file, int __oflag, ...) __attribute__ ((__nonnull__ (1)));
# 181 "/usr/include/fcntl.h" 3 4
extern int openat (int __fd, const char *__file, int __oflag, ...)
     __attribute__ ((__nonnull__ (2)));
# 203 "/usr/include/fcntl.h" 3 4
extern int creat (const char *__file, mode_t __mode) __attribute__ ((__nonnull__ (1)));
# 249 "/usr/include/fcntl.h" 3 4
extern int posix_fadvise (int __fd, off_t __offset, off_t __len,
     int __advise) __attribute__ ((__nothrow__ , __leaf__));
# 271 "/usr/include/fcntl.h" 3 4
extern int posix_fallocate (int __fd, off_t __offset, off_t __len);
# 293 "/usr/include/fcntl.h" 3 4

# 1 "/usr/include/x86_64-linux-gnu/sys/fcntl.h" 2 3 4
# 38 "afl-fuzz-single.c" 2
# 1 "/usr/include/x86_64-linux-gnu/sys/wait.h" 1 3 4
# 27 "/usr/include/x86_64-linux-gnu/sys/wait.h" 3 4

# 77 "/usr/include/x86_64-linux-gnu/sys/wait.h" 3 4
extern __pid_t wait (int *__stat_loc);
# 100 "/usr/include/x86_64-linux-gnu/sys/wait.h" 3 4
extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
# 121 "/usr/include/x86_64-linux-gnu/sys/wait.h" 3 4
extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
     int __options);






struct rusage;






extern __pid_t wait3 (int *__stat_loc, int __options,
        struct rusage * __usage) __attribute__ ((__nothrow__));




extern __pid_t wait4 (__pid_t __pid, int *__stat_loc, int __options,
        struct rusage *__usage) __attribute__ ((__nothrow__));




# 39 "afl-fuzz-single.c" 2
# 1 "/usr/include/x86_64-linux-gnu/sys/time.h" 1 3 4
# 34 "/usr/include/x86_64-linux-gnu/sys/time.h" 3 4

# 52 "/usr/include/x86_64-linux-gnu/sys/time.h" 3 4
struct timezone
  {
    int tz_minuteswest;
    int tz_dsttime;
  };

typedef struct timezone *__restrict __timezone_ptr_t;
# 68 "/usr/include/x86_64-linux-gnu/sys/time.h" 3 4
extern int gettimeofday (struct timeval *__restrict __tv,
    __timezone_ptr_t __tz) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));




extern int settimeofday (const struct timeval *__tv,
    const struct timezone *__tz)
     __attribute__ ((__nothrow__ , __leaf__));





extern int adjtime (const struct timeval *__delta,
      struct timeval *__olddelta) __attribute__ ((__nothrow__ , __leaf__));




enum __itimer_which
  {

    ITIMER_REAL = 0,


    ITIMER_VIRTUAL = 1,



    ITIMER_PROF = 2

  };



struct itimerval
  {

    struct timeval it_interval;

    struct timeval it_value;
  };






typedef int __itimer_which_t;




extern int getitimer (__itimer_which_t __which,
        struct itimerval *__value) __attribute__ ((__nothrow__ , __leaf__));




extern int setitimer (__itimer_which_t __which,
        const struct itimerval *__restrict __new,
        struct itimerval *__restrict __old) __attribute__ ((__nothrow__ , __leaf__));




extern int utimes (const char *__file, const struct timeval __tvp[2])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));



extern int lutimes (const char *__file, const struct timeval __tvp[2])
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));


extern int futimes (int __fd, const struct timeval __tvp[2]) __attribute__ ((__nothrow__ , __leaf__));
# 186 "/usr/include/x86_64-linux-gnu/sys/time.h" 3 4

# 40 "afl-fuzz-single.c" 2
# 1 "/usr/include/x86_64-linux-gnu/sys/shm.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/sys/shm.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 25 "/usr/include/x86_64-linux-gnu/sys/shm.h" 2 3 4


# 1 "/usr/include/x86_64-linux-gnu/sys/ipc.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/sys/ipc.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/ipctypes.h" 1 3 4
# 28 "/usr/include/x86_64-linux-gnu/bits/ipctypes.h" 3 4
typedef int __ipc_pid_t;
# 25 "/usr/include/x86_64-linux-gnu/sys/ipc.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/ipc.h" 1 3 4
# 42 "/usr/include/x86_64-linux-gnu/bits/ipc.h" 3 4
struct ipc_perm
  {
    __key_t __key;
    __uid_t uid;
    __gid_t gid;
    __uid_t cuid;
    __gid_t cgid;
    unsigned short int mode;
    unsigned short int __pad1;
    unsigned short int __seq;
    unsigned short int __pad2;
    __syscall_ulong_t __glibc_reserved1;
    __syscall_ulong_t __glibc_reserved2;
  };
# 26 "/usr/include/x86_64-linux-gnu/sys/ipc.h" 2 3 4
# 47 "/usr/include/x86_64-linux-gnu/sys/ipc.h" 3 4



extern key_t ftok (const char *__pathname, int __proj_id) __attribute__ ((__nothrow__ , __leaf__));


# 28 "/usr/include/x86_64-linux-gnu/sys/shm.h" 2 3 4


# 1 "/usr/include/x86_64-linux-gnu/bits/shm.h" 1 3 4
# 38 "/usr/include/x86_64-linux-gnu/bits/shm.h" 3 4




extern int __getpagesize (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));



typedef __syscall_ulong_t shmatt_t;


struct shmid_ds
  {
    struct ipc_perm shm_perm;
    size_t shm_segsz;
    __time_t shm_atime;



    __time_t shm_dtime;



    __time_t shm_ctime;



    __pid_t shm_cpid;
    __pid_t shm_lpid;
    shmatt_t shm_nattch;
    __syscall_ulong_t __glibc_reserved4;
    __syscall_ulong_t __glibc_reserved5;
  };
# 84 "/usr/include/x86_64-linux-gnu/bits/shm.h" 3 4
struct shminfo
  {
    __syscall_ulong_t shmmax;
    __syscall_ulong_t shmmin;
    __syscall_ulong_t shmmni;
    __syscall_ulong_t shmseg;
    __syscall_ulong_t shmall;
    __syscall_ulong_t __glibc_reserved1;
    __syscall_ulong_t __glibc_reserved2;
    __syscall_ulong_t __glibc_reserved3;
    __syscall_ulong_t __glibc_reserved4;
  };

struct shm_info
  {
    int used_ids;
    __syscall_ulong_t shm_tot;
    __syscall_ulong_t shm_rss;
    __syscall_ulong_t shm_swp;
    __syscall_ulong_t swap_attempts;
    __syscall_ulong_t swap_successes;
  };




# 31 "/usr/include/x86_64-linux-gnu/sys/shm.h" 2 3 4
# 43 "/usr/include/x86_64-linux-gnu/sys/shm.h" 3 4






extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf) __attribute__ ((__nothrow__ , __leaf__));


extern int shmget (key_t __key, size_t __size, int __shmflg) __attribute__ ((__nothrow__ , __leaf__));


extern void *shmat (int __shmid, const void *__shmaddr, int __shmflg)
     __attribute__ ((__nothrow__ , __leaf__));


extern int shmdt (const void *__shmaddr) __attribute__ ((__nothrow__ , __leaf__));


# 41 "afl-fuzz-single.c" 2
# 1 "/usr/include/x86_64-linux-gnu/sys/stat.h" 1 3 4
# 99 "/usr/include/x86_64-linux-gnu/sys/stat.h" 3 4


# 1 "/usr/include/x86_64-linux-gnu/bits/stat.h" 1 3 4
# 102 "/usr/include/x86_64-linux-gnu/sys/stat.h" 2 3 4
# 205 "/usr/include/x86_64-linux-gnu/sys/stat.h" 3 4
extern int stat (const char *__restrict __file,
   struct stat *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));



extern int fstat (int __fd, struct stat *__buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));
# 234 "/usr/include/x86_64-linux-gnu/sys/stat.h" 3 4
extern int fstatat (int __fd, const char *__restrict __file,
      struct stat *__restrict __buf, int __flag)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
# 259 "/usr/include/x86_64-linux-gnu/sys/stat.h" 3 4
extern int lstat (const char *__restrict __file,
    struct stat *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2)));
# 280 "/usr/include/x86_64-linux-gnu/sys/stat.h" 3 4
extern int chmod (const char *__file, __mode_t __mode)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));





extern int lchmod (const char *__file, __mode_t __mode)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));




extern int fchmod (int __fd, __mode_t __mode) __attribute__ ((__nothrow__ , __leaf__));





extern int fchmodat (int __fd, const char *__file, __mode_t __mode,
       int __flag)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))) ;






extern __mode_t umask (__mode_t __mask) __attribute__ ((__nothrow__ , __leaf__));
# 317 "/usr/include/x86_64-linux-gnu/sys/stat.h" 3 4
extern int mkdir (const char *__path, __mode_t __mode)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));





extern int mkdirat (int __fd, const char *__path, __mode_t __mode)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));






extern int mknod (const char *__path, __mode_t __mode, __dev_t __dev)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));





extern int mknodat (int __fd, const char *__path, __mode_t __mode,
      __dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));





extern int mkfifo (const char *__path, __mode_t __mode)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));





extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));





extern int utimensat (int __fd, const char *__path,
        const struct timespec __times[2],
        int __flags)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2)));




extern int futimens (int __fd, const struct timespec __times[2]) __attribute__ ((__nothrow__ , __leaf__));
# 395 "/usr/include/x86_64-linux-gnu/sys/stat.h" 3 4
extern int __fxstat (int __ver, int __fildes, struct stat *__stat_buf)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3)));
extern int __xstat (int __ver, const char *__filename,
      struct stat *__stat_buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
extern int __lxstat (int __ver, const char *__filename,
       struct stat *__stat_buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3)));
extern int __fxstatat (int __ver, int __fildes, const char *__filename,
         struct stat *__stat_buf, int __flag)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4)));
# 438 "/usr/include/x86_64-linux-gnu/sys/stat.h" 3 4
extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
       __dev_t *__dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4)));

extern int __xmknodat (int __ver, int __fd, const char *__path,
         __mode_t __mode, __dev_t *__dev)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 5)));
# 530 "/usr/include/x86_64-linux-gnu/sys/stat.h" 3 4

# 42 "afl-fuzz-single.c" 2

# 1 "/usr/include/arpa/inet.h" 1 3 4
# 22 "/usr/include/arpa/inet.h" 3 4
# 1 "/usr/include/netinet/in.h" 1 3 4
# 23 "/usr/include/netinet/in.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/sys/socket.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/sys/socket.h" 3 4


# 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h" 1 3 4
# 23 "/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/bits/types/struct_iovec.h" 2 3 4


struct iovec
  {
    void *iov_base;
    size_t iov_len;
  };
# 27 "/usr/include/x86_64-linux-gnu/sys/socket.h" 2 3 4

# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 29 "/usr/include/x86_64-linux-gnu/sys/socket.h" 2 3 4




# 1 "/usr/include/x86_64-linux-gnu/bits/socket.h" 1 3 4
# 27 "/usr/include/x86_64-linux-gnu/bits/socket.h" 3 4
# 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4
# 28 "/usr/include/x86_64-linux-gnu/bits/socket.h" 2 3 4
# 38 "/usr/include/x86_64-linux-gnu/bits/socket.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/socket_type.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/bits/socket_type.h" 3 4
enum __socket_type
{
  SOCK_STREAM = 1,


  SOCK_DGRAM = 2,


  SOCK_RAW = 3,

  SOCK_RDM = 4,

  SOCK_SEQPACKET = 5,


  SOCK_DCCP = 6,

  SOCK_PACKET = 10,







  SOCK_CLOEXEC = 02000000,


  SOCK_NONBLOCK = 00004000


};
# 39 "/usr/include/x86_64-linux-gnu/bits/socket.h" 2 3 4
# 172 "/usr/include/x86_64-linux-gnu/bits/socket.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/sockaddr.h" 1 3 4
# 28 "/usr/include/x86_64-linux-gnu/bits/sockaddr.h" 3 4
typedef unsigned short int sa_family_t;
# 173 "/usr/include/x86_64-linux-gnu/bits/socket.h" 2 3 4


struct sockaddr
  {
    sa_family_t sa_family;
    char sa_data[14];
  };
# 188 "/usr/include/x86_64-linux-gnu/bits/socket.h" 3 4
struct sockaddr_storage
  {
    sa_family_t ss_family;
    char __ss_padding[(128 - (sizeof (unsigned short int)) - sizeof (unsigned long int))];
    unsigned long int __ss_align;
  };



enum
  {
    MSG_OOB = 0x01,

    MSG_PEEK = 0x02,

    MSG_DONTROUTE = 0x04,






    MSG_CTRUNC = 0x08,

    MSG_PROXY = 0x10,

    MSG_TRUNC = 0x20,

    MSG_DONTWAIT = 0x40,

    MSG_EOR = 0x80,

    MSG_WAITALL = 0x100,

    MSG_FIN = 0x200,

    MSG_SYN = 0x400,

    MSG_CONFIRM = 0x800,

    MSG_RST = 0x1000,

    MSG_ERRQUEUE = 0x2000,

    MSG_NOSIGNAL = 0x4000,

    MSG_MORE = 0x8000,

    MSG_WAITFORONE = 0x10000,

    MSG_BATCH = 0x40000,

    MSG_ZEROCOPY = 0x4000000,

    MSG_FASTOPEN = 0x20000000,


    MSG_CMSG_CLOEXEC = 0x40000000



  };




struct msghdr
  {
    void *msg_name;
    socklen_t msg_namelen;

    struct iovec *msg_iov;
    size_t msg_iovlen;

    void *msg_control;
    size_t msg_controllen;




    int msg_flags;
  };


struct cmsghdr
  {
    size_t cmsg_len;




    int cmsg_level;
    int cmsg_type;

    __extension__ unsigned char __cmsg_data [];

  };
# 302 "/usr/include/x86_64-linux-gnu/bits/socket.h" 3 4
extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
          struct cmsghdr *__cmsg) __attribute__ ((__nothrow__ , __leaf__));
# 329 "/usr/include/x86_64-linux-gnu/bits/socket.h" 3 4
enum
  {
    SCM_RIGHTS = 0x01





  };
# 390 "/usr/include/x86_64-linux-gnu/bits/socket.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/asm/socket.h" 1 3 4
# 1 "/usr/include/asm-generic/socket.h" 1 3 4




# 1 "/usr/include/x86_64-linux-gnu/asm/sockios.h" 1 3 4
# 1 "/usr/include/asm-generic/sockios.h" 1 3 4
# 1 "/usr/include/x86_64-linux-gnu/asm/sockios.h" 2 3 4
# 6 "/usr/include/asm-generic/socket.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/asm/socket.h" 2 3 4
# 391 "/usr/include/x86_64-linux-gnu/bits/socket.h" 2 3 4
# 444 "/usr/include/x86_64-linux-gnu/bits/socket.h" 3 4
struct linger
  {
    int l_onoff;
    int l_linger;
  };
# 34 "/usr/include/x86_64-linux-gnu/sys/socket.h" 2 3 4


# 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_osockaddr.h" 1 3 4





struct osockaddr
{
  unsigned short int sa_family;
  unsigned char sa_data[14];
};
# 37 "/usr/include/x86_64-linux-gnu/sys/socket.h" 2 3 4




enum
{
  SHUT_RD = 0,

  SHUT_WR,

  SHUT_RDWR

};
# 102 "/usr/include/x86_64-linux-gnu/sys/socket.h" 3 4
extern int socket (int __domain, int __type, int __protocol) __attribute__ ((__nothrow__ , __leaf__));





extern int socketpair (int __domain, int __type, int __protocol,
         int __fds[2]) __attribute__ ((__nothrow__ , __leaf__));


extern int bind (int __fd, const struct sockaddr * __addr, socklen_t __len)
     __attribute__ ((__nothrow__ , __leaf__));


extern int getsockname (int __fd, struct sockaddr *__restrict __addr,
   socklen_t *__restrict __len) __attribute__ ((__nothrow__ , __leaf__));
# 126 "/usr/include/x86_64-linux-gnu/sys/socket.h" 3 4
extern int connect (int __fd, const struct sockaddr * __addr, socklen_t __len);



extern int getpeername (int __fd, struct sockaddr *__restrict __addr,
   socklen_t *__restrict __len) __attribute__ ((__nothrow__ , __leaf__));






extern ssize_t send (int __fd, const void *__buf, size_t __n, int __flags);






extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags);






extern ssize_t sendto (int __fd, const void *__buf, size_t __n,
         int __flags, const struct sockaddr * __addr,
         socklen_t __addr_len);
# 163 "/usr/include/x86_64-linux-gnu/sys/socket.h" 3 4
extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n,
    int __flags, struct sockaddr *__restrict __addr,
    socklen_t *__restrict __addr_len);







extern ssize_t sendmsg (int __fd, const struct msghdr *__message,
   int __flags);
# 191 "/usr/include/x86_64-linux-gnu/sys/socket.h" 3 4
extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags);
# 208 "/usr/include/x86_64-linux-gnu/sys/socket.h" 3 4
extern int getsockopt (int __fd, int __level, int __optname,
         void *__restrict __optval,
         socklen_t *__restrict __optlen) __attribute__ ((__nothrow__ , __leaf__));




extern int setsockopt (int __fd, int __level, int __optname,
         const void *__optval, socklen_t __optlen) __attribute__ ((__nothrow__ , __leaf__));





extern int listen (int __fd, int __n) __attribute__ ((__nothrow__ , __leaf__));
# 232 "/usr/include/x86_64-linux-gnu/sys/socket.h" 3 4
extern int accept (int __fd, struct sockaddr *__restrict __addr,
     socklen_t *__restrict __addr_len);
# 250 "/usr/include/x86_64-linux-gnu/sys/socket.h" 3 4
extern int shutdown (int __fd, int __how) __attribute__ ((__nothrow__ , __leaf__));




extern int sockatmark (int __fd) __attribute__ ((__nothrow__ , __leaf__));







extern int isfdtype (int __fd, int __fdtype) __attribute__ ((__nothrow__ , __leaf__));
# 272 "/usr/include/x86_64-linux-gnu/sys/socket.h" 3 4

# 24 "/usr/include/netinet/in.h" 2 3 4






typedef uint32_t in_addr_t;
struct in_addr
  {
    in_addr_t s_addr;
  };


# 1 "/usr/include/x86_64-linux-gnu/bits/in.h" 1 3 4
# 142 "/usr/include/x86_64-linux-gnu/bits/in.h" 3 4
struct ip_opts
  {
    struct in_addr ip_dst;
    char ip_opts[40];
  };


struct ip_mreqn
  {
    struct in_addr imr_multiaddr;
    struct in_addr imr_address;
    int imr_ifindex;
  };


struct in_pktinfo
  {
    int ipi_ifindex;
    struct in_addr ipi_spec_dst;
    struct in_addr ipi_addr;
  };
# 38 "/usr/include/netinet/in.h" 2 3 4


enum
  {
    IPPROTO_IP = 0,

    IPPROTO_ICMP = 1,

    IPPROTO_IGMP = 2,

    IPPROTO_IPIP = 4,

    IPPROTO_TCP = 6,

    IPPROTO_EGP = 8,

    IPPROTO_PUP = 12,

    IPPROTO_UDP = 17,

    IPPROTO_IDP = 22,

    IPPROTO_TP = 29,

    IPPROTO_DCCP = 33,

    IPPROTO_IPV6 = 41,

    IPPROTO_RSVP = 46,

    IPPROTO_GRE = 47,

    IPPROTO_ESP = 50,

    IPPROTO_AH = 51,

    IPPROTO_MTP = 92,

    IPPROTO_BEETPH = 94,

    IPPROTO_ENCAP = 98,

    IPPROTO_PIM = 103,

    IPPROTO_COMP = 108,

    IPPROTO_SCTP = 132,

    IPPROTO_UDPLITE = 136,

    IPPROTO_MPLS = 137,

    IPPROTO_RAW = 255,

    IPPROTO_MAX
  };





enum
  {
    IPPROTO_HOPOPTS = 0,

    IPPROTO_ROUTING = 43,

    IPPROTO_FRAGMENT = 44,

    IPPROTO_ICMPV6 = 58,

    IPPROTO_NONE = 59,

    IPPROTO_DSTOPTS = 60,

    IPPROTO_MH = 135

  };



typedef uint16_t in_port_t;


enum
  {
    IPPORT_ECHO = 7,
    IPPORT_DISCARD = 9,
    IPPORT_SYSTAT = 11,
    IPPORT_DAYTIME = 13,
    IPPORT_NETSTAT = 15,
    IPPORT_FTP = 21,
    IPPORT_TELNET = 23,
    IPPORT_SMTP = 25,
    IPPORT_TIMESERVER = 37,
    IPPORT_NAMESERVER = 42,
    IPPORT_WHOIS = 43,
    IPPORT_MTP = 57,

    IPPORT_TFTP = 69,
    IPPORT_RJE = 77,
    IPPORT_FINGER = 79,
    IPPORT_TTYLINK = 87,
    IPPORT_SUPDUP = 95,


    IPPORT_EXECSERVER = 512,
    IPPORT_LOGINSERVER = 513,
    IPPORT_CMDSERVER = 514,
    IPPORT_EFSSERVER = 520,


    IPPORT_BIFFUDP = 512,
    IPPORT_WHOSERVER = 513,
    IPPORT_ROUTESERVER = 520,


    IPPORT_RESERVED = 1024,


    IPPORT_USERRESERVED = 5000
  };
# 211 "/usr/include/netinet/in.h" 3 4
struct in6_addr
  {
    union
      {
 uint8_t __u6_addr8[16];
 uint16_t __u6_addr16[8];
 uint32_t __u6_addr32[4];
      } __in6_u;





  };


extern const struct in6_addr in6addr_any;
extern const struct in6_addr in6addr_loopback;
# 237 "/usr/include/netinet/in.h" 3 4
struct sockaddr_in
  {
    sa_family_t sin_family;
    in_port_t sin_port;
    struct in_addr sin_addr;


    unsigned char sin_zero[sizeof (struct sockaddr) -
      (sizeof (unsigned short int)) -
      sizeof (in_port_t) -
      sizeof (struct in_addr)];
  };



struct sockaddr_in6
  {
    sa_family_t sin6_family;
    in_port_t sin6_port;
    uint32_t sin6_flowinfo;
    struct in6_addr sin6_addr;
    uint32_t sin6_scope_id;
  };




struct ip_mreq
  {

    struct in_addr imr_multiaddr;


    struct in_addr imr_interface;
  };

struct ip_mreq_source
  {

    struct in_addr imr_multiaddr;


    struct in_addr imr_interface;


    struct in_addr imr_sourceaddr;
  };




struct ipv6_mreq
  {

    struct in6_addr ipv6mr_multiaddr;


    unsigned int ipv6mr_interface;
  };




struct group_req
  {

    uint32_t gr_interface;


    struct sockaddr_storage gr_group;
  };

struct group_source_req
  {

    uint32_t gsr_interface;


    struct sockaddr_storage gsr_group;


    struct sockaddr_storage gsr_source;
  };



struct ip_msfilter
  {

    struct in_addr imsf_multiaddr;


    struct in_addr imsf_interface;


    uint32_t imsf_fmode;


    uint32_t imsf_numsrc;

    struct in_addr imsf_slist[1];
  };





struct group_filter
  {

    uint32_t gf_interface;


    struct sockaddr_storage gf_group;


    uint32_t gf_fmode;


    uint32_t gf_numsrc;

    struct sockaddr_storage gf_slist[1];
};
# 374 "/usr/include/netinet/in.h" 3 4
extern uint32_t ntohl (uint32_t __netlong) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern uint16_t ntohs (uint16_t __netshort)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern uint32_t htonl (uint32_t __hostlong)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern uint16_t htons (uint16_t __hostshort)
     __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));




# 1 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 1 3 4
# 386 "/usr/include/netinet/in.h" 2 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/uintn-identity.h" 1 3 4
# 387 "/usr/include/netinet/in.h" 2 3 4
# 502 "/usr/include/netinet/in.h" 3 4
extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __attribute__ ((__nothrow__ , __leaf__));


extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in)
     __attribute__ ((__nothrow__ , __leaf__));
# 630 "/usr/include/netinet/in.h" 3 4

# 23 "/usr/include/arpa/inet.h" 2 3 4











extern in_addr_t inet_addr (const char *__cp) __attribute__ ((__nothrow__ , __leaf__));


extern in_addr_t inet_lnaof (struct in_addr __in) __attribute__ ((__nothrow__ , __leaf__));



extern struct in_addr inet_makeaddr (in_addr_t __net, in_addr_t __host)
     __attribute__ ((__nothrow__ , __leaf__));


extern in_addr_t inet_netof (struct in_addr __in) __attribute__ ((__nothrow__ , __leaf__));



extern in_addr_t inet_network (const char *__cp) __attribute__ ((__nothrow__ , __leaf__));



extern char *inet_ntoa (struct in_addr __in) __attribute__ ((__nothrow__ , __leaf__));




extern int inet_pton (int __af, const char *__restrict __cp,
        void *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));




extern const char *inet_ntop (int __af, const void *__restrict __cp,
         char *__restrict __buf, socklen_t __len)
     __attribute__ ((__nothrow__ , __leaf__));






extern int inet_aton (const char *__cp, struct in_addr *__inp) __attribute__ ((__nothrow__ , __leaf__));



extern char *inet_neta (in_addr_t __net, char *__buf, size_t __len) __attribute__ ((__nothrow__ , __leaf__));




extern char *inet_net_ntop (int __af, const void *__cp, int __bits,
       char *__buf, size_t __len) __attribute__ ((__nothrow__ , __leaf__));




extern int inet_net_pton (int __af, const char *__cp,
     void *__buf, size_t __len) __attribute__ ((__nothrow__ , __leaf__));




extern unsigned int inet_nsap_addr (const char *__cp,
        unsigned char *__buf, int __len) __attribute__ ((__nothrow__ , __leaf__));



extern char *inet_nsap_ntoa (int __len, const unsigned char *__cp,
        char *__buf) __attribute__ ((__nothrow__ , __leaf__));



# 44 "afl-fuzz-single.c" 2
# 1 "/usr/include/x86_64-linux-gnu/sys/resource.h" 1 3 4
# 24 "/usr/include/x86_64-linux-gnu/sys/resource.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/resource.h" 1 3 4
# 31 "/usr/include/x86_64-linux-gnu/bits/resource.h" 3 4
enum __rlimit_resource
{

  RLIMIT_CPU = 0,



  RLIMIT_FSIZE = 1,



  RLIMIT_DATA = 2,



  RLIMIT_STACK = 3,



  RLIMIT_CORE = 4,






  __RLIMIT_RSS = 5,



  RLIMIT_NOFILE = 7,
  __RLIMIT_OFILE = RLIMIT_NOFILE,




  RLIMIT_AS = 9,



  __RLIMIT_NPROC = 6,



  __RLIMIT_MEMLOCK = 8,



  __RLIMIT_LOCKS = 10,



  __RLIMIT_SIGPENDING = 11,



  __RLIMIT_MSGQUEUE = 12,





  __RLIMIT_NICE = 13,




  __RLIMIT_RTPRIO = 14,





  __RLIMIT_RTTIME = 15,


  __RLIMIT_NLIMITS = 16,
  __RLIM_NLIMITS = __RLIMIT_NLIMITS


};
# 131 "/usr/include/x86_64-linux-gnu/bits/resource.h" 3 4
typedef __rlim_t rlim_t;







struct rlimit
  {

    rlim_t rlim_cur;

    rlim_t rlim_max;
  };
# 158 "/usr/include/x86_64-linux-gnu/bits/resource.h" 3 4
enum __rusage_who
{

  RUSAGE_SELF = 0,



  RUSAGE_CHILDREN = -1
# 176 "/usr/include/x86_64-linux-gnu/bits/resource.h" 3 4
};


# 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_rusage.h" 1 3 4
# 31 "/usr/include/x86_64-linux-gnu/bits/types/struct_rusage.h" 3 4
struct rusage
  {

    struct timeval ru_utime;

    struct timeval ru_stime;

    __extension__ union
      {
 long int ru_maxrss;
 __syscall_slong_t __ru_maxrss_word;
      };



    __extension__ union
      {
 long int ru_ixrss;
 __syscall_slong_t __ru_ixrss_word;
      };

    __extension__ union
      {
 long int ru_idrss;
 __syscall_slong_t __ru_idrss_word;
      };

    __extension__ union
      {
 long int ru_isrss;
  __syscall_slong_t __ru_isrss_word;
      };


    __extension__ union
      {
 long int ru_minflt;
 __syscall_slong_t __ru_minflt_word;
      };

    __extension__ union
      {
 long int ru_majflt;
 __syscall_slong_t __ru_majflt_word;
      };

    __extension__ union
      {
 long int ru_nswap;
 __syscall_slong_t __ru_nswap_word;
      };


    __extension__ union
      {
 long int ru_inblock;
 __syscall_slong_t __ru_inblock_word;
      };

    __extension__ union
      {
 long int ru_oublock;
 __syscall_slong_t __ru_oublock_word;
      };

    __extension__ union
      {
 long int ru_msgsnd;
 __syscall_slong_t __ru_msgsnd_word;
      };

    __extension__ union
      {
 long int ru_msgrcv;
 __syscall_slong_t __ru_msgrcv_word;
      };

    __extension__ union
      {
 long int ru_nsignals;
 __syscall_slong_t __ru_nsignals_word;
      };



    __extension__ union
      {
 long int ru_nvcsw;
 __syscall_slong_t __ru_nvcsw_word;
      };


    __extension__ union
      {
 long int ru_nivcsw;
 __syscall_slong_t __ru_nivcsw_word;
      };
  };
# 180 "/usr/include/x86_64-linux-gnu/bits/resource.h" 2 3 4







enum __priority_which
{
  PRIO_PROCESS = 0,

  PRIO_PGRP = 1,

  PRIO_USER = 2

};



# 223 "/usr/include/x86_64-linux-gnu/bits/resource.h" 3 4

# 25 "/usr/include/x86_64-linux-gnu/sys/resource.h" 2 3 4







# 42 "/usr/include/x86_64-linux-gnu/sys/resource.h" 3 4
typedef int __rlimit_resource_t;
typedef int __rusage_who_t;
typedef int __priority_which_t;





extern int getrlimit (__rlimit_resource_t __resource,
        struct rlimit *__rlimits) __attribute__ ((__nothrow__ , __leaf__));
# 69 "/usr/include/x86_64-linux-gnu/sys/resource.h" 3 4
extern int setrlimit (__rlimit_resource_t __resource,
        const struct rlimit *__rlimits) __attribute__ ((__nothrow__ , __leaf__));
# 87 "/usr/include/x86_64-linux-gnu/sys/resource.h" 3 4
extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __attribute__ ((__nothrow__ , __leaf__));





extern int getpriority (__priority_which_t __which, id_t __who) __attribute__ ((__nothrow__ , __leaf__));



extern int setpriority (__priority_which_t __which, id_t __who, int __prio)
     __attribute__ ((__nothrow__ , __leaf__));


# 45 "afl-fuzz-single.c" 2



# 47 "afl-fuzz-single.c"
static u8 *in_dir,
          *out_file,
          *out_dir;

static u32 exec_tmout = 4000,
           mem_limit = 100;

static u8 keep_testcases,
           skip_deterministic,
           dumb_mode,
           kill_signal;

static s32 out_fd,
           dev_null;

static s32 child_pid;

static u8* trace_bits;
static u8 virgin_bits[65536];

static s32 shm_id;

static volatile u8 stop_soon,
                   clear_screen,
                   child_timed_out;

static u64 unique_queued,
           unique_processed,
           total_crashes,
           total_hangs,
           queued_later,
           abandoned_inputs,
           total_execs,
           start_time,
           queue_cycle;

static u32 queue_len;
static u32 subseq_hangs;

static u8* stage_name;
static s32 stage_cur, stage_max;

static u64 stage_finds[10],
           stage_cycles[10];


struct queue_entry {
  u8* fname;
  u32 len;
  u8 keep;
  u8 det_done;
  struct queue_entry* next;
};

static struct queue_entry *queue,
                          *queue_cur,
                          *queue_top;




static u8 interesting_8[] = { -128, -1, 0, 1, 16, 32, 64, 100, 127 };
static u16 interesting_16[] = { -128, -1, 0, 1, 16, 32, 64, 100, 127, -32768, -129, 128, 255, 256, 512, 1000, 1024, 4096, 32767 };
static u32 interesting_32[] = { -128, -1, 0, 1, 16, 32, 64, 100, 127, -32768, -129, 128, 255, 256, 512, 1000, 1024, 4096, 32767, -2147483648LL, -100000000, -32769, 32768, 65535, 65536, 100000000, 2147483647 };




static void add_to_queue(u8* fname, u32 len, u8 keep) {

  struct queue_entry* q = DFL_ck_alloc(sizeof(struct queue_entry));

  q->fname = fname;
  q->len = len;
  q->keep = keep;

  if (queue_top) {

    queue_top->next = q;
    queue_top = q;

  } else queue = queue_top = q;

  queue_len++;
  unique_queued++;

  if (queue_cycle > 1) queued_later++;

}




static void destroy_queue(void) {

  struct queue_entry *q = queue, *n;

  while (q) {

    n = q->next;

    if (!q->keep && !keep_testcases)
      unlink(q->fname);

    DFL_ck_free(q->fname);
    DFL_ck_free(q);
    q = n;

  }

}





static inline u8 has_new_bits(void) {

  u32* current = (u32*)trace_bits;
  u32* virgin = (u32*)virgin_bits;

  u32 i = (65536 >> 2);
  u8 ret = 0;

  while (i--) {

    if (*current & *virgin) {
      *virgin &= ~*current;
      ret = 1;
    }

    current++;
    virgin++;

  }

  return ret;

}




static inline u32 count_bits(u8* mem) {

  u32* ptr = (u32*)mem;
  u32 i = (65536 >> 2);
  u32 ret = 0;

  while (i--) {

    u32 v = *(ptr++);

    v -= ((v >> 1) & 0x55555555);
    v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
    ret += (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;

  }

  return ret;

}




static void remove_shm(void) {
  shmctl(shm_id, 
# 214 "afl-fuzz-single.c" 3 4
                0
# 214 "afl-fuzz-single.c"
                        , 
# 214 "afl-fuzz-single.c" 3 4
                          ((void *)0)
# 214 "afl-fuzz-single.c"
                              );
}




static void setup_shm(void) {

  u8* shm_str;

  memset(virgin_bits, 255, 65536);

  shm_id = shmget(
# 226 "afl-fuzz-single.c" 3 4
                 ((__key_t) 0)
# 226 "afl-fuzz-single.c"
                            , 65536, 
# 226 "afl-fuzz-single.c" 3 4
                                     01000 
# 226 "afl-fuzz-single.c"
                                               | 
# 226 "afl-fuzz-single.c" 3 4
                                                 02000 
# 226 "afl-fuzz-single.c"
                                                          | 0600);

  if (shm_id < 0) do { fprintf(
# 228 "afl-fuzz-single.c" 3 4
                 stderr
# 228 "afl-fuzz-single.c"
                 , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "shmget() failed"); fprintf(
# 228 "afl-fuzz-single.c" 3 4
                 stderr
# 228 "afl-fuzz-single.c"
                 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 228); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 228 "afl-fuzz-single.c" 3 4
                 stderr
# 228 "afl-fuzz-single.c"
                 , "\x1b[0m" "\n"); exit(1); } while (0);

  atexit(remove_shm);

  shm_str = ({ u8* _tmp; s32 _len = snprintf(
# 232 "afl-fuzz-single.c" 3 4
           ((void *)0)
# 232 "afl-fuzz-single.c"
           , 0, "%d", shm_id); if (_len < 0) do { fprintf(
# 232 "afl-fuzz-single.c" 3 4
           stderr
# 232 "afl-fuzz-single.c"
           , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Whoa, snprintf() fails?!"); fprintf(
# 232 "afl-fuzz-single.c" 3 4
           stderr
# 232 "afl-fuzz-single.c"
           , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 232); exit(1); } while (0); _tmp = DFL_ck_alloc(_len + 1); snprintf((char*)_tmp, _len + 1, "%d", shm_id); _tmp; });

  setenv("__AFL_SHM_ID", shm_str, 1);

  DFL_ck_free(shm_str);

  trace_bits = shmat(shm_id, 
# 238 "afl-fuzz-single.c" 3 4
                            ((void *)0)
# 238 "afl-fuzz-single.c"
                                , 0);

  if (!trace_bits) do { fprintf(
# 240 "afl-fuzz-single.c" 3 4
                  stderr
# 240 "afl-fuzz-single.c"
                  , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "shmat() failed"); fprintf(
# 240 "afl-fuzz-single.c" 3 4
                  stderr
# 240 "afl-fuzz-single.c"
                  , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 240); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 240 "afl-fuzz-single.c" 3 4
                  stderr
# 240 "afl-fuzz-single.c"
                  , "\x1b[0m" "\n"); exit(1); } while (0);

}




static void read_testcases(void) {

  DIR* d = opendir(in_dir);
  struct dirent* de;

  if (!d) do { fprintf(
# 252 "afl-fuzz-single.c" 3 4
         stderr
# 252 "afl-fuzz-single.c"
         , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to open '%s'", in_dir); fprintf(
# 252 "afl-fuzz-single.c" 3 4
         stderr
# 252 "afl-fuzz-single.c"
         , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 252); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 252 "afl-fuzz-single.c" 3 4
         stderr
# 252 "afl-fuzz-single.c"
         , "\x1b[0m" "\n"); exit(1); } while (0);

  while ((de = readdir(d))) {

    struct stat st;
    u8* fn = ({ u8* _tmp; s32 _len = snprintf(
# 257 "afl-fuzz-single.c" 3 4
            ((void *)0)
# 257 "afl-fuzz-single.c"
            , 0, "%s/%s", in_dir, de->d_name); if (_len < 0) do { fprintf(
# 257 "afl-fuzz-single.c" 3 4
            stderr
# 257 "afl-fuzz-single.c"
            , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Whoa, snprintf() fails?!"); fprintf(
# 257 "afl-fuzz-single.c" 3 4
            stderr
# 257 "afl-fuzz-single.c"
            , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 257); exit(1); } while (0); _tmp = DFL_ck_alloc(_len + 1); snprintf((char*)_tmp, _len + 1, "%s/%s", in_dir, de->d_name); _tmp; });

    if (stat(fn, &st) || access(fn, 
# 259 "afl-fuzz-single.c" 3 4
                                   4
# 259 "afl-fuzz-single.c"
                                       ))
      do { fprintf(
# 260 "afl-fuzz-single.c" 3 4
     stderr
# 260 "afl-fuzz-single.c"
     , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to access '%s'", fn); fprintf(
# 260 "afl-fuzz-single.c" 3 4
     stderr
# 260 "afl-fuzz-single.c"
     , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 260); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 260 "afl-fuzz-single.c" 3 4
     stderr
# 260 "afl-fuzz-single.c"
     , "\x1b[0m" "\n"); exit(1); } while (0);

    if (!
# 262 "afl-fuzz-single.c" 3 4
        ((((
# 262 "afl-fuzz-single.c"
        st.st_mode
# 262 "afl-fuzz-single.c" 3 4
        )) & 0170000) == (0100000)) 
# 262 "afl-fuzz-single.c"
                            || !st.st_size) {

      DFL_ck_free(fn);
      continue;

    }

    if (st.st_size > (1 * 1000 * 1000))
      do { fprintf(
# 270 "afl-fuzz-single.c" 3 4
     stderr
# 270 "afl-fuzz-single.c"
     , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Test case '%s' is too big", fn); fprintf(
# 270 "afl-fuzz-single.c" 3 4
     stderr
# 270 "afl-fuzz-single.c"
     , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 270); exit(1); } while (0);

    add_to_queue(fn, st.st_size, 1);

  }

  if (!unique_queued) do { fprintf(
# 276 "afl-fuzz-single.c" 3 4
                     stderr
# 276 "afl-fuzz-single.c"
                     , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "No usable test cases in '%s'", in_dir); fprintf(
# 276 "afl-fuzz-single.c" 3 4
                     stderr
# 276 "afl-fuzz-single.c"
                     , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 276); exit(1); } while (0);

}
# 289 "afl-fuzz-single.c"
static u8 run_target(char** argv) {

  static struct itimerval it;
  int status;

  child_timed_out = 0;

  memset(trace_bits, 0, 65536);

  child_pid = fork();

  if (child_pid < 0) do { fprintf(
# 300 "afl-fuzz-single.c" 3 4
                    stderr
# 300 "afl-fuzz-single.c"
                    , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "fork() failed"); fprintf(
# 300 "afl-fuzz-single.c" 3 4
                    stderr
# 300 "afl-fuzz-single.c"
                    , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 300); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 300 "afl-fuzz-single.c" 3 4
                    stderr
# 300 "afl-fuzz-single.c"
                    , "\x1b[0m" "\n"); exit(1); } while (0);

  if (!child_pid) {

    struct rlimit r;

    r.rlim_max = r.rlim_cur = ((rlim_t)mem_limit) << 20;

    setrlimit(
# 308 "afl-fuzz-single.c" 3 4
             RLIMIT_AS
# 308 "afl-fuzz-single.c"
                      , &r);




    setsid();

    dup2(dev_null, 1);
    dup2(dev_null, 2);

    if (out_file) {

      dup2(dev_null, 0);

    } else {

      dup2(out_fd, 0);
      close(out_fd);

    }

    close(dev_null);

    execvp(argv[0], argv);




    exit(0x55);

  }



  it.it_value.tv_sec = (exec_tmout / 1000);
  it.it_value.tv_usec = (exec_tmout % 1000) * 1000;

  setitimer(
# 345 "afl-fuzz-single.c" 3 4
           ITIMER_REAL
# 345 "afl-fuzz-single.c"
                      , &it, 
# 345 "afl-fuzz-single.c" 3 4
                             ((void *)0)
# 345 "afl-fuzz-single.c"
                                 );

  if (waitpid(child_pid, &status, 
# 347 "afl-fuzz-single.c" 3 4
                                 2
# 347 "afl-fuzz-single.c"
                                          ) <= 0) do { fprintf(
# 347 "afl-fuzz-single.c" 3 4
                                                  stderr
# 347 "afl-fuzz-single.c"
                                                  , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "waitpid() failed"); fprintf(
# 347 "afl-fuzz-single.c" 3 4
                                                  stderr
# 347 "afl-fuzz-single.c"
                                                  , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 347); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 347 "afl-fuzz-single.c" 3 4
                                                  stderr
# 347 "afl-fuzz-single.c"
                                                  , "\x1b[0m" "\n"); exit(1); } while (0);

  child_pid = 0;
  it.it_value.tv_sec = 0;
  it.it_value.tv_usec = 0;

  setitimer(
# 353 "afl-fuzz-single.c" 3 4
           ITIMER_REAL
# 353 "afl-fuzz-single.c"
                      , &it, 
# 353 "afl-fuzz-single.c" 3 4
                             ((void *)0)
# 353 "afl-fuzz-single.c"
                                 );

  total_execs++;



  if (child_timed_out) return 1;

  if (
# 361 "afl-fuzz-single.c" 3 4
     (((signed char) (((
# 361 "afl-fuzz-single.c"
     status
# 361 "afl-fuzz-single.c" 3 4
     ) & 0x7f) + 1) >> 1) > 0) 
# 361 "afl-fuzz-single.c"
                         && !stop_soon) {
    kill_signal = 
# 362 "afl-fuzz-single.c" 3 4
                 ((
# 362 "afl-fuzz-single.c"
                 status
# 362 "afl-fuzz-single.c" 3 4
                 ) & 0x7f)
# 362 "afl-fuzz-single.c"
                                 ;
    return 2;
  }

  if (
# 366 "afl-fuzz-single.c" 3 4
     (((
# 366 "afl-fuzz-single.c"
     status
# 366 "afl-fuzz-single.c" 3 4
     ) & 0xff00) >> 8) 
# 366 "afl-fuzz-single.c"
                         == 0x55) return 3;

  return 0;

}





static void perform_dry_run(char** argv) {

  struct queue_entry* q = queue;

  while (q) {

    u8 fault;
    u32 i;

    do { fprintf(
# 385 "afl-fuzz-single.c" 3 4
   stderr
# 385 "afl-fuzz-single.c"
   , "\x1b[1;34m" "[*] " "\x1b[0;37m" "Verifying test case '%s'...", q->fname); fprintf(
# 385 "afl-fuzz-single.c" 3 4
   stderr
# 385 "afl-fuzz-single.c"
   , "\x1b[0m" "\n"); } while (0);

    if (!out_file) {

      out_fd = open(q->fname, 
# 389 "afl-fuzz-single.c" 3 4
                             00
# 389 "afl-fuzz-single.c"
                                     );
      if (out_fd < 0) do { fprintf(
# 390 "afl-fuzz-single.c" 3 4
                     stderr
# 390 "afl-fuzz-single.c"
                     , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to open '%s'", q->fname); fprintf(
# 390 "afl-fuzz-single.c" 3 4
                     stderr
# 390 "afl-fuzz-single.c"
                     , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 390); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 390 "afl-fuzz-single.c" 3 4
                     stderr
# 390 "afl-fuzz-single.c"
                     , "\x1b[0m" "\n"); exit(1); } while (0);

    } else {

      unlink(out_file);
      if (link(q->fname, out_file)) do { fprintf(
# 395 "afl-fuzz-single.c" 3 4
                                   stderr
# 395 "afl-fuzz-single.c"
                                   , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "link() failed"); fprintf(
# 395 "afl-fuzz-single.c" 3 4
                                   stderr
# 395 "afl-fuzz-single.c"
                                   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 395); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 395 "afl-fuzz-single.c" 3 4
                                   stderr
# 395 "afl-fuzz-single.c"
                                   , "\x1b[0m" "\n"); exit(1); } while (0);

    }

    fault = run_target(argv);
    if (stop_soon) return;

    switch (fault) {

      case 1: do { fprintf(
# 404 "afl-fuzz-single.c" 3 4
                       stderr
# 404 "afl-fuzz-single.c"
                       , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Test case '%s' results in a hang (adjusting -t " "may help)", q->fname); fprintf(
# 404 "afl-fuzz-single.c" 3 4
                       stderr
# 404 "afl-fuzz-single.c"
                       , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 405); exit(1); } while (0)
                                                    ;

      case 2: do { fprintf(
# 407 "afl-fuzz-single.c" 3 4
                       stderr
# 407 "afl-fuzz-single.c"
                       , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Test case '%s' results in a crash", q->fname); fprintf(
# 407 "afl-fuzz-single.c" 3 4
                       stderr
# 407 "afl-fuzz-single.c"
                       , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 407); exit(1); } while (0);

      case 3: do { fprintf(
# 409 "afl-fuzz-single.c" 3 4
                       stderr
# 409 "afl-fuzz-single.c"
                       , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Unable to execute target application ('%s')", argv[0]); fprintf(
# 409 "afl-fuzz-single.c" 3 4
                       stderr
# 409 "afl-fuzz-single.c"
                       , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 410); exit(1); } while (0)
                                      ;

    }

    if (!has_new_bits() && !dumb_mode)
      do { fprintf(
# 415 "afl-fuzz-single.c" 3 4
     stderr
# 415 "afl-fuzz-single.c"
     , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "No instrumentation detected (you can always try -n)"); fprintf(
# 415 "afl-fuzz-single.c" 3 4
     stderr
# 415 "afl-fuzz-single.c"
     , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 415); exit(1); } while (0);



    for (i = 0; (i < 15) && !stop_soon; i++) usleep(100000);
    if (stop_soon) return;

    for (i = 0; i < 4; i++) {

      if (!out_file) lseek(out_fd, 0, 
# 424 "afl-fuzz-single.c" 3 4
                                     0
# 424 "afl-fuzz-single.c"
                                             );
      fault = run_target(argv);

      if (stop_soon) return;

      switch (fault) {

        case 1: do { fprintf(
# 431 "afl-fuzz-single.c" 3 4
                         stderr
# 431 "afl-fuzz-single.c"
                         , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Test case '%s' results in intermittent hangs " "(adjusting -t may help)", q->fname); fprintf(
# 431 "afl-fuzz-single.c" 3 4
                         stderr
# 431 "afl-fuzz-single.c"
                         , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 432); exit(1); } while (0)
                                                                    ;

        case 2: do { fprintf(
# 434 "afl-fuzz-single.c" 3 4
                         stderr
# 434 "afl-fuzz-single.c"
                         , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Test case '%s' results in intermittent " "crashes", q->fname); fprintf(
# 434 "afl-fuzz-single.c" 3 4
                         stderr
# 434 "afl-fuzz-single.c"
                         , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 435); exit(1); } while (0)
                                                    ;

        case 3: do { fprintf(
# 437 "afl-fuzz-single.c" 3 4
                         stderr
# 437 "afl-fuzz-single.c"
                         , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Unable to execute target application (huh)"); fprintf(
# 437 "afl-fuzz-single.c" 3 4
                         stderr
# 437 "afl-fuzz-single.c"
                         , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 437); exit(1); } while (0);

      }

      if (has_new_bits())
        do { fprintf(
# 442 "afl-fuzz-single.c" 3 4
       stderr
# 442 "afl-fuzz-single.c"
       , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Inconsistent instrumentation output for test case '%s'", q->fname); fprintf(
# 442 "afl-fuzz-single.c" 3 4
       stderr
# 442 "afl-fuzz-single.c"
       , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 443); exit(1); } while (0)
                       ;

    }

    if (!out_file) close(out_fd);

    do { fprintf(
# 449 "afl-fuzz-single.c" 3 4
   stderr
# 449 "afl-fuzz-single.c"
   , "\x1b[1;32m" "[+] " "\x1b[0;37m" "Done: %u bits set, %u remaining in the bitmap.\n", count_bits(trace_bits), count_bits(virgin_bits)); fprintf(
# 449 "afl-fuzz-single.c" 3 4
   stderr
# 449 "afl-fuzz-single.c"
   , "\x1b[0m" "\n"); } while (0)
                                                         ;

    q = q->next;

  }

}






static void write_to_testcase(void* mem, u32 len) {

  s32 fd = out_fd;

  if (out_file) {

    unlink(out_file);





    fd = open(out_file, 
# 475 "afl-fuzz-single.c" 3 4
                       01 
# 475 "afl-fuzz-single.c"
                                | 
# 475 "afl-fuzz-single.c" 3 4
                                  0100 
# 475 "afl-fuzz-single.c"
                                          | 
# 475 "afl-fuzz-single.c" 3 4
                                            0200
# 475 "afl-fuzz-single.c"
                                                  , 0600);

    if (fd < 0) do { fprintf(
# 477 "afl-fuzz-single.c" 3 4
               stderr
# 477 "afl-fuzz-single.c"
               , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to create '%s'", out_file); fprintf(
# 477 "afl-fuzz-single.c" 3 4
               stderr
# 477 "afl-fuzz-single.c"
               , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 477); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 477 "afl-fuzz-single.c" 3 4
               stderr
# 477 "afl-fuzz-single.c"
               , "\x1b[0m" "\n"); exit(1); } while (0);

  } else lseek(fd, 0, 
# 479 "afl-fuzz-single.c" 3 4
                     0
# 479 "afl-fuzz-single.c"
                             );

  if (write(fd, mem, len) != len)
    do { fprintf(
# 482 "afl-fuzz-single.c" 3 4
   stderr
# 482 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Short write to output file"); fprintf(
# 482 "afl-fuzz-single.c" 3 4
   stderr
# 482 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 482); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 482 "afl-fuzz-single.c" 3 4
   stderr
# 482 "afl-fuzz-single.c"
   , "\x1b[0m" "\n"); exit(1); } while (0);

  if (!out_file) {

    if (ftruncate(fd, len)) do { fprintf(
# 486 "afl-fuzz-single.c" 3 4
                           stderr
# 486 "afl-fuzz-single.c"
                           , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "ftruncate() failed"); fprintf(
# 486 "afl-fuzz-single.c" 3 4
                           stderr
# 486 "afl-fuzz-single.c"
                           , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 486); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 486 "afl-fuzz-single.c" 3 4
                           stderr
# 486 "afl-fuzz-single.c"
                           , "\x1b[0m" "\n"); exit(1); } while (0);
    lseek(fd, 0, 
# 487 "afl-fuzz-single.c" 3 4
                0
# 487 "afl-fuzz-single.c"
                        );

  } else close(fd);

}







static void show_stats(void) {

  struct timeval tv;
  struct timezone tz;
  s64 run_time;

  u32 run_d, run_h, run_m;
  double run_s;

  u32 vbits = (65536 << 3) - count_bits(virgin_bits);

  gettimeofday(&tv, &tz);

  run_time = (tv.tv_sec * 1000L) + (tv.tv_usec / 1000) - start_time;

  if (!run_time) run_time = 1;

  run_d = run_time / 1000 / 60 / 60 / 24;
  run_h = (run_time / 1000 / 60 / 60) % 24;
  run_m = (run_time / 1000 / 60) % 60;
  run_s = ((double)(run_time % 60000)) / 1000;

  printf("\x1b[H" "\x1b[0;36m" "afl-fuzz " "\x1b[1;37m" """\x1b[1;33m" "\n--------------\n\n" "\x1b[0;36m" "Queue cycle: " "\x1b[1;37m" "%llu\n\n" "\x1b[1;30m" "    Overall run time : " "\x1b[0;37m" "%u day%s, %u hr%s, %u min, %0.02f sec" "    \n", queue_cycle, run_d, (run_d == 1) ? "" : "s", run_h, (run_h == 1) ? "" : "s", run_m, run_s)
# 572 "afl-fuzz-single.c"
                    ;

  printf("\x1b[1;30m" "     Execution paths : " "\x1b[0;37m" "%llu+%llu/%llu done " "(%0.02f%%)        \n", unique_processed, abandoned_inputs, unique_queued, ((double)unique_processed + abandoned_inputs) * 100 / unique_queued)


                                                                           ;

  printf("\x1b[1;30m" "       Current stage : " "\x1b[0;37m" "%s, %u/%u done (%0.02f%%)            \n", stage_name, stage_cur, stage_max, ((double)stage_cur) * 100 / stage_max)

                                                                               ;

  printf("\x1b[1;30m" "    Execution cycles : " "\x1b[0;37m" "%llu (%0.02f per second)        \n", total_execs, ((double)total_execs) * 1000 / run_time)

                                                            ;

  printf("\x1b[1;30m" "      Problems found : " "\x1b[0;37m" "%llu crashes, %llu hangs    \n", total_crashes, total_hangs)

                                  ;

  printf("\x1b[1;30m" "      Bitmap density : " "\x1b[0;37m" "%u tuples seen (%0.02f%%)    \n", vbits, ((double)vbits) * 100 / (65536 << 3))

                                                   ;

  printf("\x1b[1;30m" "  Fuzzing efficiency : " "\x1b[0;37m" "paths = %0.02f ppm, faults = %0.02f ppm" "\x1b[0m" "        \n\n", ((double)unique_queued) * 1000000 / total_execs, ((double)total_crashes + total_hangs) * 1000000 / total_execs)


                                                                     ;

  printf("\x1b[0;36m" "Per-stage yields:\n\n" "\x1b[1;30m" "     Bit-level flips : " "\x1b[0;37m" "%llu/%llu, %llu/%llu, %llu/%llu\n", stage_finds[0], stage_cycles[0], stage_finds[1], stage_cycles[1], stage_finds[2], stage_cycles[2])



                                        ;

  printf("\x1b[1;30m" "    Byte-level flips : " "\x1b[0;37m" "%llu/%llu, %llu/%llu, %llu/%llu\n", stage_finds[3], stage_cycles[3], stage_finds[4], stage_cycles[4], stage_finds[5], stage_cycles[5])


                                        ;

  printf("\x1b[1;30m" "    Interesting ints : " "\x1b[0;37m" "%llu/%llu, %llu/%llu, %llu/%llu\n", stage_finds[6], stage_cycles[6], stage_finds[7], stage_cycles[7], stage_finds[8], stage_cycles[8])


                                        ;

  printf("\x1b[1;30m" "       Random tweaks : " "\x1b[0;37m" "%llu/%llu (%llu latent paths)" "\x1b[0m" "\n\n", stage_finds[9], stage_cycles[9], queued_later)

                                                      ;

}





static u8 common_fuzz_stuff(char** argv, u8* out_buf, u32 len) {

  u8 fault;

  write_to_testcase(out_buf, len);

  fault = run_target(argv);

  if (stop_soon) return 1;

  if (fault == 1 && subseq_hangs++ > 20) {

    abandoned_inputs++;
    return 1;

  } else subseq_hangs = 0;

  save_if_interesting(out_buf, len, fault);

  if (!(stage_cur % 100) || stage_cur + 1 == stage_max) show_stats();

  return 0;

}





static void fuzz_one(char** argv) {

  s32 len, fd, temp_len;
  u8 *in_buf, *out_buf;
  s32 i, j;

  u64 orig_hit_cnt, new_hit_cnt;



  fd = open(queue_cur->fname, 
# 665 "afl-fuzz-single.c" 3 4
                             00
# 665 "afl-fuzz-single.c"
                                     );

  if (fd < 0) do { fprintf(
# 667 "afl-fuzz-single.c" 3 4
             stderr
# 667 "afl-fuzz-single.c"
             , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to open '%s'", queue_cur->fname); fprintf(
# 667 "afl-fuzz-single.c" 3 4
             stderr
# 667 "afl-fuzz-single.c"
             , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 667); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 667 "afl-fuzz-single.c" 3 4
             stderr
# 667 "afl-fuzz-single.c"
             , "\x1b[0m" "\n"); exit(1); } while (0);

  len = queue_cur->len;

  in_buf = DFL_ck_alloc(len),
  out_buf = DFL_ck_alloc(len);

  if (read(fd, in_buf, len) != len)
    do { fprintf(
# 675 "afl-fuzz-single.c" 3 4
   stderr
# 675 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Short read from '%s'", queue_cur->fname); fprintf(
# 675 "afl-fuzz-single.c" 3 4
   stderr
# 675 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 675); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 675 "afl-fuzz-single.c" 3 4
   stderr
# 675 "afl-fuzz-single.c"
   , "\x1b[0m" "\n"); exit(1); } while (0);

  close(fd);

  memcpy(out_buf, in_buf, len);

  subseq_hangs = 0;

  if (skip_deterministic || queue_cur->det_done) goto havoc_stage;







  stage_name = "bitflip 1/1";
  stage_max = len << 3;

  orig_hit_cnt = unique_queued + total_hangs + total_crashes;

  for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {

    do { out_buf[(stage_cur) >> 3] ^= (1 << ((stage_cur) & 7)); } while (0);

    if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;

    do { out_buf[(stage_cur) >> 3] ^= (1 << ((stage_cur) & 7)); } while (0);

  }

  new_hit_cnt = unique_queued + total_hangs + total_crashes;
  stage_finds[0] += new_hit_cnt - orig_hit_cnt;
  stage_cycles[0] += stage_max;

  stage_name = "bitflip 2/1";
  stage_max = (len << 3) - 1;

  orig_hit_cnt = new_hit_cnt;

  for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {

    do { out_buf[(stage_cur) >> 3] ^= (1 << ((stage_cur) & 7)); } while (0);
    do { out_buf[(stage_cur + 1) >> 3] ^= (1 << ((stage_cur + 1) & 7)); } while (0);

    if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;

    do { out_buf[(stage_cur) >> 3] ^= (1 << ((stage_cur) & 7)); } while (0);
    do { out_buf[(stage_cur + 1) >> 3] ^= (1 << ((stage_cur + 1) & 7)); } while (0);

  }

  new_hit_cnt = unique_queued + total_hangs + total_crashes;
  stage_finds[1] += new_hit_cnt - orig_hit_cnt;
  stage_cycles[1] += stage_max;

  stage_name = "bitflip 4/1";
  stage_max = (len << 3) - 3;

  orig_hit_cnt = new_hit_cnt;

  for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {

    do { out_buf[(stage_cur) >> 3] ^= (1 << ((stage_cur) & 7)); } while (0);
    do { out_buf[(stage_cur + 1) >> 3] ^= (1 << ((stage_cur + 1) & 7)); } while (0);
    do { out_buf[(stage_cur + 2) >> 3] ^= (1 << ((stage_cur + 2) & 7)); } while (0);
    do { out_buf[(stage_cur + 3) >> 3] ^= (1 << ((stage_cur + 3) & 7)); } while (0);

    if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;

    do { out_buf[(stage_cur) >> 3] ^= (1 << ((stage_cur) & 7)); } while (0);
    do { out_buf[(stage_cur + 1) >> 3] ^= (1 << ((stage_cur + 1) & 7)); } while (0);
    do { out_buf[(stage_cur + 2) >> 3] ^= (1 << ((stage_cur + 2) & 7)); } while (0);
    do { out_buf[(stage_cur + 3) >> 3] ^= (1 << ((stage_cur + 3) & 7)); } while (0);

  }

  new_hit_cnt = unique_queued + total_hangs + total_crashes;
  stage_finds[2] += new_hit_cnt - orig_hit_cnt;
  stage_cycles[2] += stage_max;

  stage_name = "bitflip 8/8";
  stage_max = len;

  orig_hit_cnt = new_hit_cnt;

  for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {

    out_buf[stage_cur] ^= 0xFF;

    if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;

    out_buf[stage_cur] ^= 0xFF;

  }

  new_hit_cnt = unique_queued + total_hangs + total_crashes;
  stage_finds[3] += new_hit_cnt - orig_hit_cnt;
  stage_cycles[3] += stage_max;

  stage_name = "bitflip 16/8";
  stage_max = len - 1;

  orig_hit_cnt = new_hit_cnt;

  for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {

    *(u16*)(out_buf + stage_cur) ^= 0xFFFF;

    if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;

    *(u16*)(out_buf + stage_cur) ^= 0xFFFF;

  }

  new_hit_cnt = unique_queued + total_hangs + total_crashes;
  stage_finds[4] += new_hit_cnt - orig_hit_cnt;
  stage_cycles[4] += stage_max;

  stage_name = "bitflip 32/8";
  stage_max = len - 3;

  orig_hit_cnt = new_hit_cnt;

  for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {

    *(u32*)(out_buf + stage_cur) ^= 0xFFFFFFFF;

    if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;

    *(u32*)(out_buf + stage_cur) ^= 0xFFFFFFFF;

  }

  new_hit_cnt = unique_queued + total_hangs + total_crashes;
  stage_finds[5] += new_hit_cnt - orig_hit_cnt;
  stage_cycles[5] += stage_max;





  stage_name = "interest 8/8";
  stage_cur = 0;
  stage_max = len * sizeof(interesting_8);

  orig_hit_cnt = new_hit_cnt;

  for (i = 0; i < len; i++) {

    u8 orig = out_buf[i];

    for (j = 0; j < sizeof(interesting_8); j++) {

      out_buf[i] = interesting_8[j];

      if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;

      out_buf[i] = orig;
      stage_cur++;

    }

  }

  new_hit_cnt = unique_queued + total_hangs + total_crashes;
  stage_finds[6] += new_hit_cnt - orig_hit_cnt;
  stage_cycles[6] += stage_max;







  stage_name = "interest 16/8";
  stage_cur = 0;
  stage_max = len * sizeof(interesting_16);

  orig_hit_cnt = new_hit_cnt;

  for (i = 0; i < len - 1; i++) {

    u16 orig = *(u16*)(out_buf+i);

    for (j = 0; j < sizeof(interesting_16) / 2; j++) {

      *(u16*)(out_buf + i) = interesting_16[j];

      if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
      stage_cur++;

      if ((((interesting_16[j]) << 8) | ((interesting_16[j]) >> 8)) != interesting_16[j]) {

        *(u16*)(out_buf + i) = (((interesting_16[j]) << 8) | ((interesting_16[j]) >> 8));
        if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
        stage_cur++;

      } else stage_max--;


      *(u16*)(out_buf + i) = orig;

    }

  }

  new_hit_cnt = unique_queued + total_hangs + total_crashes;
  stage_finds[7] += new_hit_cnt - orig_hit_cnt;
  stage_cycles[7] += stage_max;

  stage_name = "interest 32/8";
  stage_cur = 0;
  stage_max = len * sizeof(interesting_32) / 2;

  orig_hit_cnt = new_hit_cnt;

  for (i = 0; i < len - 3; i++) {

    u32 orig = *(u32*)(out_buf + i);

    for (j = 0; j < sizeof(interesting_32) / 4; j++) {

      *(u32*)(out_buf + i) = interesting_32[j];

      if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
      stage_cur++;

      if ((((interesting_32[j]) << 24) | ((interesting_32[j]) >> 24) | (((interesting_32[j]) << 8) & 0x00FF0000) | (((interesting_32[j]) >> 8) & 0x0000FF00)) != interesting_32[j]) {

        *(u32*)(out_buf + i) = (((interesting_32[j]) << 24) | ((interesting_32[j]) >> 24) | (((interesting_32[j]) << 8) & 0x00FF0000) | (((interesting_32[j]) >> 8) & 0x0000FF00));
        if (common_fuzz_stuff(argv, out_buf, len)) goto abandon_entry;
        stage_cur++;

      } else stage_max--;

      *(u32*)(out_buf + i) = orig;

    }

  }

  new_hit_cnt = unique_queued + total_hangs + total_crashes;
  stage_finds[8] += new_hit_cnt - orig_hit_cnt;
  stage_cycles[8] += stage_max;





havoc_stage:

  queue_cur->det_done = 1;

  stage_name = "havoc";
  stage_max = 5000;
  temp_len = len;

  orig_hit_cnt = unique_queued + total_hangs + total_crashes;

  for (stage_cur = 0; stage_cur < stage_max; stage_cur++) {

    u32 use_stacking = (random() % (5)) + 1;

    for (i = 0; i < use_stacking; i++) {

      switch ((random() % (7))) {

        case 0:



          do { out_buf[((random() % (temp_len << 3))) >> 3] ^= (1 << (((random() % (temp_len << 3))) & 7)); } while (0);
          break;

        case 1:



          out_buf[(random() % (temp_len))] = interesting_8[(random() % (sizeof(interesting_8)))];
          break;

        case 2:



          if (temp_len < 2) break;

          if ((random() % (2))) {

            *(u16*)(out_buf + (random() % (temp_len - 1))) =
              interesting_16[(random() % (sizeof(interesting_16) >> 1))];

          } else {

            *(u16*)(out_buf + (random() % (temp_len - 1))) = htons(
              interesting_16[(random() % (sizeof(interesting_16) >> 1))]);

          }

          break;

        case 3:



          if (temp_len < 4) break;

          if ((random() % (2))) {

            *(u32*)(out_buf + (random() % (temp_len - 3))) =
              interesting_32[(random() % (sizeof(interesting_32) >> 2))];

          } else {

            *(u32*)(out_buf + (random() % (temp_len - 3))) = htonl(
              interesting_32[(random() % (sizeof(interesting_32) >> 2))]);

          }

          break;

        case 4:



          out_buf[(random() % (temp_len))] = (random() % (256));
          break;

        case 5: {



            u32 del_from, del_len, max_chunk_len;

            if (temp_len == 1) break;



            max_chunk_len = (((temp_len - 1) * 75 / 100) > (100) ? (100) : ((temp_len - 1) * 75 / 100))
                                                ;

            del_len = 1 + (random() % (max_chunk_len ? max_chunk_len : 1));

            del_from = (random() % (temp_len - del_len + 1));

            memmove(out_buf + del_from, out_buf + del_from + del_len,
                    temp_len - del_from - del_len);

            temp_len -= del_len;

            break;

          }

        case 6: {



            u32 clone_from, clone_to, clone_len, max_chunk_len;
            u8* new_buf;

            max_chunk_len = ((temp_len * 75 / 100) > (100) ? (100) : (temp_len * 75 / 100))
                                                ;

            clone_len = 1 + (random() % (max_chunk_len ? max_chunk_len : 1));

            clone_from = (random() % (temp_len - clone_len + 1));
            clone_to = (random() % (temp_len));

            new_buf = DFL_ck_alloc(temp_len + clone_len);


            memcpy(new_buf, out_buf, clone_to);


            memcpy(new_buf + clone_to, out_buf + clone_from, clone_len);


            memcpy(new_buf + clone_to + clone_len, out_buf + clone_to,
                   temp_len - clone_to);

            DFL_ck_free(out_buf);
            out_buf = new_buf;
            temp_len += clone_len;

            break;

          }

      }

    }

    if (common_fuzz_stuff(argv, out_buf, temp_len))
      goto abandon_entry;

    if (temp_len < len) out_buf = DFL_ck_realloc(out_buf, len);
    temp_len = len;
    memcpy(out_buf, in_buf, len);

  }

  new_hit_cnt = unique_queued + total_hangs + total_crashes;
  stage_finds[9] += new_hit_cnt - orig_hit_cnt;
  stage_cycles[9] += stage_max;

  unique_processed++;

abandon_entry:

  DFL_ck_free(in_buf);
  DFL_ck_free(out_buf);

}




static void handle_stop_sig(int sig) {

  stop_soon = 1;
  if (child_pid > 0) kill(child_pid, 
# 1097 "afl-fuzz-single.c" 3 4
                                    9
# 1097 "afl-fuzz-single.c"
                                           );

}




static void handle_timeout(int sig) {

  child_timed_out = 1;
  if (child_pid > 0) kill(child_pid, 
# 1107 "afl-fuzz-single.c" 3 4
                                    9
# 1107 "afl-fuzz-single.c"
                                           );

}




static void setup_random(void) {

  u32 seed;
  struct timeval tv;
  struct timezone tz;

  gettimeofday(&tv, &tz);
  seed = tv.tv_sec ^ tv.tv_usec ^ getpid();

  srandom(seed);

  start_time = (tv.tv_sec * 1000L) + (tv.tv_usec / 1000);

}




static void usage(u8* argv0) {

  printf("\n%s [ options ] -- /path/to/traced_app [ ... ]\n\n" "Required parameters:\n\n" "  -i dir        - input directory with test cases\n" "  -o dir        - output directory for captured crashes\n\n" "Execution control settings:\n\n" "  -f file       - input filed used by the traced application\n" "  -t msec       - timeout for each run (%u ms)\n" "  -m megs       - memory limit for child process (%u MB)\n" "Fuzzing behavior settings:\n\n" "  -d            - skip all deterministic fuzzing stages\n" "  -k            - keep all discovered test cases\n" "  -n            - fuzz non-instrumented binaries (dumb mode)\n\n" "For additional tips, please consult the provided documentation.\n\n", argv0, 4000, 100)
# 1155 "afl-fuzz-single.c"
                                      ;

  exit(1);

}




static void setup_dirs(void) {

  u8* tmp;

  if (mkdir(out_dir, 0700) && 
# 1168 "afl-fuzz-single.c" 3 4
                             (*__errno_location ()) 
# 1168 "afl-fuzz-single.c"
                                   != 
# 1168 "afl-fuzz-single.c" 3 4
                                      17
# 1168 "afl-fuzz-single.c"
                                            )
    do { fprintf(
# 1169 "afl-fuzz-single.c" 3 4
   stderr
# 1169 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to create '%s'", out_dir); fprintf(
# 1169 "afl-fuzz-single.c" 3 4
   stderr
# 1169 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 1169); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 1169 "afl-fuzz-single.c" 3 4
   stderr
# 1169 "afl-fuzz-single.c"
   , "\x1b[0m" "\n"); exit(1); } while (0);

  tmp = ({ u8* _tmp; s32 _len = snprintf(
# 1171 "afl-fuzz-single.c" 3 4
       ((void *)0)
# 1171 "afl-fuzz-single.c"
       , 0, "%s/queue", out_dir); if (_len < 0) do { fprintf(
# 1171 "afl-fuzz-single.c" 3 4
       stderr
# 1171 "afl-fuzz-single.c"
       , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Whoa, snprintf() fails?!"); fprintf(
# 1171 "afl-fuzz-single.c" 3 4
       stderr
# 1171 "afl-fuzz-single.c"
       , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 1171); exit(1); } while (0); _tmp = DFL_ck_alloc(_len + 1); snprintf((char*)_tmp, _len + 1, "%s/queue", out_dir); _tmp; });

  if (mkdir(tmp, 0700))
    do { fprintf(
# 1174 "afl-fuzz-single.c" 3 4
   stderr
# 1174 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to create '%s' (delete existing directories first)", tmp); fprintf(
# 1174 "afl-fuzz-single.c" 3 4
   stderr
# 1174 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 1174); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 1174 "afl-fuzz-single.c" 3 4
   stderr
# 1174 "afl-fuzz-single.c"
   , "\x1b[0m" "\n"); exit(1); } while (0);

  DFL_ck_free(tmp);

  tmp = ({ u8* _tmp; s32 _len = snprintf(
# 1178 "afl-fuzz-single.c" 3 4
       ((void *)0)
# 1178 "afl-fuzz-single.c"
       , 0, "%s/crashes", out_dir); if (_len < 0) do { fprintf(
# 1178 "afl-fuzz-single.c" 3 4
       stderr
# 1178 "afl-fuzz-single.c"
       , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Whoa, snprintf() fails?!"); fprintf(
# 1178 "afl-fuzz-single.c" 3 4
       stderr
# 1178 "afl-fuzz-single.c"
       , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 1178); exit(1); } while (0); _tmp = DFL_ck_alloc(_len + 1); snprintf((char*)_tmp, _len + 1, "%s/crashes", out_dir); _tmp; });

  if (mkdir(tmp, 0700))
    do { fprintf(
# 1181 "afl-fuzz-single.c" 3 4
   stderr
# 1181 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to create '%s' (delete existing directories first)", tmp); fprintf(
# 1181 "afl-fuzz-single.c" 3 4
   stderr
# 1181 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 1181); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 1181 "afl-fuzz-single.c" 3 4
   stderr
# 1181 "afl-fuzz-single.c"
   , "\x1b[0m" "\n"); exit(1); } while (0);

  DFL_ck_free(tmp);

  tmp = ({ u8* _tmp; s32 _len = snprintf(
# 1185 "afl-fuzz-single.c" 3 4
       ((void *)0)
# 1185 "afl-fuzz-single.c"
       , 0, "%s/hangs", out_dir); if (_len < 0) do { fprintf(
# 1185 "afl-fuzz-single.c" 3 4
       stderr
# 1185 "afl-fuzz-single.c"
       , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Whoa, snprintf() fails?!"); fprintf(
# 1185 "afl-fuzz-single.c" 3 4
       stderr
# 1185 "afl-fuzz-single.c"
       , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 1185); exit(1); } while (0); _tmp = DFL_ck_alloc(_len + 1); snprintf((char*)_tmp, _len + 1, "%s/hangs", out_dir); _tmp; });

  if (mkdir(tmp, 0700))
    do { fprintf(
# 1188 "afl-fuzz-single.c" 3 4
   stderr
# 1188 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to create '%s' (delete existing directories first)", tmp); fprintf(
# 1188 "afl-fuzz-single.c" 3 4
   stderr
# 1188 "afl-fuzz-single.c"
   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 1188); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 1188 "afl-fuzz-single.c" 3 4
   stderr
# 1188 "afl-fuzz-single.c"
   , "\x1b[0m" "\n"); exit(1); } while (0);

  DFL_ck_free(tmp);

}




static void setup_stdio_file(void) {

  u8* fn = ({ u8* _tmp; s32 _len = snprintf(
# 1199 "afl-fuzz-single.c" 3 4
          ((void *)0)
# 1199 "afl-fuzz-single.c"
          , 0, "%s/.cur_input", out_dir); if (_len < 0) do { fprintf(
# 1199 "afl-fuzz-single.c" 3 4
          stderr
# 1199 "afl-fuzz-single.c"
          , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Whoa, snprintf() fails?!"); fprintf(
# 1199 "afl-fuzz-single.c" 3 4
          stderr
# 1199 "afl-fuzz-single.c"
          , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 1199); exit(1); } while (0); _tmp = DFL_ck_alloc(_len + 1); snprintf((char*)_tmp, _len + 1, "%s/.cur_input", out_dir); _tmp; });

  unlink(fn);

  out_fd = open(fn, 
# 1203 "afl-fuzz-single.c" 3 4
                   02 
# 1203 "afl-fuzz-single.c"
                          | 
# 1203 "afl-fuzz-single.c" 3 4
                            0100 
# 1203 "afl-fuzz-single.c"
                                    | 
# 1203 "afl-fuzz-single.c" 3 4
                                      0200 
# 1203 "afl-fuzz-single.c"
                                             | 
# 1203 "afl-fuzz-single.c" 3 4
                                               0400000
# 1203 "afl-fuzz-single.c"
                                                         , 0600);

  if (out_fd < 0) do { fprintf(
# 1205 "afl-fuzz-single.c" 3 4
                 stderr
# 1205 "afl-fuzz-single.c"
                 , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to create '%s'", fn); fprintf(
# 1205 "afl-fuzz-single.c" 3 4
                 stderr
# 1205 "afl-fuzz-single.c"
                 , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 1205); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 1205 "afl-fuzz-single.c" 3 4
                 stderr
# 1205 "afl-fuzz-single.c"
                 , "\x1b[0m" "\n"); exit(1); } while (0);

  DFL_ck_free(fn);

}




static void handle_resize(int sig) {
  clear_screen = 1;
}





int main(int argc, char** argv) {

  s32 opt;

  printf("\x1b[0;36m" "afl-fuzz " "\x1b[1;37m" """\x1b[0;37m" " (" "Jul  2 2018" " " "09:10:07" ") by <[email protected]>\n")
                                     ;

  signal(
# 1229 "afl-fuzz-single.c" 3 4
        1
# 1229 "afl-fuzz-single.c"
              , handle_stop_sig);
  signal(
# 1230 "afl-fuzz-single.c" 3 4
        2
# 1230 "afl-fuzz-single.c"
              , handle_stop_sig);
  signal(
# 1231 "afl-fuzz-single.c" 3 4
        15
# 1231 "afl-fuzz-single.c"
               , handle_stop_sig);
  signal(
# 1232 "afl-fuzz-single.c" 3 4
        14
# 1232 "afl-fuzz-single.c"
               , handle_timeout);
  signal(
# 1233 "afl-fuzz-single.c" 3 4
        28
# 1233 "afl-fuzz-single.c"
                , handle_resize);

  signal(
# 1235 "afl-fuzz-single.c" 3 4
        20
# 1235 "afl-fuzz-single.c"
               , 
# 1235 "afl-fuzz-single.c" 3 4
                 ((__sighandler_t) 1)
# 1235 "afl-fuzz-single.c"
                        );
  signal(
# 1236 "afl-fuzz-single.c" 3 4
        13
# 1236 "afl-fuzz-single.c"
               , 
# 1236 "afl-fuzz-single.c" 3 4
                 ((__sighandler_t) 1)
# 1236 "afl-fuzz-single.c"
                        );

  while ((opt = getopt(argc,argv,"+i:o:f:m:t:kdn")) > 0)

    switch (opt) {

      case 'i':

        if (in_dir) do { fprintf(
# 1244 "afl-fuzz-single.c" 3 4
                   stderr
# 1244 "afl-fuzz-single.c"
                   , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Multiple -i options not supported"); fprintf(
# 1244 "afl-fuzz-single.c" 3 4
                   stderr
# 1244 "afl-fuzz-single.c"
                   , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 1244); exit(1); } while (0);
        in_dir = optarg;
        break;

      case 'o':

        if (out_dir) do { fprintf(
# 1250 "afl-fuzz-single.c" 3 4
                    stderr
# 1250 "afl-fuzz-single.c"
                    , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Multiple -o options not supported"); fprintf(
# 1250 "afl-fuzz-single.c" 3 4
                    stderr
# 1250 "afl-fuzz-single.c"
                    , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 1250); exit(1); } while (0);
        out_dir = optarg;
        break;

      case 'f':

        if (out_file) do { fprintf(
# 1256 "afl-fuzz-single.c" 3 4
                     stderr
# 1256 "afl-fuzz-single.c"
                     , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Multiple -f options not supported"); fprintf(
# 1256 "afl-fuzz-single.c" 3 4
                     stderr
# 1256 "afl-fuzz-single.c"
                     , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 1256); exit(1); } while (0);
        out_file = optarg;
        break;

      case 't':

        exec_tmout = atoi(optarg);
        if (exec_tmout < 20) do { fprintf(
# 1263 "afl-fuzz-single.c" 3 4
                            stderr
# 1263 "afl-fuzz-single.c"
                            , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad or dangerously low value of -t"); fprintf(
# 1263 "afl-fuzz-single.c" 3 4
                            stderr
# 1263 "afl-fuzz-single.c"
                            , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 1263); exit(1); } while (0);
        break;

      case 'm':

        mem_limit = atoi(optarg);
        if (mem_limit < 10) do { fprintf(
# 1269 "afl-fuzz-single.c" 3 4
                           stderr
# 1269 "afl-fuzz-single.c"
                           , "\x1b[1;31m" "\n[-] PROGRAM ABORT : " "\x1b[1;37m" "Bad or dangerously low value of -m"); fprintf(
# 1269 "afl-fuzz-single.c" 3 4
                           stderr
# 1269 "afl-fuzz-single.c"
                           , "\x1b[1;31m" "\n         Location : " "\x1b[0;37m" "%s(), %s:%u\n\n" "\x1b[0m", __FUNCTION__, "afl-fuzz-single.c", 1269); exit(1); } while (0);
        break;

      case 'k':

        keep_testcases = 1;
        break;

      case 'd':

        skip_deterministic = 1;
        break;

      case 'n':

        dumb_mode = 1;
        break;

      default:

        usage(argv[0]);

    }

  if (optind == argc || !in_dir || !out_dir) usage(argv[0]);

  dev_null = open("/dev/null", 
# 1295 "afl-fuzz-single.c" 3 4
                              02
# 1295 "afl-fuzz-single.c"
                                    );
  if (dev_null < 0) do { fprintf(
# 1296 "afl-fuzz-single.c" 3 4
                   stderr
# 1296 "afl-fuzz-single.c"
                   , "\x1b[1;31m" "\n[-]  SYSTEM ERROR : " "\x1b[1;37m" "Unable to open /dev/null"); fprintf(
# 1296 "afl-fuzz-single.c" 3 4
                   stderr
# 1296 "afl-fuzz-single.c"
                   , "\x1b[1;31m" "\n    Stop location : " "\x1b[0;37m" "%s(), %s:%u\n", __FUNCTION__, "afl-fuzz-single.c", 1296); perror("\x1b[1;31m" "       OS message " "\x1b[0;37m"); fprintf(
# 1296 "afl-fuzz-single.c" 3 4
                   stderr
# 1296 "afl-fuzz-single.c"
                   , "\x1b[0m" "\n"); exit(1); } while (0);

  setup_shm();

  setup_dirs();

  read_testcases();

  perform_dry_run(argv + optind);

  if (!stop_soon) {

    setup_random();
    if (!out_file) setup_stdio_file();

  }

  printf("\x1b[H" "\x1b[2J");

  while (!stop_soon) {

    if (!queue_cur) {

      queue_cycle++;
      unique_processed = 0;
      abandoned_inputs = 0;
      queue_cur = queue;
      show_stats();

    }

    fuzz_one(argv + optind);
    queue_cur = queue_cur->next;

    if (clear_screen) {

      printf("\x1b[H" "\x1b[2J");
      show_stats();
      clear_screen = 0;

    }

  }

  show_stats();

  if (stop_soon) printf("\x1b[1;31m" "\n+++ Testing aborted by user +++\n" "\x1b[0m");

  destroy_queue();
  ;

  do { fprintf(
# 1347 "afl-fuzz-single.c" 3 4
 stderr
# 1347 "afl-fuzz-single.c"
 , "\x1b[1;32m" "[+] " "\x1b[0;37m" "We're done here. Have a nice day!"); fprintf(
# 1347 "afl-fuzz-single.c" 3 4
 stderr
# 1347 "afl-fuzz-single.c"
 , "\x1b[0m" "\n"); } while (0);

  exit(0);

}

build failed

$ cargo build --release
   Compiling slotmap v0.3.0
   Compiling c2rust-ast-builder v0.9.0 (/home/zaoqi/pkgs-src/c2rust/c2rust-ast-builder)
   Compiling proc-macro2 v0.4.27
   Compiling syn v0.15.30
   Compiling rand_chacha v0.1.1
   Compiling rand_pcg v0.1.2
error[E0554]: #![feature] may not be used on the stable release channel
 --> /home/zaoqi/.cargo/registry/src/github.com-1ecc6299db9ec823/slotmap-0.3.0/src/lib.rs:4:35
  |
4 | #![cfg_attr(feature = "unstable", feature(untagged_unions))]
  |                                   ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0554`.
error: Could not compile `slotmap`.
warning: build failed, waiting for other jobs to finish...
error[E0412]: cannot find type `ParenthesizedArgs` in this scope
   --> c2rust-ast-builder/src/builder.rs:209:28
    |
209 | impl Make<GenericArgs> for ParenthesizedArgs {
    |                            ^^^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `ParenthesisedArgs`

error[E0412]: cannot find type `ParenthesizedArgs` in this scope
   --> c2rust-ast-builder/src/builder.rs:449:53
    |
449 |     pub fn parenthesized_args<Ts>(self, tys: Ts) -> ParenthesizedArgs
    |                                                     ^^^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `ParenthesisedArgs`

error[E0422]: cannot find struct, variant or union type `ParenthesizedArgs` in this scope
   --> c2rust-ast-builder/src/builder.rs:454:9
    |
454 |         ParenthesizedArgs {
    |         ^^^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `ParenthesisedArgs`

error[E0554]: #![feature] may not be used on the stable release channel
 --> c2rust-ast-builder/src/lib.rs:1:1
  |
1 | #![feature(rustc_private)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no associated item named `MetaItem` found for type `syntax::source_map::Spanned<syntax::ast::NestedMetaItemKind>` in the current scope
   --> c2rust-ast-builder/src/builder.rs:229:25
    |
229 |         NestedMetaItem::MetaItem(self)
    |         ----------------^^^^^^^^
    |         |
    |         associated item not found in `syntax::source_map::Spanned<syntax::ast::NestedMetaItemKind>`

error[E0599]: no associated item named `Literal` found for type `syntax::source_map::Spanned<syntax::ast::NestedMetaItemKind>` in the current scope
   --> c2rust-ast-builder/src/builder.rs:235:25
    |
235 |         NestedMetaItem::Literal(self)
    |         ----------------^^^^^^^
    |         |
    |         associated item not found in `syntax::source_map::Spanned<syntax::ast::NestedMetaItemKind>`
    |
    = help: did you mean `literal`?

error[E0599]: no variant named `CVarArgs` found for type `syntax::ast::TyKind` in the current scope
    --> c2rust-ast-builder/src/builder.rs:1361:27
     |
1361 |             node: TyKind::CVarArgs,
     |                   --------^^^^^^^^
     |                   |
     |                   variant not found in `syntax::ast::TyKind`

error[E0308]: mismatched types
    --> c2rust-ast-builder/src/builder.rs:1498:24
     |
1498 |             asyncness: dummy_spanned(IsAsync::NotAsync),
     |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `syntax::ast::IsAsync`, found struct `syntax::source_map::Spanned`
     |
     = note: expected type `syntax::ast::IsAsync`
                found type `syntax::source_map::Spanned<syntax::ast::IsAsync>`

error[E0560]: struct `syntax::ast::FnDecl` has no field named `c_variadic`
    --> c2rust-ast-builder/src/builder.rs:1516:13
     |
1516 |             c_variadic,
     |             ^^^^^^^^^^ help: a field with a similar name exists: `variadic`

error[E0308]: mismatched types
    --> c2rust-ast-builder/src/builder.rs:1531:58
     |
1531 |             ItemKind::Struct(VariantData::Struct(fields, false), self.generics),
     |                                                          ^^^^^ expected struct `syntax::ast::NodeId`, found bool
     |
     = note: expected type `syntax::ast::NodeId`
                found type `bool`

error[E0308]: mismatched types
    --> c2rust-ast-builder/src/builder.rs:1546:57
     |
1546 |             ItemKind::Union(VariantData::Struct(fields, false), self.generics),
     |                                                         ^^^^^ expected struct `syntax::ast::NodeId`, found bool
     |
     = note: expected type `syntax::ast::NodeId`
                found type `bool`

error[E0560]: struct `syntax::ast::Variant_` has no field named `id`
    --> c2rust-ast-builder/src/builder.rs:1622:17
     |
1622 |                 id: DUMMY_NODE_ID,
     |                 ^^ `syntax::ast::Variant_` does not have this field
     |
     = note: available fields are: `ident`, `attrs`, `data`, `disr_expr`

error[E0560]: struct `syntax::ast::Variant_` has no field named `id`
    --> c2rust-ast-builder/src/builder.rs:1644:17
     |
1644 |                 id: DUMMY_NODE_ID,
     |                 ^^ `syntax::ast::Variant_` does not have this field
     |
     = note: available fields are: `ident`, `attrs`, `data`, `disr_expr`

error[E0560]: struct `syntax::ast::MetaItem` has no field named `path`
    --> c2rust-ast-builder/src/builder.rs:2085:13
     |
2085 |             path: path,
     |             ^^^^ `syntax::ast::MetaItem` does not have this field
     |
     = note: available fields are: `ident`, `node`, `span`

error[E0308]: mismatched types
    --> c2rust-ast-builder/src/builder.rs:2122:22
     |
2122 |                 tts: tts,
     |                      ^^^ expected struct `syntax::tokenstream::ThinTokenStream`, found enum `syntax::tokenstream::TokenStream`
     |
     = note: expected type `syntax::tokenstream::ThinTokenStream`
                found type `syntax::tokenstream::TokenStream`

error: aborting due to 15 previous errors

Some errors occurred: E0308, E0412, E0422, E0554, E0560, E0599.
For more information about an error, try `rustc --explain E0308`.
error: Could not compile `c2rust-ast-builder`.

To learn more, run the command again with --verbose.

Translation of doc comments

Some C comments have special meaning in Rust and can cause compiler errors. Example:

error: expected outer doc comment
   --> programs/../lib/legacy/zstd_v05.rs:176:1
    |
176 | / /*!
177 | |  * HEAPMODE :
178 | |  * Select how default decompression function ZSTDv05_decompress() will allocate memory,
179 | |  * in memory stack (0), or in memory heap (1, requires malloc())
180 | |  */
    | |___^
    |
    = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items

zstd_decompress.rs missing ZSTD_decompressFrame() function

The function is not particularly complex within https://github.com/facebook/zstd/blob/dev/lib/decompress/zstd_decompress.c:

static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx,
                                   void* dst, size_t dstCapacity,
                             const void** srcPtr, size_t *srcSizePtr)
{
    const BYTE* ip = (const BYTE*)(*srcPtr);
    BYTE* const ostart = (BYTE* const)dst;
    BYTE* const oend = ostart + dstCapacity;
    BYTE* op = ostart;
    size_t remainingSize = *srcSizePtr;

    /* check */
    if (remainingSize < ZSTD_frameHeaderSize_min+ZSTD_blockHeaderSize)
        return ERROR(srcSize_wrong);

    /* Frame Header */
    {   size_t const frameHeaderSize = ZSTD_frameHeaderSize(ip, ZSTD_frameHeaderSize_prefix);
        if (ZSTD_isError(frameHeaderSize)) return frameHeaderSize;
        if (remainingSize < frameHeaderSize+ZSTD_blockHeaderSize)
            return ERROR(srcSize_wrong);
        CHECK_F( ZSTD_decodeFrameHeader(dctx, ip, frameHeaderSize) );
        ip += frameHeaderSize; remainingSize -= frameHeaderSize;
    }

    /* Loop on each block */
    while (1) {
        size_t decodedSize;
        blockProperties_t blockProperties;
        size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSize, &blockProperties);
        if (ZSTD_isError(cBlockSize)) return cBlockSize;

        ip += ZSTD_blockHeaderSize;
        remainingSize -= ZSTD_blockHeaderSize;
        if (cBlockSize > remainingSize) return ERROR(srcSize_wrong);

        switch(blockProperties.blockType)
        {
        case bt_compressed:
            decodedSize = ZSTD_decompressBlock_internal(dctx, op, oend-op, ip, cBlockSize, /* frame */ 1);
            break;
        case bt_raw :
            decodedSize = ZSTD_copyRawBlock(op, oend-op, ip, cBlockSize);
            break;
        case bt_rle :
            decodedSize = ZSTD_generateNxBytes(op, oend-op, *ip, blockProperties.origSize);
            break;
        case bt_reserved :
        default:
            return ERROR(corruption_detected);
        }

        if (ZSTD_isError(decodedSize)) return decodedSize;
        if (dctx->fParams.checksumFlag)
            XXH64_update(&dctx->xxhState, op, decodedSize);
        op += decodedSize;
        ip += cBlockSize;
        remainingSize -= cBlockSize;
        if (blockProperties.lastBlock) break;
    }

    if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) {
        if ((U64)(op-ostart) != dctx->fParams.frameContentSize) {
            return ERROR(corruption_detected);
    }   }
    if (dctx->fParams.checksumFlag) { /* Frame content checksum verification */
        U32 const checkCalc = (U32)XXH64_digest(&dctx->xxhState);
        U32 checkRead;
        if (remainingSize<4) return ERROR(checksum_wrong);
        checkRead = MEM_readLE32(ip);
        if (checkRead != checkCalc) return ERROR(checksum_wrong);
        ip += 4;
        remainingSize -= 4;
    }

    /* Allow caller to get size read */
    *srcPtr = ip;
    *srcSizePtr = remainingSize;
    return op-ostart;
}

But in the output, the entire function is missing

/* ! ZSTD_decompressFrame() :                                                                     
*   @dctx must be properly initialized */                                                         
/* ! ZSTD_getcBlockSize() :                                                                       
 *  Provides the size of compressed block from block header `src` */                              
#[no_mangle]                                                                                      
pub unsafe extern "C" fn ZSTD_getcBlockSize(...

about the docker container you provide

Hi Immunant,

I am very interested to convert C to Rust.

I followed instructions and can run docker just fine. I plan to transpile some C project outside your docker container but failed to share host file system with docker container. Did you build the docker image without the sudo access? I want a way to transpile the project on host file system, or need a way to move the project on to the docker container.

Please advise, thanks.

Clean Yong

Translation of C's `va_copy` into Rust's `std::ffi::VaList::copy`

There is no good way to perform syntax-directed translation of all possible C functions using va_list into a corresponding Rust function using std::ffi::VaList::copy. VaLists copy has the following signature:

pub unsafe fn copy<F, R>(&self, f: F) -> R
            where F: for<'copy> FnOnce(VaList<'copy>) -> R;

copy takes a closure whose input VaList cannot outlive the closure (e.g. it cannot be passed back as a result of the closure). This is so that va_end can be called on the input VaList once the closure returns.

Since copy takes an immutable reference to the original va_list and std::ffi::VaList::arg requires a mutable reference, it is not possible to call std::ffi::VaList::arg inside the closure passed to copy. Therefore, a C function that calls va_arg on two va_lists (with one being a va_copy of the other) in the same basic block, cannot be expressed using the current Rust variadic function API

Assembly translation failures for zstd and libxml2

Translating zstd like this (working around other issues):

intercept-build make -j`ncpus` zstd
c2rust transpile --translate-asm -m zstdcli compile_commands.json
cargo build

produces:

error: couldn't allocate output register for constraint 'a'
    --> programs/../lib/compress/zstd_compress.rs:1778:5
     |
1778 |     asm!("cpuid" : "=a" (n) : "a" (0i32) : "ebx" , "ecx" , "edx");
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: couldn't allocate output register for constraint 'a'
    --> programs/../lib/compress/zstd_compress.rs:1781:9
     |
1781 | /         asm!("cpuid" : "=a" (f1a) , "=c" (f1c) , "=d" (f1d) : "a" (1i32) :
1782 | |              "ebx")
     | |___________________^

error: couldn't allocate output register for constraint 'a'
    --> programs/../lib/compress/zstd_compress.rs:1786:9
     |
1786 | /         asm!("cpuid" : "=a" (f7a) , "=b" (f7b) , "=c" (f7c) : "a" (7i32) , "c"
1787 | |              (0i32) : "edx")
     | |____________________________^

error: couldn't allocate output register for constraint 'a'
    --> programs/../lib/decompress/zstd_decompress.rs:1050:5
     |
1050 |     asm!("cpuid" : "=a" (n) : "a" (0i32) : "ebx" , "ecx" , "edx");
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: couldn't allocate output register for constraint 'a'
    --> programs/../lib/decompress/zstd_decompress.rs:1053:9
     |
1053 | /         asm!("cpuid" : "=a" (f1a) , "=c" (f1c) , "=d" (f1d) : "a" (1i32) :
1054 | |              "ebx")
     | |___________________^

error: couldn't allocate output register for constraint 'a'
    --> programs/../lib/decompress/zstd_decompress.rs:1058:9
     |
1058 | /         asm!("cpuid" : "=a" (f7a) , "=b" (f7b) , "=c" (f7c) : "a" (7i32) , "c"
1059 | |              (0i32) : "edx")
     | |____________________________^

The assembly code originates from https://github.com/immunant/zstd/blob/dev/lib/common/cpu.h#L34-L110. Problem persists whether one builds with clang or gcc.

ast_exporter error after each file about -p

ast_exporter: for the -p option: may only occur zero or one times!

This error gets printed after each file and it stops. However if I rerun it, it progresses anyways and skips previously translated files, which after a quick visual inspection, didn't simply get outputted as empty files. I couldn't find anywhere this error might be coming from or any similar errors from Googling. I can complete this anyways, but it means running c2rust once for every file, or which the project I'm currently working on has 866.

Bug in translated Hilbert Curve generation code?

This is a copied StackOverflow question.

I found the following code for drawing Hilbert Curves on Wikipedia:

//convert (x,y) to d
int xy2d (int n, int x, int y) {
    int rx, ry, s, d=0;
    for (s=n/2; s>0; s/=2) {
        rx = (x & s) > 0;
        ry = (y & s) > 0;
        d += s * s * ((3 * rx) ^ ry);
        rot(s, &x, &y, rx, ry);
    }
    return d;
}

//convert d to (x,y)
void d2xy(int n, int d, int *x, int *y) {
    int rx, ry, s, t=d;
    *x = *y = 0;
    for (s=1; s<n; s*=2) {
        rx = 1 & (t/2);
        ry = 1 & (t ^ rx);
        rot(s, x, y, rx, ry);
        *x += s * rx;
        *y += s * ry;
        t /= 4;
    }
}

//rotate/flip a quadrant appropriately
void rot(int n, int *x, int *y, int rx, int ry) {
    if (ry == 0) {
        if (rx == 1) {
            *x = n-1 - *x;
            *y = n-1 - *y;
        }

        //Swap x and y
        int t  = *x;
        *x = *y;
        *y = t;
    }
}

I put it into c2rust.com with definition of rot() put as the first function and got the following code:

#![allow(dead_code,
         mutable_transmutes,
         non_camel_case_types,
         non_snake_case,
         non_upper_case_globals,
         unused_mut)]
#![feature(libc)]
extern crate libc;
// rotate/flip a quadrant appropriately
#[no_mangle]
pub unsafe extern "C" fn rot(mut n: libc::c_int,
                             mut x: *mut libc::c_int,
                             mut y: *mut libc::c_int,
                             mut rx: libc::c_int,
                             mut ry: libc::c_int)
                             -> () {
    if ry == 0i32 {
        if rx == 1i32 {
            *x = n - 1i32 - *x;
            *y = n - 1i32 - *y
        }
        // Swap x and y
        let mut t: libc::c_int = *x;
        *x = *y;
        *y = t
    };
}
// convert (x,y) to d
#[no_mangle]
pub unsafe extern "C" fn xy2d(mut n: libc::c_int,
                              mut x: libc::c_int,
                              mut y: libc::c_int)
                              -> libc::c_int {
    let mut rx: libc::c_int = 0;
    let mut ry: libc::c_int = 0;
    let mut s: libc::c_int = 0;
    let mut d: libc::c_int = 0i32;
    s = n / 2i32;
    while s > 0i32 {
        rx = (x & s > 0i32) as libc::c_int;
        ry = (y & s > 0i32) as libc::c_int;
        d += s * s * (3i32 * rx ^ ry);
        rot(s, &mut x, &mut y, rx, ry);
        s /= 2i32
    }
    return d;
}
// convert d to (x,y)
#[no_mangle]
pub unsafe extern "C" fn d2xy(mut n: libc::c_int,
                              mut d: libc::c_int,
                              mut x: *mut libc::c_int,
                              mut y: *mut libc::c_int)
                              -> () {
    let mut rx: libc::c_int = 0;
    let mut ry: libc::c_int = 0;
    let mut s: libc::c_int = 0;
    let mut t: libc::c_int = d;
    *y = 0i32;
    *x = *y;
    s = 1i32;
    while s < n {
        rx = 1i32 & t / 2i32;
        ry = 1i32 & (t ^ rx);
        rot(s, x, y, rx, ry);
        *x += s * rx;
        *y += s * ry;
        t /= 4i32;
        s *= 2i32
    }
}

fn main() {
    let mut x: libc::c_int = 0;
    let mut y: libc::c_int = 0;
    let d: libc::c_int = 10;
    unsafe {
        for n in 1..10 {
            d2xy(n, d, &mut x, &mut y);
            println!("n={}, x={}, y={}", n, x, y);
        }
    }
}

The problem is that the results seem to make no sense:

   Compiling x v0.1.0 (file:///tmp/x)
warning: value assigned to `rx` is never read                            ] 0/1: x                                                                                                                
  --> src/main.rs:34:13
   |
34 |     let mut rx: libc::c_int = 0;
   |             ^^
   |
   = note: #[warn(unused_assignments)] on by default

warning: value assigned to `ry` is never read
  --> src/main.rs:35:13
   |
35 |     let mut ry: libc::c_int = 0;
   |             ^^

warning: value assigned to `s` is never read
  --> src/main.rs:36:13
   |
36 |     let mut s: libc::c_int = 0;
   |             ^

warning: value assigned to `rx` is never read
  --> src/main.rs:55:13
   |
55 |     let mut rx: libc::c_int = 0;
   |             ^^

warning: value assigned to `ry` is never read
  --> src/main.rs:56:13
   |
56 |     let mut ry: libc::c_int = 0;
   |             ^^

warning: value assigned to `s` is never read
  --> src/main.rs:57:13
   |
57 |     let mut s: libc::c_int = 0;
   |             ^

    Finished dev [unoptimized + debuginfo] target(s) in 0.25s                                                                                                                                    
     Running `target/debug/x`
n=1, x=0, y=0
n=2, x=1, y=1
n=3, x=3, y=3
n=4, x=3, y=3
n=5, x=3, y=3
n=6, x=3, y=3
n=7, x=3, y=3
n=8, x=3, y=3
n=9, x=3, y=3

I definitely didn't expect repeated coordinates for different Ns. What could have gone wrong? Here's C test code for comparison:

int main() {
    int n=32, d=0, x=0, y=0;
    for (d=0; d<10; d++) {
        d2xy(n, d, &x, &y);
        printf("d=%d, x=%d, y=%d\n", d, x, y);
    }
}

And the expected output (as generated by C):

d=0, x=0, y=0
d=1, x=0, y=1
d=2, x=1, y=1
d=3, x=1, y=0
d=4, x=2, y=0
d=5, x=3, y=0
d=6, x=3, y=1
d=7, x=2, y=1
d=8, x=2, y=2
d=9, x=3, y=2

build failed

$ cargo build --release
warning: unused manifest key: package.edition
warning: unused manifest key: package.edition
warning: unused manifest key: package.edition
    Updating registry `https://github.com/rust-lang/crates.io-index`
warning: spurious network error (2 tries remaining): SSL error: unknown error; class=Net (12)
 Downloading regex v1.1.0                                                       
 Downloading env_logger v0.6.0                                                  
 Downloading log v0.4.6                                                         
 Downloading clap v2.32.0                                                       
 Downloading regex-syntax v0.6.4                                                
 Downloading memchr v2.1.2                                                      
 Downloading aho-corasick v0.6.9                                                
 Downloading utf8-ranges v1.0.2                                                 
 Downloading thread_local v0.3.6                                                
 Downloading ucd-util v0.1.3                                                    
 Downloading libc v0.2.46                                                       
 Downloading cfg-if v0.1.6                                                      
 Downloading version_check v0.1.5                                               
 Downloading lazy_static v1.2.0                                                 
 Downloading termcolor v1.0.4                                                   
 Downloading atty v0.2.11                                                       
 Downloading humantime v1.2.0                                                   
 Downloading quick-error v1.2.2                                                 
 Downloading diff v0.1.11                                                       
 Downloading json v0.11.13                                                      
 Downloading ena v0.11.0                                                        
 Downloading cargo v0.32.0                                                      
 Downloading indexmap v1.0.2                                                    
 Downloading unicode-width v0.1.5                                               
 Downloading bitflags v1.0.4                                                    
 Downloading yaml-rust v0.3.5                                                   
 Downloading textwrap v0.10.0                                                   
 Downloading strsim v0.7.0                                                      
 Downloading vec_map v0.8.1                                                     
 Downloading home v0.3.3                                                        
 Downloading serde v1.0.84                                                      
 Downloading ignore v0.4.6                                                      
 Downloading serde_ignored v0.0.4                                               
 Downloading git2-curl v0.8.2                                                   
 Downloading curl v0.4.19                                                       
 Downloading jobserver v0.1.12                                                  
 Downloading bytesize v1.0.0                                                    
 Downloading fs2 v0.4.3                                                         
 Downloading curl-sys v0.4.15                                                   
 Downloading crates-io v0.20.0                                                  
 Downloading hex v0.3.2                                                         
 Downloading semver v0.9.0                                                      
 Downloading failure v0.1.5                                                     
 Downloading git2 v0.7.5                                                        
 Downloading opener v0.3.2                                                      
 Downloading flate2 v1.0.6                                                      
 Downloading tar v0.4.20                                                        
 Downloading crossbeam-utils v0.5.0                                             
 Downloading env_logger v0.5.13                                                 
 Downloading glob v0.2.11                                                       
 Downloading filetime v0.2.4                                                    
 Downloading shell-escape v0.1.4                                                
 Downloading crypto-hash v0.3.3                                                 
 Downloading serde_json v1.0.34                                                 
 Downloading rustc-workspace-hack v1.0.0                                        
 Downloading serde_derive v1.0.84                                               
 Downloading rustfix v0.4.4                                                     
 Downloading libgit2-sys v0.7.11                                                
 Downloading lazycell v1.2.1                                                    
 Downloading url v1.7.2                                                         
 Downloading tempfile v3.0.5                                                    
 Downloading same-file v1.0.4                                                   
 Downloading toml v0.4.10                                                       
 Downloading num_cpus v1.9.0                                                    
 Downloading crossbeam-channel v0.3.6                                           
 Downloading globset v0.4.2                                                     
 Downloading walkdir v2.2.7                                                     
 Downloading parking_lot v0.7.1                                                 
 Downloading rand v0.6.3                                                        
 Downloading crossbeam-utils v0.6.3                                             
 Downloading smallvec v0.6.7                                                    
 Downloading lock_api v0.1.5                                                    
 Downloading parking_lot_core v0.4.0                                            
 Downloading owning_ref v0.4.0                                                  
 Downloading scopeguard v0.3.3                                                  
 Downloading stable_deref_trait v1.1.1                                          
 Downloading rand_hc v0.1.0                                                     
 Downloading rand_core v0.3.0                                                   
 Downloading rand_os v0.1.0                                                     
 Downloading rand_pcg v0.1.1                                                    
 Downloading rand_isaac v0.1.1                                                  
 Downloading rand_chacha v0.1.1                                                 
 Downloading rand_xorshift v0.1.1                                               
 Downloading rustc_version v0.2.3                                               
 Downloading semver-parser v0.7.0                                               
 Downloading autocfg v0.1.1                                                     
 Downloading unreachable v1.0.0                                                 
 Downloading void v1.0.2                                                        
 Downloading fnv v1.0.6                                                         
 Downloading percent-encoding v1.0.1                                            
 Downloading matches v0.1.8                                                     
 Downloading idna v0.1.5                                                        
 Downloading unicode-normalization v0.1.7                                       
 Downloading unicode-bidi v0.3.4                                                
 Downloading socket2 v0.3.8                                                     
 Downloading libnghttp2-sys v0.1.1                                              
 Downloading libz-sys v1.0.25                                                   
 Downloading cc v1.0.28                                                         
 Downloading pkg-config v0.3.14                                                 
 Downloading libssh2-sys v0.2.11                                                
 Downloading syn v0.15.24                                                       
 Downloading quote v0.6.10                                                      
 Downloading proc-macro2 v0.4.24                                                
 Downloading unicode-xid v0.1.0                                                 
 Downloading backtrace v0.3.13                                                  
 Downloading failure_derive v0.1.5                                              
 Downloading rustc-demangle v0.1.13                                             
 Downloading synstructure v0.10.1                                               
 Downloading itoa v0.4.3                                                        
 Downloading ryu v0.2.7                                                         
 Downloading crc32fast v1.1.2                                                   
 Downloading miniz-sys v0.1.11                                                  
 Downloading remove_dir_all v0.5.1                                              
 Downloading fern v0.5.7                                                        
 Downloading dtoa v0.4.3                                                        
 Downloading pathdiff v0.1.0                                                    
 Downloading serde_cbor v0.9.0                                                  
 Downloading strum_macros v0.13.0                                               
 Downloading itertools v0.8.0                                                   
 Downloading strum v0.13.0                                                      
 Downloading handlebars v1.1.0                                                  
 Downloading serde_bytes v0.10.4                                                
 Downloading half v1.3.0                                                        
 Downloading byteorder v1.2.7                                                   
 Downloading clang-sys v0.26.4                                                  
 Downloading bindgen v0.46.0                                                    
 Downloading cmake v0.1.35                                                      
 Downloading libloading v0.5.0                                                  
 Downloading which v2.0.1                                                       
 Downloading hashbrown v0.1.7                                                   
 Downloading peeking_take_while v0.1.2                                          
 Downloading cexpr v0.3.3                                                       
 Downloading nom v4.1.1                                                         
 Downloading colored v1.7.0                                                     
 Downloading heck v0.3.1                                                        
 Downloading unicode-segmentation v1.2.1                                        
 Downloading either v1.5.0                                                      
 Downloading pest_derive v2.1.0                                                 
 Downloading pest v2.1.0                                                        
 Downloading pest_generator v2.1.0                                              
 Downloading pest_meta v2.1.0                                                   
 Downloading maplit v1.0.1                                                      
 Downloading ucd-trie v0.1.1                                                    
 Downloading mdbook v0.2.2                                                      
 Downloading pulldown-cmark v0.2.0                                              
 Downloading pulldown-cmark-to-cmark v1.2.0                                     
 Downloading chrono v0.4.6                                                      
 Downloading iron v0.6.0                                                        
 Downloading ammonia v1.2.0                                                     
 Downloading staticfile v0.5.0                                                  
 Downloading error-chain v0.12.0                                                
 Downloading elasticlunr-rs v2.3.4                                              
 Downloading toml-query v0.7.0                                                  
 Downloading pulldown-cmark v0.1.2                                              
 Downloading ws v0.7.9                                                          
 Downloading itertools v0.7.11                                                  
 Downloading open v1.2.2                                                        
 Downloading notify v4.0.6                                                      
 Downloading shlex v0.1.1                                                       
 Downloading num-integer v0.1.39                                                
 Downloading time v0.1.41                                                       
 Downloading num-traits v0.2.6                                                  
 Downloading plugin v0.2.6                                                      
 Downloading log v0.3.9                                                         
 Downloading hyper v0.10.15                                                     
 Downloading typemap v0.3.3                                                     
 Downloading mime_guess v1.8.6                                                  
 Downloading modifier v0.1.0                                                    
 Downloading unsafe-any v0.4.2                                                  
 Downloading traitobject v0.1.0                                                 
 Downloading base64 v0.9.3                                                      
 Downloading unicase v1.4.2                                                     
 Downloading mime v0.2.6                                                        
 Downloading httparse v1.3.3                                                    
 Downloading language-tags v0.2.2                                               
 Downloading typeable v0.1.2                                                    
 Downloading safemem v0.3.0                                                     
 Downloading phf v0.7.24                                                        
 Downloading phf_shared v0.7.24                                                 
 Downloading siphasher v0.2.3                                                   
 Downloading phf_codegen v0.7.24                                                
 Downloading phf_generator v0.7.24                                              
 Downloading tendril v0.4.1                                                     
 Downloading html5ever v0.22.5                                                  
 Downloading utf-8 v0.7.5                                                       
 Downloading mac v0.1.1                                                         
 Downloading futf v0.1.4                                                        
 Downloading new_debug_unreachable v1.0.1                                       
 Downloading markup5ever v0.7.5                                                 
 Downloading string_cache v0.7.3                                                
 Downloading precomputed-hash v0.1.1                                            
 Downloading string_cache_shared v0.3.0                                         
 Downloading string_cache_codegen v0.4.2                                        
 Downloading mount v0.4.0                                                       
 Downloading sequence_trie v0.3.6                                               
 Downloading strum v0.11.0                                                      
 Downloading strum_macros v0.11.0                                               
 Downloading is-match v0.1.0                                                    
 Downloading getopts v0.2.18                                                    
 Downloading bitflags v0.9.1                                                    
 Downloading sha1 v0.6.0                                                        
 Downloading mio-extras v2.0.5                                                  
 Downloading rand v0.4.3                                                        
 Downloading mio v0.6.16                                                        
 Downloading slab v0.4.1                                                        
 Downloading bytes v0.4.11                                                      
 Downloading iovec v0.1.2                                                       
 Downloading net2 v0.2.33                                                       
 Downloading ansi_term v0.11.0                                                  
 Downloading openssl-sys v0.9.40                                                
 Downloading openssl-probe v0.1.2                                               
 Downloading backtrace-sys v0.1.28                                              
 Downloading openssl v0.10.16                                                   
 Downloading foreign-types v0.3.2                                               
 Downloading foreign-types-shared v0.1.1                                        
 Downloading inotify v0.6.1                                                     
 Downloading tokio-reactor v0.1.8                                               
 Downloading tokio-io v0.1.11                                                   
 Downloading inotify-sys v0.1.3                                                 
 Downloading futures v0.1.25                                                    
 Downloading tokio-executor v0.1.6                                              
   Compiling open v1.2.2                                                        
   Compiling foreign-types-shared v0.1.1
   Compiling mac v0.1.1
   Compiling utf8-ranges v1.0.2
   Compiling hex v0.3.2
   Compiling stable_deref_trait v1.1.1
   Compiling pkg-config v0.3.14
   Compiling vec_map v0.8.1
   Compiling c2rust v0.9.0 (file:///home/1828_sandbox/src/c2rust/c2rust)
   Compiling failure_derive v0.1.5
   Compiling crc32fast v1.1.2
   Compiling ucd-util v0.1.3
   Compiling bytesize v1.0.0
   Compiling openssl v0.10.16
   Compiling unicode-width v0.1.5
   Compiling num-traits v0.2.6
   Compiling glob v0.2.11
   Compiling sequence_trie v0.3.6
   Compiling remove_dir_all v0.5.1
   Compiling percent-encoding v1.0.1
   Compiling serde v1.0.84
   Compiling lazycell v1.2.1
   Compiling shell-escape v0.1.4
   Compiling semver-parser v0.7.0
   Compiling pulldown-cmark v0.2.0
   Compiling quick-error v1.2.2
   Compiling maplit v1.0.1
   Compiling version_check v0.1.5
   Compiling shlex v0.1.1
   Compiling fnv v1.0.6
   Compiling cc v1.0.28
   Compiling bindgen v0.46.0
   Compiling safemem v0.3.0
   Compiling pathdiff v0.1.0
   Compiling libc v0.2.46
   Compiling termcolor v1.0.4
   Compiling slab v0.4.1
   Compiling futures v0.1.25
   Compiling ucd-trie v0.1.1
   Compiling unicode-xid v0.1.0
   Compiling precomputed-hash v0.1.1
   Compiling itoa v0.4.3
   Compiling either v1.5.0
   Compiling json v0.11.13
   Compiling rustc-workspace-hack v1.0.0
   Compiling crossbeam-utils v0.5.0
error: the struct `#[repr(align(u16))]` attribute is experimental (see issue #33626)
  --> /home/1828_sandbox/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.5.0/src/cache_padded.rs:19:1
   |
19 | #[repr(align(64))]
   | ^^^^^^^^^^^^^^^^^^

error: non-string literals in attributes, or string literals in top-level positions, are experimental (see issue #34981)
  --> /home/1828_sandbox/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.5.0/src/cache_padded.rs:19:1
   |
19 | #[repr(align(64))]
   | ^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

   Compiling utf-8 v0.7.5
error: Could not compile `crossbeam-utils`.
warning: build failed, waiting for other jobs to finish...
error: invalid format string: expected `'}'`, found `'?'`
  --> /home/1828_sandbox/.cargo/registry/src/github.com-1ecc6299db9ec823/utf-8-0.7.5/src/read.rs:40:27
   |
40 |                 write!(f, "invalid byte sequence: {:02x?}", bytes)
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: invalid format string: expected `'}'`, found `'?'`
  --> /home/1828_sandbox/.cargo/registry/src/github.com-1ecc6299db9ec823/utf-8-0.7.5/src/lib.rs:42:17
   |
42 | /                 "found invalid byte sequence {invalid_sequence:02x?} after \
43 | |                  {valid_byte_count} valid bytes, followed by {unprocessed_byte_count} more \
44 | |                  unprocessed bytes",
   | |___________________________________^

error: invalid format string: expected `'}'`, found `'?'`
  --> /home/1828_sandbox/.cargo/registry/src/github.com-1ecc6299db9ec823/utf-8-0.7.5/src/lib.rs:54:17
   |
54 | /                 "found incomplete byte sequence {incomplete_suffix:02x?} after \
55 | |                  {valid_byte_count} bytes",
   | |__________________________________________^

error: aborting due to 3 previous errors

error: Could not compile `utf-8`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Ever-changing randomized translations

If I run ~/c2rust/scripts/transpile.py $PWD/compile_commands.json
the result is different upon each run.
This makes it very difficult to tell what has changed in the translations, especially if I'm trying to apply subtle changes to the C code in order to get a desired output in the transpiled rust

Rely on `libc` crate to further reduce imports?

I'm not sure to what extent this is feasible in practice, but all of the files I'm getting out of c2rust have very large blocks of extern items that could mostly be elided by relying on the libc crate's definition for those type signatures. Would that tactic cause issues for the semantics-preserving approach you've taken?

Ways to clean up C string literals before writing output?

This is pretty hard to parse even once you get used to it: b"contents\x00" as *const u8 as *const c_char. One way to reduce the noise while remaining correct would be to rely on a crate that lets you declare a C string literal like cstr-macro.

./scripts/build_translator.py fails on provided vagrant env

Since the latest release 2 days ago ./scripts/build_translator.py fails on provided vagrant env:

plumbum.commands.processes.ProcessExecutionError: Command line: ['/bin/tar', 'xf', '/home/vagrant/C2Rust/dependencies/cfe-6.0.1.src.tar.xz']
Exit code: 2
Stderr:  | /bin/tar: cfe-6.0.1.src/test/Driver/Inputs/multilib_32bit_linux_tree/usr/bin/ld: Cannot create symlink to ‘i386-unknown-linux-gnu-ld’: Protocol error

This is reproducible:

vagrant@vagrant:~/C2Rust/dependencies$ tar -xf /home/vagrant/C2Rust/dependencies/cfe-6.0.1.src.tar.xz
tar: cfe-6.0.1.src/test/Driver/Inputs/multilib_32bit_linux_tree/usr/bin/ld: Cannot create symlink to ‘i386-unknown-linux-gnu-ld’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/multilib_32bit_linux_tree/usr/bin/as: Cannot create symlink to ‘i386-unknown-linux-gnu-as’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/multilib_64bit_linux_tree/usr/bin/ld: Cannot create symlink to ‘x86_64-unknown-linux-gnu-ld’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/multilib_64bit_linux_tree/usr/bin/as: Cannot create symlink to ‘x86_64-unknown-linux-gnu-as’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/basic_cross_linux_tree/usr/x86_64-unknown-linux-gnu/bin/ld: Cannot create symlink to ‘ld.gold’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/basic_cross_linux_tree/usr/i386-unknown-linux-gnu/bin/ld: Cannot create symlink to ‘ld.gold’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/x86_64-unknown-linux-gnu-ld: Cannot create symlink to ‘x86_64-unknown-linux-gnu-ld.gold’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/basic_cross_linux_tree/usr/bin/i386-unknown-linux-gnu-ld: Cannot create symlink to ‘i386-unknown-linux-gnu-ld.gold’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/bin/as: Cannot create symlink to ‘../../bin/x86_64-unknown-linux-gnu-as’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/multilib_64bit_linux_tree/usr/x86_64-unknown-linux/bin/ld: Cannot create symlink to ‘../../bin/x86_64-unknown-linux-gnu-ld’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/bin/as: Cannot create symlink to ‘../../bin/i386-unknown-linux-gnu-as’: Protocol error
tar: cfe-6.0.1.src/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/bin/ld: Cannot create symlink to ‘../../bin/i386-unknown-linux-gnu-ld’: Protocol error
tar: Exiting with failure status due to previous errors

Handle simd intrinsics

For example it would be nice to be able to handle the following code:

#include <xmmintrin.h>
#include <emmintrin.h>

void
unpack_128_2x128 (__m128i data, __m128i* data_lo, __m128i* data_hi)
{
    *data_lo = _mm_unpacklo_epi8 (data, _mm_setzero_si128 ());
    *data_hi = _mm_unpackhi_epi8 (data, _mm_setzero_si128 ());
}

Use va_list-rs crate or core::ffi::VaList

I noticed C2rust has some support for va_list and seems to manually create the correct structure. If c2rust is expected to generate Rust for nightly channels you should be able to use core::ffi::VaList (NB: I've only really tested x86 and x86_64). If nightly is not an option and/or if more stability is desired, the va_list-rs crate works well.

packed struct is not translated correctly

#include <stdint.h>

typedef struct {
    uint64_t a;
    uint64_t b;
    uint16_t c;
    uint16_t d;
    uint8_t data[];
} __attribute__((__packed__))
message;

void print(message m) {
    
}

is translated to

extern crate libc;
pub type uint16_t = libc::c_ushort;
pub type uint8_t = libc::c_uchar;
pub type uint64_t = libc::c_ulong;
#[derive ( Copy , Clone )]
#[repr ( C )]
pub struct message {
    pub a: uint64_t,
    pub b: uint64_t,
    pub c: uint16_t,
    pub d: uint16_t,
    pub data: [uint8_t; 0],
}
#[no_mangle]
pub unsafe extern "C" fn print(mut m: message) -> () { }

when it should be #[repr(C, packed)]

size_t/ssize_t should be translated to usize/isize

(I'm not too familiar with the Rust ABI details...)

At least I can't think of a reason why it shouldn't be translated to that instead of:


pub type size_t = libc::c_ulong;

Ok, I guess it is picking up the typedef in the header and then instead of understanding the idea behind size_t, it just blindly translates the typedef.

Rust cross-checks are broken due to changes in rustc nightly

The rustc nightly bump broke some things in our cross-checking crates, most notably due to the removal of quote_expr! and friends. I'll have to fix all the problems manually, including replacing all quoting macros with manual AST builder calls.

Provide binaries

Since compiling c2rust takes a while it'd be nice if the CI process could provide binaries when creating a tag in this repository.

Run rustfmt on the output?

As the project moves towards designing the post-processing steps for the tool, would you consider adding a rustfmt step before writing the output? I think it would help to have a more human-friendly starting point after the initial conversion process.

Panic 'no entry found for key' when translating mruby 2.0.0

Seems to come from this map access. Happening on macOS 10.14.2, against both master and 0.9.0.

Repro steps (if not on Mac you'll need a recent Ruby installed):

  1. Download and extract [http://mruby.org/](mruby 2.0.0).

  2. Replace the build_config.rb file in the root of the extracted files with this minimal one:

    MRuby::Build.new do |conf|
      if ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
        toolchain :visualcpp
      else
        toolchain :gcc
      end
    end
  3. Run intercept-build ruby ./minirake to generate the compiler commands needed for c2rust.

  4. Run c2rust transpile compile_commands.json against the generated compile commands output.

Looks like it's struggling on something (complex macro expansions?) in include/mruby/array.h.

Support translation of C macros to Rust

A feature request that would make it easier to work around the know limitations of C macros and variadic functions: It would be cool if c2rust could take an annotation or similar and turn C macro invocations and variadic function invocations into Rust macro invocations, but leave the Rust macro undefined and to be manually ported by the user.

Failed translating declaration due to error: Unsupported vector default initializer: Int x 4, kind: Some(Function { is_extern: true, is_inline: true, is_implicit: false, typ: CTypeId(10934), name: "MyGetIP_comp", parameters: [CDeclId(23294)], body: Some(CStmtId(23293)) })'

I used the following input:

a.zip

Here's the result:

[19:27:38]  d33tah@d33tah-laptop:/tmp(101) > /home/d33tah/workspace/src/c2rust/target/release/c2rust transpile compile_commands.json --fail-on-error
Transpiling a.c
thread 'main' panicked at 'Failed translating declaration due to error: Unsupported vector default initializer: Int x 4, kind: Some(Function { is_extern: true, is_inline: true, is_implicit: false, typ: CTypeId(10934), name: "MyGetIP_comp", parameters: [CDeclId(23294)], body: Some(CStmtId(23293)) })', c2rust-transpile/src/translator/mod.rs:305:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Are there any plans to add support for this feature?

Publish c2rust-bitfields?

c2rust produces code that depends on c2rust-bitfields for compilation, but that crate is only available on github. Perhaps it should be made available on crates.io?

libsyntax not found on macOS

When attempting to run ast-importer I get this message:

dyld: Library not loaded: @rpath/libsyntax-5b61bedd79cd3694.dylib
  Referenced from: /<redacted>/c2rust/ast-importer/target.<redacted>/release/./ast_importer
  Reason: image not found
Abort trap: 6

Translation of variadic function pointers

Bug found while translating ioquake3. From ui_syscalls.c

static intptr_t (QDECL *syscall)( intptr_t arg, ... ) = (intptr_t (QDECL *)( intptr_t, ...))-1;

we get:

static mut syscall: Option<unsafe extern "C" fn(_: intptr_t) -> intptr_t> =
    unsafe {
        ::std::mem::transmute::<libc::intptr_t,
                                Option<unsafe extern "C" fn(_: intptr_t)
                                           ->
                                               intptr_t>>(-1i32 as
                                                              libc::intptr_t)
    };

Options to elide literal types in more places

The current output has many unnecessary explicit type declarations, especially for literal values. A simple example from the homepage:

let mut i: libc::c_int = 1i32;

While this is useful for cross-verifying one's C code, it would be nice to only have (at max) one type annotation on this line, since only one is necessary for the code to be correct.

_mm_slli_si128 breaks translation

The following code fails to translate:

#include <stdbool.h>
#include <stdint.h>
#include <tmmintrin.h>

void accumulate_non_zero_c(uint8_t *dst, int16_t *src, int len) {
    int i = 0;
    while (true) {
        __m128i a = _mm_loadu_si128((__m128i *) &src[i]);
        a = _mm_slli_si128(a, 2);
        _mm_storel_epi64((__m128i *) &dst[i], a);
        i += 8;
        /* breaking here saves one shuffle */
        if (i >= len)
            break;
    }
}

Removing 'a = _mm_slli_si128(a, 2);' makes it work

Signed integer uses wrapping_neg for -1 literal

Given my C declaration of

static pid_t pid = -1;

The code is translated into

static mut pid: pid_t = unsafe { 1i32.wrapping_neg() };

Which doesn't compile in Rust, since method calls aren't allowed in static declarations.

I expect it to be directly translated into a literal, like so:

static mut pid: pid_t = -1i32;

Static struct

I'm trying to translate ncurses for fun and I ran into a few files that contained a line like static const NCURSES_CH_T blankchar = NewChar(BLANK_TEXT);. When c2rust hit those files, it panicked with

thread 'main' panicked at 'internal error: entered unreachable code: Found static initializer type other than block or array: Struct(path(cchar_t), [Field { ident: attr#0, expr: expr(4294967040: ' ' as i32 as chtype & !1u32.wrapping_sub(1u32) << 0i32 + 8i32), span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, is_shorthand: false, attrs: ThinVec(None) }, Field { ident: chars#0, expr: expr(4294967040: [(' ' as i32 as chtype & (1u32 << 0i32 + 8i32).wrapping_sub(1u32)) as wchar_t, 0i32, 0i32, 0i32, 0i32]), span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, is_shorthand: false, attrs: ThinVec(None) }, Field { ident: ext_color#0, expr: expr(4294967040: 0i32), span: Span { lo: BytePos(0), hi: BytePos(0), ctxt: #0 }, is_shorthand: false, attrs: ThinVec(None) }], None)', c2rust-transpile/src/translator/mod.rs:897:26
note: Run with `RUST_BACKTRACE=1` for a backtrace.

The culprit is fairly clearly c2rust-transpile/src/translator/mod.rs#L897 and it seems like c2rust simply didn't expect this to happen. From what I can tell, it shouldn't be too hard to translate static struct initializers into rust especially since rust already supports them.

So far, I've been working around this by replacing the static structures with #defines.

glibc's assert(3) expansion causes most functions to be omitted

Thanks for this, this is a very interesting project.

I'm translating a large single file project, where most functions validate arguments using assert(3). All these functions are omitted from the generated rust. That was confusing me for a while, until I discovered the -a="--fail-on-error" option which gives a hint in the logfile:

DEBUG:root:thread 'main' panicked at 'Failed translating declaration due to error:
Statement expression didn't end in an expression: If { scrutinee: CExprId(13370),
true_variant: CStmtId(13371), false_variant: Some(CStmtId(13372)) },
kind: Some(Function { is_extern: false, is_inline: false, is_implicit: false,
typ: CTypeId(2606), name: "tdefl_flush_block",
parameters: [CDeclId(2609), CDeclId(2610)], body: Some(CStmtId(2608)) })',
src/translator.rs:251:9

That's weird, I thought, because this function contains no expression-flavour if statements. But it's actually the asserts, because glibc's assert here looks like:

#  define assert(expr)							\
  ((void) sizeof ((expr) ? 1 : 0), __extension__ ({			\
      if (expr)								\
        ; /* empty */							\
      else								\
        __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION);	\
    }))

Preprocessing-out asserts with -DNDEBUG fixes this.

Mistranslation of string literals

If I translate mz_error, I get:

#[derive ( Copy , Clone )]
#[repr(C)]
pub struct unnamed_4 {
    pub m_err: libc::c_int,
    pub m_pDesc: *const libc::c_char,
}

(...)

#[no_mangle]
pub unsafe extern "C" fn mz_error(mut err: libc::c_int)
 -> *const libc::c_char {
    static mut s_error_descs: [unnamed_4; 10] =
        unsafe {
            [unnamed_4{m_err: MZ_OK as libc::c_int,
                       m_pDesc: [0].as_ptr() as *mut _,},
             unnamed_4{m_err: MZ_STREAM_END as libc::c_int,
                       m_pDesc:
                           [115, 116, 114, 101, 97, 109, 32, 101, 110, 100,
                            0].as_ptr() as *mut _,},
(...)

However the type of the [115, 116, 114, ... array is [i32], so in memory this string looks like:

0x555555633410:	0x00000073	0x00000074	0x00000072	0x00000065
0x555555633420:	0x00000061	0x0000006d	0x00000020	0x00000065
0x555555633430:	0x0000006e	0x00000064	0x00000000	0x0000006e

But it should be:

0x555555633410:	0x65727473	0x65206d61	0x6e00646e	0x20646565

(little endian)

Naturally marking up one of the integers as u8 sorts this out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.