#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*/ wchar_t;

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
int get_module_model_type(char *);
int get_text_file_info(char *, int /*<<< orphan*/ ***);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int extract_terminal_input_info(int argc, char **argv, int *module_code,
                                int *module_model_type, char **index_file_name,
                                wchar_t ***texts_or_querys) {
  int index_file_name_length, input_line_count;
  input_line_count = 0;
  setlocale(LC_ALL, "");
  if (argc == 5) {
    if (strcmp(argv[1], "-i") == 0) {
      *module_code = 0;
      index_file_name_length = strlen(argv[4]);
      *index_file_name =
          (char *)malloc(sizeof(char) * (index_file_name_length + 1));
      strncpy(*index_file_name, argv[4], index_file_name_length);
      input_line_count = get_text_file_info(argv[3], texts_or_querys);
    } else if (strcmp(argv[1], "-b") == 0) {
      *module_code = 1;
      index_file_name_length = strlen(argv[3]);
      *index_file_name =
          (char *)malloc(sizeof(char) * (index_file_name_length + 1));
      strncpy(*index_file_name, argv[3], index_file_name_length);
      input_line_count = get_text_file_info(argv[4], texts_or_querys);
    } else {
      printf("O comando nao esta no padrao correto3.\n");
      return 0;
    }
    if (*module_model_type == -1) {
      printf("O comando nao esta no padrao correto.\n");
      return 0;
    }
    *module_model_type = get_module_model_type(argv[2]);
    if (input_line_count == 0) {
      return 0;
    }
    return 1;
  } else {
    printf("O comando nao esta no padrao correto.\n");
    return 0;
  }
}


