#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ constraints_name_to_types(char *, int *, int *, int *,
                                             int *);
int /*<<< orphan*/ count_constrained_walks(int, int, int, int, int, int, char *,
                                           int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int sscanf(char *, char *, int *, ...);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  char *conarg = 0;
  char *Narg = 0;
  int self_avoidance = -999;
  int location_constraint = -99;
  int p = 0;
  int q = 0;
  int argi;
  int Nmin = 1;
  int Nmax = 15;
  FILE *walk_fp = NULL;
  if (argc < 3)
    usage(argv[0]);
  conarg = argv[1];
  Narg = argv[2];
  if (sscanf(argv[2], "%d-%d", &Nmin, &Nmax) == 2)
    ;
  else if (sscanf(argv[2], "%d", &Nmax) == 1)
    Nmin = Nmax;
  else
    usage(argv[0]);
  for (argi = 3; argi < argc; argi++) {
    if (strcmp(argv[argi], "stdout") == 0)
      walk_fp = stdout;
    else if (strcmp(argv[argi], "stderr") == 0)
      walk_fp = stderr;
    else
      usage(argv[0]);
  }
  if (Nmin > Nmax) {
    fprintf(stderr, "Must have Nmin <= Nmax; got %d and %d.\n", Nmin, Nmax);
    exit(1);
  }
  if (!constraints_name_to_types(conarg, &self_avoidance, &location_constraint,
                                 &p, &q)) {
    exit(1);
  }
  count_constrained_walks(Nmin, Nmax, self_avoidance, location_constraint, p, q,
                          conarg, walk_fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0xfffffc19,-0x24(%rbp)
movl   $0xffffff9d,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x1,-0x38(%rbp)
movl   $0xf,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11de <main+0x6e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdfb(%rip),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmp    $0x2,%eax
jne    1222 <main+0xb2>
jmp    1261 <main+0xf1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdd2(%rip),%rsi
lea    -0x3c(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    1250 <main+0xe0>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    125c <main+0xec>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <usage@plt>
jmp    1261 <main+0xf1>
movl   $0x3,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1302 <main+0x192>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd7f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12a9 <main+0x139>
mov    0x2d3b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    12ef <main+0x17f>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd51(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12de <main+0x16e>
mov    0x2d0e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    12ea <main+0x17a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <usage@plt>
jmp    12ef <main+0x17f>
jmp    12f4 <main+0x184>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1268 <main+0xf8>
mov    -0x38(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jle    1334 <main+0x1c4>
mov    0x2ccb(%rip),%rax
mov    (%rax),%rdi
mov    -0x38(%rbp),%edx
mov    -0x3c(%rbp),%ecx
lea    0xcef(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1060 <constraints_name_to_types@plt>
cmp    $0x0,%eax
jne    1360 <main+0x1f0>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
mov    -0x18(%rbp),%r10
mov    -0x48(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <count_constrained_walks@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0xfffffc19,0x1c(%rsp)
ff
movl   $0xffffff9d,0x18(%rsp)
ff
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x1,0xc(%rsp)
movl   $0xf,0x8(%rsp)
cmp    $0x2,%edi
jg     11c0 <main+0x50>
mov    (%rbx),%rdi
call   1080 <usage@plt>
mov    0x8(%rbx),%rax
mov    %rax,0x20(%rsp)
mov    0x10(%rbx),%rdi
lea    0xe2c(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   1070 <sscanf@plt>
cmp    $0x2,%eax
je     120e <main+0x9e>
mov    0x10(%rbx),%rdi
lea    0xe0e(%rip),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
cmp    $0x1,%eax
jne    1279 <main+0x109>
mov    0x8(%rsp),%eax
mov    %eax,0xc(%rsp)
cmp    $0x4,%ebp
jl     1286 <main+0x116>
mov    %ebp,%ebp
mov    $0x3,%r14d
xor    %r12d,%r12d
lea    0xde1(%rip),%r13
lea    0xde1(%rip),%r15
jmp    1243 <main+0xd3>
xchg   %ax,%ax
mov    0x2da1(%rip),%rax
mov    (%rax),%r12
add    $0x1,%r14
cmp    %r14,%rbp
je     1289 <main+0x119>
mov    (%rbx,%r14,8),%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1230 <main+0xc0>
mov    (%rbx,%r14,8),%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1270 <main+0x100>
mov    (%rbx),%rdi
call   1080 <usage@plt>
jmp    123a <main+0xca>
nop
mov    0x2d69(%rip),%rax
jmp    1237 <main+0xc7>
mov    (%rbx),%rdi
call   1080 <usage@plt>
cmp    $0x4,%ebp
jge    1213 <main+0xa3>
xor    %r12d,%r12d
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
cmp    %ecx,%edx
jg     12f1 <main+0x181>
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <constraints_name_to_types@plt>
test   %eax,%eax
je     1307 <main+0x197>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x1c(%rsp),%edx
mov    0x18(%rsp),%ecx
mov    0x14(%rsp),%r8d
mov    0x10(%rsp),%r9d
push   %r12
push   %rbx
call   1030 <count_constrained_walks@plt>
add    $0x10,%rsp
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ce8(%rip),%rax
mov    (%rax),%rdi
lea    0xd12(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%d-%d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"stdout\00"
@stdout = global i32* null
@.str.3 = [7 x i8] c"stderr\00"
@stderr = global i32* null
@.str.4 = [40 x i8] c"Must have Nmin <= Nmax; got %d and %d.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i32 -999, i32* %8
store i32 -99, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 1, i32* %13
store i32 15, i32* %14
store i32* null, i32** %15
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @usage(i8* %21)
br label %23
23: ; preds = %18, %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %6
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
store i8* %29, i8** %7
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %13, i32* %14)
%34 = icmp eq i32 %33, 2
br i1 %34, label %35, label %36
35: ; preds = %23
br label %50
36: ; preds = %23
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = load i32, i32* %14
store i32 %43, i32* %13
br label %49
44: ; preds = %36
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = call i32 @usage(i8* %47)
br label %49
49: ; preds = %44, %42
br label %50
50: ; preds = %49, %35
store i32 3, i32* %12
br label %51
51: ; preds = %82, %50
%52 = load i32, i32* %12
%53 = load i32, i32* %4
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %85
55: ; preds = %51
%56 = load i8**, i8*** %5
%57 = load i32, i32* %12
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %56, i64 %58
%60 = load i8*, i8** %59
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %55
%64 = load i32*, i32** @stdout
store i32* %64, i32** %15
br label %81
65: ; preds = %55
%66 = load i8**, i8*** %5
%67 = load i32, i32* %12
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = call i64 @strcmp(i8* %70, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %65
%74 = load i32*, i32** @stderr
store i32* %74, i32** %15
br label %80
75: ; preds = %65
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 0
%78 = load i8*, i8** %77
%79 = call i32 @usage(i8* %78)
br label %80
80: ; preds = %75, %73
br label %81
81: ; preds = %80, %63
br label %82
82: ; preds = %81
%83 = load i32, i32* %12
%84 = add nsw i32 %83, 1
store i32 %84, i32* %12
br label %51
85: ; preds = %51
%86 = load i32, i32* %13
%87 = load i32, i32* %14
%88 = icmp sgt i32 %86, %87
br i1 %88, label %89, label %95
89: ; preds = %85
%90 = load i32*, i32** @stderr
%91 = load i32, i32* %13
%92 = load i32, i32* %14
%93 = call i32 @fprintf(i32* %90, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %91, i32 %92)
%94 = call i32 @exit(i32 1)
unreachable
95: ; preds = %85
%96 = load i8*, i8** %6
%97 = call i32 @constraints_name_to_types(i8* %96, i32* %8, i32* %9, i32* %10, i32* %11)
%98 = icmp ne i32 %97, 0
br i1 %98, label %101, label %99
99: ; preds = %95
%100 = call i32 @exit(i32 1)
unreachable
101: ; preds = %95
%102 = load i32, i32* %13
%103 = load i32, i32* %14
%104 = load i32, i32* %8
%105 = load i32, i32* %9
%106 = load i32, i32* %10
%107 = load i32, i32* %11
%108 = load i8*, i8** %6
%109 = load i32*, i32** %15
%110 = call i32 @count_constrained_walks(i32 %102, i32 %103, i32 %104, i32 %105, i32 %106, i32 %107, i8* %108, i32* %109)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d-%d\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [7 x i8] c"stdout\00"
@stdout = global i32* null
@.str.3 = [7 x i8] c"stderr\00"
@stderr = global i32* null
@.str.4 = [40 x i8] c"Must have Nmin <= Nmax; got %d and %d.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
store i32 -999, i32* %3
%10 = bitcast i32* %4 to i8*
store i32 -99, i32* %4
%11 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%13 = bitcast i32* %7 to i8*
store i32 1, i32* %7
%14 = bitcast i32* %8 to i8*
store i32 15, i32* %8
%15 = icmp slt i32 %0, 3
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i8*, i8** %1
%18 = tail call i32 @usage(i8* %17)
br label %19
19: ; preds = %16, %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %8)
%25 = icmp eq i32 %24, 2
br i1 %25, label %35, label %26
26: ; preds = %19
%27 = load i8*, i8** %22
%28 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = load i32, i32* %8
store i32 %31, i32* %7
br label %35
32: ; preds = %26
%33 = load i8*, i8** %1
%34 = call i32 @usage(i8* %33)
br label %35
35: ; preds = %30, %32, %19
%36 = icmp sgt i32 %0, 3
br i1 %36, label %37, label %61
37: ; preds = %35
%38 = zext i32 %0 to i64
br label %39
39: ; preds = %37, %57
%40 = phi i64 [ 3, %37 ], [ %59, %57 ]
%41 = phi i32* [ null, %37 ], [ %58, %57 ]
%42 = getelementptr inbounds i8*, i8** %1, i64 %40
%43 = load i8*, i8** %42
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %39
%47 = load i32*, i32** @stdout
br label %57
48: ; preds = %39
%49 = load i8*, i8** %42
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = load i32*, i32** @stderr
br label %57
54: ; preds = %48
%55 = load i8*, i8** %1
%56 = call i32 @usage(i8* %55)
br label %57
57: ; preds = %46, %54, %52
%58 = phi i32* [ %47, %46 ], [ %53, %52 ], [ %41, %54 ]
%59 = add nuw nsw i64 %40, 1
%60 = icmp eq i64 %59, %38
br i1 %60, label %61, label %39
61: ; preds = %57, %35
%62 = phi i32* [ null, %35 ], [ %58, %57 ]
%63 = load i32, i32* %7
%64 = load i32, i32* %8
%65 = icmp sgt i32 %63, %64
br i1 %65, label %66, label %70
66: ; preds = %61
%67 = load i32*, i32** @stderr
%68 = call i32 @fprintf(i32* %67, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %63, i32 %64)
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %61
%71 = call i32 @constraints_name_to_types(i8* %21, i32* %3, i32* %4, i32* %5, i32* %6)
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %70
%76 = load i32, i32* %7
%77 = load i32, i32* %8
%78 = load i32, i32* %3
%79 = load i32, i32* %4
%80 = load i32, i32* %5
%81 = load i32, i32* %6
%82 = call i32 @count_constrained_walks(i32 %76, i32 %77, i32 %78, i32 %79, i32 %80, i32 %81, i8* %21, i32* %62)
ret i32 0
}