#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 */
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ const member_1;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ error_exit();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ generate_counter_example(char *, char *, char *,
                                            int /*<<< orphan*/ *);
int /*<<< orphan*/ generate_counter_example_full(char *, char *, char *, char *,
                                                 char *, int /*<<< orphan*/ *);
int getopt_long(int, char **, char *, struct option *, int *);
char *malloc(scalar_t__);
#define no_argument 129
char *optarg;
int optind;
int /*<<< orphan*/ printf(char *, ...);
#define required_argument 128
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int main(int argc, char **argv) {
  int c;
  int help_opt = 0;
  char *cbmc_xml = NULL;
  char *cbmc_c_input = NULL;
  char *simpl_pol = NULL;
  char *simpl_log = NULL;
  char *out_name = NULL;
  char *arbac_file = NULL;
  static struct option long_options[] = {{"help", no_argument, 0, 'h'},
                                         {0, 0, 0, 0}};
  while (1) {
    int option_index = 0;
    c = getopt_long(argc, argv, "hx:c:p:l:o:", long_options, &option_index);
    if (c == -1)
      break;
    static struct option long_options[] = {
        {"cbmc-xml", required_argument, 0, 'x'},
        {"cbmc-input", required_argument, 0, 'c'},
        {"simplified-policy", required_argument, 0, 'p'},
        {"simplified-log", required_argument, 0, 'l'},
        {"out", required_argument, 0, 'o'},
        {"help", no_argument, 0, 'h'},
        {0, 0, 0, 0}};
    switch (c) {
    case 'h':
      printf(
          "Counter Example Generator for VAC\n"
          "Usage: counterexample OPTIONS ARBAC_FILE\n"
          "OPTIONS:\n"
          "  -x,--cbmc-xml          {XML_FILE}                Mandatory: the "
          "XML file got from CBMC on the translated ABRAC policies\n"
          "  -c,--cbmc-input        {TRANSLATED_FILE}         Mandatory: is "
          "the program for CBMC that is translated from ABRAC policies\n"
          "  -p,--simplified-policy {ARBAC_SIMPLIFIED_FILE}   If "
          "simplification: is the simplified of ARBAC policies\n"
          "  -d,--simplified-debug  {SIMPLIFY_DEBUG_FILE}     If "
          "simplification: is the recorded debug information of simplification "
          "process (invoke ./simplify -g command)\n"
          "  -o,--out               {filename}                Optional: "
          "Specify the output file (default=stdout)\n"
          "  -h,--help                                        Shows this "
          "message then exit\n"
          "  ARBAC_FILE is the original (not simplfiedied) ARBAC policies\n");
      help_opt = 1;
      exit(EXIT_SUCCESS);
      break;
    case 'x':
      cbmc_xml = malloc(strlen(optarg) + 1);
      strcpy(cbmc_xml, optarg);
      break;
    case 'c':
      cbmc_c_input = malloc(strlen(optarg) + 1);
      strcpy(cbmc_c_input, optarg);
      break;
    case 'p':
      simpl_pol = malloc(strlen(optarg) + 1);
      strcpy(simpl_pol, optarg);
      break;
    case 'l':
      simpl_log = malloc(strlen(optarg) + 1);
      strcpy(simpl_log, optarg);
      break;
    case 'o':
      out_name = malloc(strlen(optarg) + 1);
      strcpy(out_name, optarg);
      break;
    default:
      error_exit();
    }
  }
  if (optind < argc) {
    FILE *out_file = NULL;
    arbac_file = malloc(strlen(argv[optind]) + 1);
    strcpy(arbac_file, argv[optind]);
    if (out_name == NULL) {
      out_file = stdout;
    } else {
      out_file = fopen(out_name, "w");
      if (out_file == NULL) {
        printf("Cannot save in %s.\n", out_name);
        error_exit();
      }
    }
    if (cbmc_xml != NULL && cbmc_c_input != NULL && simpl_pol != NULL &&
        simpl_log != NULL && arbac_file != NULL) {
      generate_counter_example_full(cbmc_xml, cbmc_c_input, simpl_pol,
                                    simpl_log, arbac_file, out_file);
    } else if (cbmc_xml != NULL && cbmc_c_input != NULL && arbac_file != NULL) {
      generate_counter_example(cbmc_xml, cbmc_c_input, arbac_file, out_file);
    } else {
      error_exit();
    }
    if (out_name != NULL) {
      fclose(out_file);
    }
    return EXIT_SUCCESS;
  } else if (!help_opt) {
    error_exit();
  }
  return EXIT_SUCCESS;
}


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)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe4b(%rip),%rdx
lea    0x2e67(%rip),%rcx
lea    -0x4c(%rbp),%r8
call   1060 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1234 <main+0x84>
jmp    139f <main+0x1ef>
mov    -0x14(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0x15,%eax
ja     1393 <main+0x1e3>
mov    -0x60(%rbp),%rax
lea    0xdac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2d4e(%rip),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
jmp    139a <main+0x1ea>
mov    0x2d3a(%rip),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2d17(%rip),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
jmp    139a <main+0x1ea>
mov    0x2d03(%rip),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2ce0(%rip),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
jmp    139a <main+0x1ea>
mov    0x2ccc(%rip),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x2ca9(%rip),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
jmp    139a <main+0x1ea>
mov    0x2c95(%rip),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    0x2c72(%rip),%rax
mov    (%rax),%rsi
call   1030 <strcpy@plt>
jmp    139a <main+0x1ea>
mov    $0x0,%al
call   1080 <error_exit@plt>
jmp    11fd <main+0x4d>
mov    0x2c3a(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    151b <main+0x36b>
movq   $0x0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2c1c(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x2bf1(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcpy@plt>
cmpq   $0x0,-0x40(%rbp)
jne    1419 <main+0x269>
mov    0x2bc3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    1456 <main+0x2a6>
mov    -0x40(%rbp),%rdi
lea    0xfca(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1451 <main+0x2a1>
mov    -0x40(%rbp),%rsi
lea    0xfad(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1080 <error_exit@plt>
jmp    1456 <main+0x2a6>
cmpq   $0x0,-0x20(%rbp)
je     14af <main+0x2ff>
cmpq   $0x0,-0x28(%rbp)
je     14af <main+0x2ff>
cmpq   $0x0,-0x30(%rbp)
je     14af <main+0x2ff>
cmpq   $0x0,-0x38(%rbp)
je     14af <main+0x2ff>
cmpq   $0x0,-0x48(%rbp)
je     14af <main+0x2ff>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x48(%rbp),%r8
mov    -0x58(%rbp),%r9
call   10c0 <generate_counter_example_full@plt>
jmp    14f6 <main+0x346>
cmpq   $0x0,-0x20(%rbp)
je     14ea <main+0x33a>
cmpq   $0x0,-0x28(%rbp)
je     14ea <main+0x33a>
cmpq   $0x0,-0x48(%rbp)
je     14ea <main+0x33a>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x58(%rbp),%rcx
call   10b0 <generate_counter_example@plt>
jmp    14f1 <main+0x341>
mov    $0x0,%al
call   1080 <error_exit@plt>
jmp    14f6 <main+0x346>
cmpq   $0x0,-0x40(%rbp)
je     150a <main+0x35a>
mov    -0x58(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2ab7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    153d <main+0x38d>
cmpl   $0x0,-0x18(%rbp)
jne    152c <main+0x37c>
mov    $0x0,%al
call   1080 <error_exit@plt>
jmp    1531 <main+0x381>
mov    0x2a90(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%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    $0x38,%rsp
mov    %rsi,%rbp
mov    %edi,%r14d
lea    0x2eb5(%rip),%r12
lea    0x24(%rsp),%r13
lea    0xe19(%rip),%r15
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %eax,%eax
mov    %rax,0x28(%rsp)
xor    %eax,%eax
mov    %rax,0x30(%rsp)
jmp    123b <main+0x7b>
mov    0x2de5(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   10a0 <malloc@plt>
mov    %rax,0x10(%rsp)
nopl   0x0(%rax)
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movl   $0x0,0x24(%rsp)
mov    %r14d,%edi
mov    %rbp,%rsi
lea    0xe0d(%rip),%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1070 <getopt_long@plt>
lea    -0x63(%rax),%ecx
cmp    $0x15,%ecx
ja     1301 <main+0x141>
movslq (%r15,%rcx,4),%rax
add    %r15,%rax
jmp    *%rax
mov    0x2d81(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   10a0 <malloc@plt>
mov    %rax,0x18(%rsp)
jmp    1230 <main+0x70>
mov    0x2d5f(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   10a0 <malloc@plt>
mov    %rax,0x28(%rsp)
jmp    1230 <main+0x70>
mov    0x2d3a(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   10a0 <malloc@plt>
mov    %rax,0x30(%rsp)
jmp    1230 <main+0x70>
mov    0x2d15(%rip),%rax
mov    (%rax),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   10a0 <malloc@plt>
mov    %rax,0x8(%rsp)
jmp    1230 <main+0x70>
cmp    $0xffffffff,%eax
je     1312 <main+0x152>
xor    %eax,%eax
call   1090 <error_exit@plt>
jmp    123b <main+0x7b>
mov    0x2cc7(%rip),%rax
movslq (%rax),%rax
cmp    %r14d,%eax
jge    1392 <main+0x1d2>
mov    0x0(%rbp,%rax,8),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdi
call   10a0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    0x30(%rsp),%r15
test   %r15,%r15
je     139e <main+0x1de>
lea    0xd13(%rip),%rsi
mov    %r15,%rdi
call   10b0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
mov    0x18(%rsp),%r12
mov    0x10(%rsp),%r13
mov    0x8(%rsp),%rbx
jne    13b7 <main+0x1f7>
lea    0xcef(%rip),%rdi
xor    %r14d,%r14d
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
call   1090 <error_exit@plt>
jmp    13b7 <main+0x1f7>
xor    %eax,%eax
call   1090 <error_exit@plt>
jmp    1430 <main+0x270>
mov    0x2c2b(%rip),%rax
mov    (%rax),%r14
mov    0x18(%rsp),%r12
mov    0x10(%rsp),%r13
mov    0x8(%rsp),%rbx
test   %r13,%r13
setne  %cl
test   %r12,%r12
setne  %al
and    %cl,%al
cmp    $0x1,%al
mov    0x28(%rsp),%rcx
jne    13f8 <main+0x238>
test   %rbx,%rbx
je     13f8 <main+0x238>
test   %rcx,%rcx
je     13f8 <main+0x238>
test   %rbp,%rbp
je     13f8 <main+0x238>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %rbp,%r8
mov    %r14,%r9
call   10d0 <generate_counter_example_full@plt>
test   %r15,%r15
jne    1428 <main+0x268>
jmp    1430 <main+0x270>
test   %rbp,%rbp
sete   %cl
xor    $0x1,%al
or     %cl,%al
jne    141c <main+0x25c>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %r14,%rcx
call   10c0 <generate_counter_example@plt>
test   %r15,%r15
jne    1428 <main+0x268>
jmp    1430 <main+0x270>
xor    %eax,%eax
call   1090 <error_exit@plt>
test   %r15,%r15
je     1430 <main+0x270>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    0x2b91(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc30(%rip),%rdi
call   1040 <puts@plt>
mov    0x2b6d(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32, i32 }
@main.long_options = internal global [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [12 x i8] c"hx:c:p:l:o:\00"
@main.long_options.2 = internal global [7 x %struct.option] [%struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i32 0, i32 0), i8 -128, i32 0, i32 120 }, %struct.option { i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i32 0, i32 0), i8 -128, i32 0, i32 99 }, %struct.option { i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i32 0, i32 0), i8 -128, i32 0, i32 112 }, %struct.option { i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i32 0, i32 0), i8 -128, i32 0, i32 108 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i8 -128, i32 0, i32 111 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option zeroinitializer]
@.str.3 = [9 x i8] c"cbmc-xml\00"
@.str.4 = [11 x i8] c"cbmc-input\00"
@.str.5 = [18 x i8] c"simplified-policy\00"
@.str.6 = [15 x i8] c"simplified-log\00"
@.str.7 = [4 x i8] c"out\00"
@.str.8 = [844 x i8] c"Counter Example Generator for VAC\0AUsage: counterexample OPTIONS ARBAC_FILE\0AOPTIONS:\0A -x,--cbmc-xml {XML_FILE} Mandatory: the XML file got from CBMC on the translated ABRAC policies\0A -c,--cbmc-input {TRANSLATED_FILE} Mandatory: is the program for CBMC that is translated from ABRAC policies\0A -p,--simplified-policy {ARBAC_SIMPLIFIED_FILE} If simplification: is the simplified of ARBAC policies\0A -d,--simplified-debug {SIMPLIFY_DEBUG_FILE} If simplification: is the recorded debug information of simplification process (invoke ./simplify -g command)\0A -o,--out {filename} Optional: Specify the output file (default=stdout)\0A -h,--help Shows this message then exit\0A ARBAC_FILE is the original (not simplfiedied) ARBAC policies\0A\00"
@EXIT_SUCCESS = global i32 0
@optarg = global i8* null
@optind = global i32 0
@stdout = global i32* null
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [20 x i8] c"Cannot save in %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %10
store i8* null, i8** %11
store i8* null, i8** %12
store i8* null, i8** %13
br label %16
16: ; preds = %2, %71
store i32 0, i32* %14
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call i32 @getopt_long(i32 %17, i8** %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %14)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %23
22: ; preds = %16
br label %72
23: ; preds = %16
%24 = load i32, i32* %6
switch i32 %24, label %69 [
i32 104, label %25
i32 120, label %29
i32 99, label %37
i32 112, label %45
i32 108, label %53
i32 111, label %61
]
25: ; preds = %23
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([844 x i8], [844 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %7
%27 = load i32, i32* @EXIT_SUCCESS
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %23
%30 = load i8*, i8** @optarg
%31 = call i64 @strlen(i8* %30)
%32 = add nsw i64 %31, 1
%33 = call i8* @malloc(i64 %32)
store i8* %33, i8** %8
%34 = load i8*, i8** %8
%35 = load i8*, i8** @optarg
%36 = call i32 @strcpy(i8* %34, i8* %35)
br label %71
37: ; preds = %23
%38 = load i8*, i8** @optarg
%39 = call i64 @strlen(i8* %38)
%40 = add nsw i64 %39, 1
%41 = call i8* @malloc(i64 %40)
store i8* %41, i8** %9
%42 = load i8*, i8** %9
%43 = load i8*, i8** @optarg
%44 = call i32 @strcpy(i8* %42, i8* %43)
br label %71
45: ; preds = %23
%46 = load i8*, i8** @optarg
%47 = call i64 @strlen(i8* %46)
%48 = add nsw i64 %47, 1
%49 = call i8* @malloc(i64 %48)
store i8* %49, i8** %10
%50 = load i8*, i8** %10
%51 = load i8*, i8** @optarg
%52 = call i32 @strcpy(i8* %50, i8* %51)
br label %71
53: ; preds = %23
%54 = load i8*, i8** @optarg
%55 = call i64 @strlen(i8* %54)
%56 = add nsw i64 %55, 1
%57 = call i8* @malloc(i64 %56)
store i8* %57, i8** %11
%58 = load i8*, i8** %11
%59 = load i8*, i8** @optarg
%60 = call i32 @strcpy(i8* %58, i8* %59)
br label %71
61: ; preds = %23
%62 = load i8*, i8** @optarg
%63 = call i64 @strlen(i8* %62)
%64 = add nsw i64 %63, 1
%65 = call i8* @malloc(i64 %64)
store i8* %65, i8** %12
%66 = load i8*, i8** %12
%67 = load i8*, i8** @optarg
%68 = call i32 @strcpy(i8* %66, i8* %67)
br label %71
69: ; preds = %23
%70 = call i32 (...) @error_exit()
br label %71
71: ; preds = %69, %61, %53, %45, %37, %29
br label %16
72: ; preds = %22
%73 = load i32, i32* @optind
%74 = load i32, i32* %4
%75 = icmp slt i32 %73, %74
br i1 %75, label %76, label %155
76: ; preds = %72
store i32* null, i32** %15
%77 = load i8**, i8*** %5
%78 = load i32, i32* @optind
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %77, i64 %79
%81 = load i8*, i8** %80
%82 = call i64 @strlen(i8* %81)
%83 = add nsw i64 %82, 1
%84 = call i8* @malloc(i64 %83)
store i8* %84, i8** %13
%85 = load i8*, i8** %13
%86 = load i8**, i8*** %5
%87 = load i32, i32* @optind
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8*, i8** %86, i64 %88
%90 = load i8*, i8** %89
%91 = call i32 @strcpy(i8* %85, i8* %90)
%92 = load i8*, i8** %12
%93 = icmp eq i8* %92, null
br i1 %93, label %94, label %96
94: ; preds = %76
%95 = load i32*, i32** @stdout
store i32* %95, i32** %15
br label %106
96: ; preds = %76
%97 = load i8*, i8** %12
%98 = call i32* @fopen(i8* %97, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %98, i32** %15
%99 = load i32*, i32** %15
%100 = icmp eq i32* %99, null
br i1 %100, label %101, label %105
101: ; preds = %96
%102 = load i8*, i8** %12
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* %102)
%104 = call i32 (...) @error_exit()
br label %105
105: ; preds = %101, %96
br label %106
106: ; preds = %105, %94
%107 = load i8*, i8** %8
%108 = icmp ne i8* %107, null
br i1 %108, label %109, label %129
109: ; preds = %106
%110 = load i8*, i8** %9
%111 = icmp ne i8* %110, null
br i1 %111, label %112, label %129
112: ; preds = %109
%113 = load i8*, i8** %10
%114 = icmp ne i8* %113, null
br i1 %114, label %115, label %129
115: ; preds = %112
%116 = load i8*, i8** %11
%117 = icmp ne i8* %116, null
br i1 %117, label %118, label %129
118: ; preds = %115
%119 = load i8*, i8** %13
%120 = icmp ne i8* %119, null
br i1 %120, label %121, label %129
121: ; preds = %118
%122 = load i8*, i8** %8
%123 = load i8*, i8** %9
%124 = load i8*, i8** %10
%125 = load i8*, i8** %11
%126 = load i8*, i8** %13
%127 = load i32*, i32** %15
%128 = call i32 @generate_counter_example_full(i8* %122, i8* %123, i8* %124, i8* %125, i8* %126, i32* %127)
br label %147
129: ; preds = %118, %115, %112, %109, %106
%130 = load i8*, i8** %8
%131 = icmp ne i8* %130, null
br i1 %131, label %132, label %144
132: ; preds = %129
%133 = load i8*, i8** %9
%134 = icmp ne i8* %133, null
br i1 %134, label %135, label %144
135: ; preds = %132
%136 = load i8*, i8** %13
%137 = icmp ne i8* %136, null
br i1 %137, label %138, label %144
138: ; preds = %135
%139 = load i8*, i8** %8
%140 = load i8*, i8** %9
%141 = load i8*, i8** %13
%142 = load i32*, i32** %15
%143 = call i32 @generate_counter_example(i8* %139, i8* %140, i8* %141, i32* %142)
br label %146
144: ; preds = %135, %132, %129
%145 = call i32 (...) @error_exit()
br label %146
146: ; preds = %144, %138
br label %147
147: ; preds = %146, %121
%148 = load i8*, i8** %12
%149 = icmp ne i8* %148, null
br i1 %149, label %150, label %153
150: ; preds = %147
%151 = load i32*, i32** %15
%152 = call i32 @fclose(i32* %151)
br label %153
153: ; preds = %150, %147
%154 = load i32, i32* @EXIT_SUCCESS
store i32 %154, i32* %3
br label %163
155: ; preds = %72
%156 = load i32, i32* %7
%157 = icmp ne i32 %156, 0
br i1 %157, label %160, label %158
158: ; preds = %155
%159 = call i32 (...) @error_exit()
br label %160
160: ; preds = %158, %155
br label %161
161: ; preds = %160
%162 = load i32, i32* @EXIT_SUCCESS
store i32 %162, i32* %3
br label %163
163: ; preds = %161, %153
%164 = load i32, i32* %3
ret i32 %164
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32, i32 }
@main.long_options = internal global [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32 0, i32 104 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [12 x i8] c"hx:c:p:l:o:\00"
@EXIT_SUCCESS = global i32 0
@optarg = global i8* null
@optind = global i32 0
@stdout = global i32* null
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [20 x i8] c"Cannot save in %s.\0A\00"
@str = [843 x i8] c"Counter Example Generator for VAC\0AUsage: counterexample OPTIONS ARBAC_FILE\0AOPTIONS:\0A -x,--cbmc-xml {XML_FILE} Mandatory: the XML file got from CBMC on the translated ABRAC policies\0A -c,--cbmc-input {TRANSLATED_FILE} Mandatory: is the program for CBMC that is translated from ABRAC policies\0A -p,--simplified-policy {ARBAC_SIMPLIFIED_FILE} If simplification: is the simplified of ARBAC policies\0A -d,--simplified-debug {SIMPLIFY_DEBUG_FILE} If simplification: is the recorded debug information of simplification process (invoke ./simplify -g command)\0A -o,--out {filename} Optional: Specify the output file (default=stdout)\0A -h,--help Shows this message then exit\0A ARBAC_FILE is the original (not simplfiedied) ARBAC policies\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %48, %2
%6 = phi i8* [ null, %2 ], [ %49, %48 ]
%7 = phi i8* [ null, %2 ], [ %50, %48 ]
%8 = phi i8* [ null, %2 ], [ %51, %48 ]
%9 = phi i8* [ null, %2 ], [ %52, %48 ]
%10 = phi i8* [ null, %2 ], [ %53, %48 ]
store i32 0, i32* %3
%11 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %3)
switch i32 %11, label %46 [
i32 -1, label %54
i32 104, label %12
i32 120, label %16
i32 99, label %22
i32 112, label %28
i32 108, label %34
i32 111, label %40
]
12: ; preds = %5
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([843 x i8], [843 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_SUCCESS
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %5
%17 = load i8*, i8** @optarg
%18 = call i64 @strlen(i8* dereferenceable(1) %17)
%19 = add nsw i64 %18, 1
%20 = call i8* @malloc(i64 %19)
%21 = call i32 @strcpy(i8* %20, i8* %17)
br label %48
22: ; preds = %5
%23 = load i8*, i8** @optarg
%24 = call i64 @strlen(i8* dereferenceable(1) %23)
%25 = add nsw i64 %24, 1
%26 = call i8* @malloc(i64 %25)
%27 = call i32 @strcpy(i8* %26, i8* %23)
br label %48
28: ; preds = %5
%29 = load i8*, i8** @optarg
%30 = call i64 @strlen(i8* dereferenceable(1) %29)
%31 = add nsw i64 %30, 1
%32 = call i8* @malloc(i64 %31)
%33 = call i32 @strcpy(i8* %32, i8* %29)
br label %48
34: ; preds = %5
%35 = load i8*, i8** @optarg
%36 = call i64 @strlen(i8* dereferenceable(1) %35)
%37 = add nsw i64 %36, 1
%38 = call i8* @malloc(i64 %37)
%39 = call i32 @strcpy(i8* %38, i8* %35)
br label %48
40: ; preds = %5
%41 = load i8*, i8** @optarg
%42 = call i64 @strlen(i8* dereferenceable(1) %41)
%43 = add nsw i64 %42, 1
%44 = call i8* @malloc(i64 %43)
%45 = call i32 @strcpy(i8* %44, i8* %41)
br label %48
46: ; preds = %5
%47 = call i32 (...) @error_exit()
br label %48
48: ; preds = %16, %22, %28, %34, %40, %46
%49 = phi i8* [ %6, %46 ], [ %6, %40 ], [ %6, %34 ], [ %6, %28 ], [ %6, %22 ], [ %20, %16 ]
%50 = phi i8* [ %7, %46 ], [ %7, %40 ], [ %7, %34 ], [ %7, %28 ], [ %26, %22 ], [ %7, %16 ]
%51 = phi i8* [ %8, %46 ], [ %8, %40 ], [ %8, %34 ], [ %32, %28 ], [ %8, %22 ], [ %8, %16 ]
%52 = phi i8* [ %9, %46 ], [ %9, %40 ], [ %38, %34 ], [ %9, %28 ], [ %9, %22 ], [ %9, %16 ]
%53 = phi i8* [ %10, %46 ], [ %44, %40 ], [ %10, %34 ], [ %10, %28 ], [ %10, %22 ], [ %10, %16 ]
br label %5
54: ; preds = %5
%55 = load i32, i32* @optind
%56 = icmp slt i32 %55, %0
br i1 %56, label %57, label %96
57: ; preds = %54
%58 = sext i32 %55 to i64
%59 = getelementptr inbounds i8*, i8** %1, i64 %58
%60 = load i8*, i8** %59
%61 = call i64 @strlen(i8* dereferenceable(1) %60)
%62 = add nsw i64 %61, 1
%63 = call i8* @malloc(i64 %62)
%64 = call i32 @strcpy(i8* %63, i8* %60)
%65 = icmp eq i8* %10, null
br i1 %65, label %66, label %68
66: ; preds = %57
%67 = load i32*, i32** @stdout
br label %74
68: ; preds = %57
%69 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%70 = icmp eq i32* %69, null
br i1 %70, label %71, label %74
71: ; preds = %68
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8* %10)
%73 = call i32 (...) @error_exit()
br label %74
74: ; preds = %68, %71, %66
%75 = phi i32* [ %67, %66 ], [ null, %71 ], [ %69, %68 ]
%76 = icmp ne i8* %6, null
%77 = icmp ne i8* %7, null
%78 = select i1 %76, i1 %77, i1 false
%79 = icmp ne i8* %8, null
%80 = select i1 %78, i1 %79, i1 false
%81 = icmp ne i8* %9, null
%82 = select i1 %80, i1 %81, i1 false
%83 = icmp ne i8* %63, null
%84 = and i1 %82, %83
br i1 %84, label %85, label %87
85: ; preds = %74
%86 = call i32 @generate_counter_example_full(i8* %6, i8* %7, i8* %8, i8* %9, i8* %63, i32* %75)
br label %93
87: ; preds = %74
%88 = and i1 %78, %83
br i1 %88, label %89, label %91
89: ; preds = %87
%90 = call i32 @generate_counter_example(i8* %6, i8* %7, i8* %63, i32* %75)
br label %93
91: ; preds = %87
%92 = call i32 (...) @error_exit()
br label %93
93: ; preds = %89, %91, %85
br i1 %65, label %98, label %94
94: ; preds = %93
%95 = call i32 @fclose(i32* %75)
br label %98
96: ; preds = %54
%97 = call i32 (...) @error_exit()
br label %98
98: ; preds = %93, %94, %96
%99 = load i32, i32* @EXIT_SUCCESS
ret i32 %99
}