x86 assembly (clang, -O0):
<extract_terminal_input_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
call   10a0 <setlocale@plt>
cmpl   $0x5,-0x8(%rbp)
jne    1348 <extract_terminal_input_info+0x1c8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    124a <extract_terminal_input_info+0xca>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
mov    -0x34(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <get_text_file_info@plt>
mov    %eax,-0x38(%rbp)
jmp    12ec <extract_terminal_input_info+0x16c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdaa(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12cf <extract_terminal_input_info+0x14f>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    -0x34(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <get_text_file_info@plt>
mov    %eax,-0x38(%rbp)
jmp    12e7 <extract_terminal_input_info+0x167>
lea    0xd30(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    135b <extract_terminal_input_info+0x1db>
jmp    12ec <extract_terminal_input_info+0x16c>
mov    -0x20(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    1311 <extract_terminal_input_info+0x191>
lea    0xd2e(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    135b <extract_terminal_input_info+0x1db>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <get_module_model_type@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x38(%rbp)
jne    133c <extract_terminal_input_info+0x1bc>
movl   $0x0,-0x4(%rbp)
jmp    135b <extract_terminal_input_info+0x1db>
movl   $0x1,-0x4(%rbp)
jmp    135b <extract_terminal_input_info+0x1db>
lea    0xcdf(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_terminal_input_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r15
mov    %r8,%r12
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   10a0 <setlocale@plt>
cmp    $0x5,%ebp
jne    127f <extract_terminal_input_info+0xff>
mov    0x8(%rbx),%rdi
lea    0xe3b(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11f0 <extract_terminal_input_info+0x70>
mov    0x8(%rbx),%rdi
lea    0xe29(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1224 <extract_terminal_input_info+0xa4>
lea    0xe1b(%rip),%rdi
jmp    1286 <extract_terminal_input_info+0x106>
movl   $0x0,0x0(%r13)
mov    0x20(%rbx),%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
lea    0x1(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,(%r12)
mov    0x20(%rbx),%rsi
mov    %rax,%rdi
mov    %ebp,%edx
call   1030 <strncpy@plt>
mov    $0x3,%eax
jmp    1256 <extract_terminal_input_info+0xd6>
movl   $0x1,0x0(%r13)
mov    0x18(%rbx),%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
lea    0x1(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,(%r12)
mov    0x18(%rbx),%rsi
mov    %rax,%rdi
mov    %ebp,%edx
call   1030 <strncpy@plt>
mov    $0x4,%eax
mov    (%rbx,%rax,8),%rdi
mov    %r15,%rsi
call   1080 <get_text_file_info@plt>
cmpl   $0xffffffff,(%r14)
je     127f <extract_terminal_input_info+0xff>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1060 <get_module_model_type@plt>
mov    %eax,(%r14)
xor    %eax,%eax
test   %ebp,%ebp
setne  %al
jmp    128d <extract_terminal_input_info+0x10d>
lea    0xda7(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"-i\00"
@.str.2 = [3 x i8] c"-b\00"
@.str.3 = [40 x i8] c"O comando nao esta no padrao correto3.\0A\00"
@.str.4 = [39 x i8] c"O comando nao esta no padrao correto.\0A\00"
define i32 @extract_terminal_input_info(i32 %0, i8** %1, i32* %2, i32* %3, i8** %4, i32*** %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8**
%13 = alloca i32***
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %8
store i8** %1, i8*** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i8** %4, i8*** %12
store i32*** %5, i32**** %13
store i32 0, i32* %15
%16 = load i32, i32* @LC_ALL
%17 = call i32 @setlocale(i32 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 5
br i1 %19, label %20, label %103
20: ; preds = %6
%21 = load i8**, i8*** %9
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %52
26: ; preds = %20
%27 = load i32*, i32** %10
store i32 0, i32* %27
%28 = load i8**, i8*** %9
%29 = getelementptr inbounds i8*, i8** %28, i64 4
%30 = load i8*, i8** %29
%31 = call i32 @strlen(i8* %30)
store i32 %31, i32* %14
%32 = load i32, i32* %14
%33 = add nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = mul i64 1, %34
%36 = trunc i64 %35 to i32
%37 = call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to i8*
%39 = load i8**, i8*** %12
store i8* %38, i8** %39
%40 = load i8**, i8*** %12
%41 = load i8*, i8** %40
%42 = load i8**, i8*** %9
%43 = getelementptr inbounds i8*, i8** %42, i64 4
%44 = load i8*, i8** %43
%45 = load i32, i32* %14
%46 = call i32 @strncpy(i8* %41, i8* %44, i32 %45)
%47 = load i8**, i8*** %9
%48 = getelementptr inbounds i8*, i8** %47, i64 3
%49 = load i8*, i8** %48
%50 = load i32***, i32**** %13
%51 = call i32 @get_text_file_info(i8* %49, i32*** %50)
store i32 %51, i32* %15
br label %87
52: ; preds = %20
%53 = load i8**, i8*** %9
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %84
58: ; preds = %52
%59 = load i32*, i32** %10
store i32 1, i32* %59
%60 = load i8**, i8*** %9
%61 = getelementptr inbounds i8*, i8** %60, i64 3
%62 = load i8*, i8** %61
%63 = call i32 @strlen(i8* %62)
store i32 %63, i32* %14
%64 = load i32, i32* %14
%65 = add nsw i32 %64, 1
%66 = sext i32 %65 to i64
%67 = mul i64 1, %66
%68 = trunc i64 %67 to i32
%69 = call i64 @malloc(i32 %68)
%70 = inttoptr i64 %69 to i8*
%71 = load i8**, i8*** %12
store i8* %70, i8** %71
%72 = load i8**, i8*** %12
%73 = load i8*, i8** %72
%74 = load i8**, i8*** %9
%75 = getelementptr inbounds i8*, i8** %74, i64 3
%76 = load i8*, i8** %75
%77 = load i32, i32* %14
%78 = call i32 @strncpy(i8* %73, i8* %76, i32 %77)
%79 = load i8**, i8*** %9
%80 = getelementptr inbounds i8*, i8** %79, i64 4
%81 = load i8*, i8** %80
%82 = load i32***, i32**** %13
%83 = call i32 @get_text_file_info(i8* %81, i32*** %82)
store i32 %83, i32* %15
br label %86
84: ; preds = %52
%85 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %105
86: ; preds = %58
br label %87
87: ; preds = %86, %26
%88 = load i32*, i32** %11
%89 = load i32, i32* %88
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %93
91: ; preds = %87
%92 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %7
br label %105
93: ; preds = %87
%94 = load i8**, i8*** %9
%95 = getelementptr inbounds i8*, i8** %94, i64 2
%96 = load i8*, i8** %95
%97 = call i32 @get_module_model_type(i8* %96)
%98 = load i32*, i32** %11
store i32 %97, i32* %98
%99 = load i32, i32* %15
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %102
101: ; preds = %93
store i32 0, i32* %7
br label %105
102: ; preds = %93
store i32 1, i32* %7
br label %105
103: ; preds = %6
%104 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %7
br label %105
105: ; preds = %103, %102, %101, %91, %84
%106 = load i32, i32* %7
ret i32 %106
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [3 x i8] c"-i\00"
@.str.2 = [3 x i8] c"-b\00"
@str.5 = [39 x i8] c"O comando nao esta no padrao correto3.\00"
@str.6 = [38 x i8] c"O comando nao esta no padrao correto.\00"
define i32 @extract_terminal_input_info(i32 %0, i8** nocapture %1, i32* nocapture writeonly %2, i32* nocapture %3, i8** nocapture writeonly %4, i32*** %5) {
%7 = load i32, i32* @LC_ALL
%8 = tail call i32 @setlocale(i32 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %0, 5
br i1 %9, label %10, label %54
10: ; preds = %6
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %10
store i32 0, i32* %2
%16 = getelementptr inbounds i8*, i8** %1, i64 4
%17 = load i8*, i8** %16
%18 = tail call i32 @strlen(i8* %17)
%19 = add nsw i32 %18, 1
%20 = tail call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %4
%22 = load i8*, i8** %16
%23 = tail call i32 @strncpy(i8* %21, i8* %22, i32 %18)
br label %39
24: ; preds = %10
%25 = load i8*, i8** %11
%26 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %24
store i32 1, i32* %2
%29 = getelementptr inbounds i8*, i8** %1, i64 3
%30 = load i8*, i8** %29
%31 = tail call i32 @strlen(i8* %30)
%32 = add nsw i32 %31, 1
%33 = tail call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to i8*
store i8* %34, i8** %4
%35 = load i8*, i8** %29
%36 = tail call i32 @strncpy(i8* %34, i8* %35, i32 %31)
br label %39
37: ; preds = %24
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.5, i64 0, i64 0))
br label %56
39: ; preds = %28, %15
%40 = phi i64 [ 4, %28 ], [ 3, %15 ]
%41 = getelementptr inbounds i8*, i8** %1, i64 %40
%42 = load i8*, i8** %41
%43 = tail call i32 @get_text_file_info(i8* %42, i32*** %5)
%44 = load i32, i32* %3
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %48
46: ; preds = %39
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.6, i64 0, i64 0))
br label %56
48: ; preds = %39
%49 = getelementptr inbounds i8*, i8** %1, i64 2
%50 = load i8*, i8** %49
%51 = tail call i32 @get_module_model_type(i8* %50)
store i32 %51, i32* %3
%52 = icmp ne i32 %43, 0
%53 = zext i1 %52 to i32
br label %56
54: ; preds = %6
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.6, i64 0, i64 0))
br label %56
56: ; preds = %48, %54, %46, %37
%57 = phi i32 [ 0, %46 ], [ 0, %37 ], [ 0, %54 ], [ %53, %48 ]
ret i32 %57
}