#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 gengetopt_args_info {
  int dummy;
};
struct cmdline_parser_params {
  int dummy;
};

/* Variables and functions */
unsigned int cmdline_parser_create_argv(char const *, char ***, char const *);
int cmdline_parser_internal(unsigned int, char **, struct gengetopt_args_info *,
                            struct cmdline_parser_params *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char **);
int /*<<< orphan*/ free_cmd_list();
int cmdline_parser_string_ext(const char *cmdline,
                              struct gengetopt_args_info *args_info,
                              const char *prog_name,
                              struct cmdline_parser_params *params) {
  char **argv_ptr = 0;
  int result;
  unsigned int argc;
  argc = cmdline_parser_create_argv(cmdline, &argv_ptr, prog_name);
  result = cmdline_parser_internal(argc, argv_ptr, args_info, params, 0);
  if (argv_ptr) {
    free(argv_ptr);
  }
  free_cmd_list();
  return result;
}


x86 assembly (clang, -O0):
<cmdline_parser_string_ext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rsi
call   1060 <cmdline_parser_create_argv@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
xor    %r8d,%r8d
call   1050 <cmdline_parser_internal@plt>
mov    %eax,-0x2c(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a2 <cmdline_parser_string_ext+0x62>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1040 <free_cmd_list@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmdline_parser_string_ext>:
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rsi,%rbx
movq   $0x0,(%rsp)
mov    %rsp,%rsi
call   1060 <cmdline_parser_create_argv@plt>
mov    (%rsp),%rsi
mov    %eax,%edi
mov    %rbx,%rdx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1050 <cmdline_parser_internal@plt>
mov    %eax,%ebx
mov    (%rsp),%rdi
test   %rdi,%rdi
je     117e <cmdline_parser_string_ext+0x3e>
call   1030 <free@plt>
xor    %eax,%eax
call   1040 <free_cmd_list@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.gengetopt_args_info = type { i32 }
%struct.cmdline_parser_params = type { i32 }
define i32 @cmdline_parser_string_ext(i8* %0, %struct.gengetopt_args_info* %1, i8* %2, %struct.cmdline_parser_params* %3) {
%5 = alloca i8*
%6 = alloca %struct.gengetopt_args_info*
%7 = alloca i8*
%8 = alloca %struct.cmdline_parser_params*
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store %struct.gengetopt_args_info* %1, %struct.gengetopt_args_info** %6
store i8* %2, i8** %7
store %struct.cmdline_parser_params* %3, %struct.cmdline_parser_params** %8
store i8** null, i8*** %9
%12 = load i8*, i8** %5
%13 = load i8*, i8** %7
%14 = call i32 @cmdline_parser_create_argv(i8* %12, i8*** %9, i8* %13)
store i32 %14, i32* %11
%15 = load i32, i32* %11
%16 = load i8**, i8*** %9
%17 = load %struct.gengetopt_args_info*, %struct.gengetopt_args_info** %6
%18 = load %struct.cmdline_parser_params*, %struct.cmdline_parser_params** %8
%19 = call i32 @cmdline_parser_internal(i32 %15, i8** %16, %struct.gengetopt_args_info* %17, %struct.cmdline_parser_params* %18, i32 0)
store i32 %19, i32* %10
%20 = load i8**, i8*** %9
%21 = icmp ne i8** %20, null
br i1 %21, label %22, label %25
22: ; preds = %4
%23 = load i8**, i8*** %9
%24 = call i32 @free(i8** %23)
br label %25
25: ; preds = %22, %4
%26 = call i32 (...) @free_cmd_list()
%27 = load i32, i32* %10
ret i32 %27
}

LLVM IR (-O2):
%struct.gengetopt_args_info = type { i32 }
%struct.cmdline_parser_params = type { i32 }
define i32 @cmdline_parser_string_ext(i8* %0, %struct.gengetopt_args_info* %1, i8* %2, %struct.cmdline_parser_params* %3) {
%5 = alloca i8**
%6 = bitcast i8*** %5 to i8*
store i8** null, i8*** %5
%7 = call i32 @cmdline_parser_create_argv(i8* %0, i8*** %5, i8* %2)
%8 = load i8**, i8*** %5
%9 = call i32 @cmdline_parser_internal(i32 %7, i8** %8, %struct.gengetopt_args_info* %1, %struct.cmdline_parser_params* %3, i32 0)
%10 = load i8**, i8*** %5
%11 = icmp eq i8** %10, null
br i1 %11, label %14, label %12
12: ; preds = %4
%13 = call i32 @free(i8** %10)
br label %14
14: ; preds = %12, %4
%15 = call i32 (...) @free_cmd_list()
ret i32 %9
}