#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;
  int member_1;
  char member_3;
  int /*<<< orphan*/ *member_2;
};

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
int getopt_long(int, char **, char const *const, struct option const *,
                int /*<<< orphan*/ *);
int /*<<< orphan*/ imprime_uso();
char *optarg;
int /*<<< orphan*/ printf(char *, ...);
int strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int index, n;
  int siguiente_opcion;
  char *archivo = NULL;
  const char *const op_cortas = "hVi:";
  const struct option op_largas[] = {{"help", 0, NULL, 'h'},
                                     {"version", 0, NULL, 'V'},
                                     {"input", 2, NULL, 'i'},
                                     {NULL, 0, NULL, 0}};
  while (1) {
    siguiente_opcion = getopt_long(argc, argv, op_cortas, op_largas, NULL);
    if (siguiente_opcion == -1)
      break;
    switch (siguiente_opcion) {
    case 'h':
      imprime_uso();
      exit(EXIT_SUCCESS);
    case 'V':
      printf("Tp1 version 1.0 \n");
      break;
    case 'i':
      n = strcmp("-", optarg);
      if (n == 0) {
        archivo = NULL;
      } else {
        archivo = optarg;
      }
      printf("input %s\n", archivo);
      break;
    case '?':
      imprime_uso();
      exit(1);
    case -1:
      break;
    default:
      exit(1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe78(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x90(%rbp),%rdi
lea    0x2c16(%rip),%rsi
mov    $0x60,%edx
call   1070 <memcpy@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x90(%rbp),%rcx
lea    0xe47(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <getopt_long@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11d5 <main+0x75>
jmp    12de <main+0x17e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x94(%rbp)
sub    $0xffffffff,%eax
je     12ca <main+0x16a>
jmp    11ec <main+0x8c>
mov    -0x94(%rbp),%eax
sub    $0x3f,%eax
je     12b9 <main+0x159>
jmp    1200 <main+0xa0>
mov    -0x94(%rbp),%eax
sub    $0x56,%eax
je     1251 <main+0xf1>
jmp    1214 <main+0xb4>
mov    -0x94(%rbp),%eax
sub    $0x68,%eax
je     123c <main+0xdc>
jmp    1228 <main+0xc8>
mov    -0x94(%rbp),%eax
sub    $0x69,%eax
je     1264 <main+0x104>
jmp    12cf <main+0x16f>
mov    $0x0,%al
call   1030 <imprime_uso@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12d9 <main+0x179>
mov    0x2d8d(%rip),%rax
mov    (%rax),%rsi
lea    0xdb5(%rip),%rdi
call   1060 <strcmp@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1294 <main+0x134>
movq   $0x0,-0x28(%rbp)
jmp    12a2 <main+0x142>
mov    0x2d5d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12d9 <main+0x179>
mov    $0x0,%al
call   1030 <imprime_uso@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    12d9 <main+0x179>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11a4 <main+0x44>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movaps 0x2c86(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0x2c6a(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0x2c4e(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0x2c32(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c16(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2bfa(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xe3f(%rip),%r14
mov    %rsp,%r15
lea    0xe4f(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1050 <getopt_long@plt>
cmp    $0x67,%eax
jg     1200 <main+0xa0>
cmp    $0x56,%eax
jne    1235 <main+0xd5>
lea    0xe30(%rip),%rdi
call   1040 <puts@plt>
jmp    11d0 <main+0x70>
nopl   0x0(%rax,%rax,1)
cmp    $0x69,%eax
jne    124b <main+0xeb>
mov    0x2dec(%rip),%rax
mov    (%rax),%r13
lea    0xe02(%rip),%rdi
mov    %r13,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
mov    $0x0,%esi
cmovne %r13,%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11d0 <main+0x70>
cmp    $0xffffffff,%eax
jne    1265 <main+0x105>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x68,%eax
jne    1271 <main+0x111>
xor    %eax,%eax
call   1030 <imprime_uso@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
cmp    $0x3f,%eax
jne    1271 <main+0x111>
xor    %eax,%eax
call   1030 <imprime_uso@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i32, i8, i32* }
@.str = [5 x i8] c"hVi:\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [8 x i8] c"version\00"
@.str.3 = [6 x i8] c"input\00"
@__const.main.op_largas = [4 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 104 to i32*) }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 86 to i32*) }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i32 2, i8 0, i32* inttoptr (i64 105 to i32*) }, %struct.option zeroinitializer]
@EXIT_SUCCESS = global i32 0
@.str.4 = [18 x i8] c"Tp1 version 1.0 \0A\00"
@.str.5 = [2 x i8] c"-\00"
@optarg = global i8* null
@.str.6 = [10 x i8] c"input %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 i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [4 x %struct.option]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %9
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %10
%12 = bitcast [4 x %struct.option]* %11 to i8*
br label %13
13: ; preds = %2, %46
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %11, i64 0, i64 0
%17 = call i32 @getopt_long(i32 %14, i8** %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), %struct.option* %16, i32* null)
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %13
br label %47
21: ; preds = %13
%22 = load i32, i32* %8
switch i32 %22, label %44 [
i32 104, label %23
i32 86, label %27
i32 105, label %29
i32 63, label %40
i32 -1, label %43
]
23: ; preds = %21
%24 = call i32 (...) @imprime_uso()
%25 = load i32, i32* @EXIT_SUCCESS
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %21
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %46
29: ; preds = %21
%30 = load i8*, i8** @optarg
%31 = call i32 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %30)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %29
store i8* null, i8** %9
br label %37
35: ; preds = %29
%36 = load i8*, i8** @optarg
store i8* %36, i8** %9
br label %37
37: ; preds = %35, %34
%38 = load i8*, i8** %9
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %38)
br label %46
40: ; preds = %21
%41 = call i32 (...) @imprime_uso()
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %21
br label %46
44: ; preds = %21
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %43, %37, %27
br label %13
47: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i8, i32* }
@.str = [5 x i8] c"hVi:\00"
@.str.1 = [5 x i8] c"help\00"
@.str.2 = [8 x i8] c"version\00"
@.str.3 = [6 x i8] c"input\00"
@__const.main.op_largas = [4 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 104 to i32*) }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i32 0, i8 0, i32* inttoptr (i64 86 to i32*) }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i32 2, i8 0, i32* inttoptr (i64 105 to i32*) }, %struct.option zeroinitializer]
@EXIT_SUCCESS = global i32 0
@.str.5 = [2 x i8] c"-\00"
@optarg = global i8* null
@.str.6 = [10 x i8] c"input %s\0A\00"
@str = [17 x i8] c"Tp1 version 1.0 \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [4 x %struct.option]
%4 = bitcast [4 x %struct.option]* %3 to i8*
%5 = getelementptr inbounds [4 x %struct.option], [4 x %struct.option]* %3, i64 0, i64 0
br label %6
6: ; preds = %20, %2
%7 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %struct.option* %5, i32* null)
switch i32 %7, label %24 [
i32 -1, label %26
i32 104, label %8
i32 86, label %12
i32 105, label %14
i32 63, label %21
]
8: ; preds = %6
%9 = call i32 (...) @imprime_uso()
%10 = load i32, i32* @EXIT_SUCCESS
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %6
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %20
14: ; preds = %6
%15 = load i8*, i8** @optarg
%16 = call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* dereferenceable(1) %15)
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i8* null, i8* %15
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %14, %12
br label %6
21: ; preds = %6
%22 = call i32 (...) @imprime_uso()
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %6
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %6
ret i32 0
}