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

/* Variables and functions */
int EXIT_SUCCESS;
int getopt(int, char **, char *);
char *optarg;
scalar_t__ opterr;
int optind;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  opterr = 0;
  int opt;
  static char optstrings[] = "hU:v";
  while ((opt = getopt(argc, argv, optstrings)) != -1)
    switch (opt) {
    case 'h':
      puts("Processata l'opzione -h");
      printf("optind = %d - argc = %d\n", optind, argc);
      break;
    case 'v':
      puts("Processata l'opzione -v");
      printf("optind = %d - argc = %d\n", optind, argc);
      break;
    case 'U':
      printf("Opzione -U \"%s\" parametro \n", optarg);
      break;
    case '?':
      printf("Parametro non valido \"?\"\n");
      break;
    default:
      puts("Opzione sconosciuta");
    }
  for (; optind < argc; ++optind) {
    printf("argv[%d] = %s\n", optind, argv[optind]);
    printf("optind = %d - argc = %d\n", optind, argc);
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e83(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0x2ed6(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1251 <main+0x121>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x3f,%eax
je     122d <main+0xfd>
jmp    1187 <main+0x57>
mov    -0x18(%rbp),%eax
sub    $0x55,%eax
je     1210 <main+0xe0>
jmp    1198 <main+0x68>
mov    -0x18(%rbp),%eax
sub    $0x68,%eax
je     11ba <main+0x8a>
jmp    11a9 <main+0x79>
mov    -0x18(%rbp),%eax
sub    $0x76,%eax
je     11e5 <main+0xb5>
jmp    1240 <main+0x110>
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124c <main+0x11c>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124c <main+0x11c>
mov    0x2de1(%rip),%rax
mov    (%rax),%rsi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124c <main+0x11c>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124c <main+0x11c>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
jmp    1154 <main+0x24>
jmp    1256 <main+0x126>
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    12c5 <main+0x195>
mov    0x2d71(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x2d64(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    0x2d22(%rip),%rax
mov    %ecx,(%rax)
jmp    1256 <main+0x126>
mov    0x2cfc(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e89(%rip),%rax
movq   $0x0,(%rax)
lea    0x2ee3(%rip),%r14
mov    0x2e84(%rip),%r15
lea    0xeb5(%rip),%r12
lea    0xec7(%rip),%r13
jmp    1187 <main+0x57>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    (%r15),%esi
mov    %r12,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <getopt@plt>
cmp    $0x67,%eax
jg     11c0 <main+0x90>
cmp    $0x3f,%eax
je     11cf <main+0x9f>
cmp    $0x55,%eax
jne    11dd <main+0xad>
mov    0x2e4e(%rip),%rax
mov    (%rax),%rsi
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1187 <main+0x57>
nopl   (%rax)
cmp    $0x68,%eax
je     116c <main+0x3c>
cmp    $0x76,%eax
jne    11e2 <main+0xb2>
mov    %r13,%rdi
jmp    1173 <main+0x43>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
jmp    1187 <main+0x57>
cmp    $0xffffffff,%eax
je     11f0 <main+0xc0>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
jmp    1187 <main+0x57>
mov    (%r15),%eax
cmp    %ebp,%eax
jge    123d <main+0x10d>
lea    0xe7b(%rip),%r14
lea    0xe13(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
movslq %eax,%rsi
mov    (%rbx,%rsi,8),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%esi
mov    %r12,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%eax
add    $0x1,%eax
mov    %eax,(%r15)
cmp    %ebp,%eax
jl     1210 <main+0xe0>
mov    0x2d84(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@opterr = global i64 0
@main.optstrings = internal global [5 x i8] c"hU:v\00"
@.str = [24 x i8] c"Processata l'opzione -h\00"
@.str.1 = [25 x i8] c"optind = %d - argc = %d\0A\00"
@optind = global i32 0
@.str.2 = [24 x i8] c"Processata l'opzione -v\00"
@.str.3 = [28 x i8] c"Opzione -U \22%s\22 parametro \0A\00"
@optarg = global i8* null
@.str.4 = [26 x i8] c"Parametro non valido \22?\22\0A\00"
@.str.5 = [20 x i8] c"Opzione sconosciuta\00"
@.str.6 = [15 x i8] c"argv[%d] = %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* @opterr
br label %7
7: ; preds = %31, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @main.optstrings, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %32
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %29 [
i32 104, label %14
i32 118, label %19
i32 85, label %24
i32 63, label %27
]
14: ; preds = %12
%15 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @optind
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %17)
br label %31
19: ; preds = %12
%20 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @optind
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22)
br label %31
24: ; preds = %12
%25 = load i8*, i8** @optarg
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %25)
br label %31
27: ; preds = %12
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %31
29: ; preds = %12
%30 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %31
31: ; preds = %29, %27, %24, %19, %14
br label %7
32: ; preds = %7
br label %33
33: ; preds = %48, %32
%34 = load i32, i32* @optind
%35 = load i32, i32* %4
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %51
37: ; preds = %33
%38 = load i32, i32* @optind
%39 = load i8**, i8*** %5
%40 = load i32, i32* @optind
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %38, i8* %43)
%45 = load i32, i32* @optind
%46 = load i32, i32* %4
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %45, i32 %46)
br label %48
48: ; preds = %37
%49 = load i32, i32* @optind
%50 = add nsw i32 %49, 1
store i32 %50, i32* @optind
br label %33
51: ; preds = %33
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}

LLVM IR (-O2):
@opterr = global i64 0
@main.optstrings = internal global [5 x i8] c"hU:v\00"
@.str = [24 x i8] c"Processata l'opzione -h\00"
@.str.1 = [25 x i8] c"optind = %d - argc = %d\0A\00"
@optind = global i32 0
@.str.2 = [24 x i8] c"Processata l'opzione -v\00"
@.str.3 = [28 x i8] c"Opzione -U \22%s\22 parametro \0A\00"
@optarg = global i8* null
@.str.5 = [20 x i8] c"Opzione sconosciuta\00"
@.str.6 = [15 x i8] c"argv[%d] = %s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [25 x i8] c"Parametro non valido \22?\22\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @opterr
br label %3
3: ; preds = %23, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @main.optstrings, i64 0, i64 0))
switch i32 %4, label %21 [
i32 -1, label %5
i32 104, label %8
i32 118, label %12
i32 85, label %16
i32 63, label %19
]
5: ; preds = %3
%6 = load i32, i32* @optind
%7 = icmp slt i32 %6, %0
br i1 %7, label %24, label %35
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @optind
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %0)
br label %23
12: ; preds = %3
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* @optind
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %0)
br label %23
16: ; preds = %3
%17 = load i8*, i8** @optarg
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %17)
br label %23
19: ; preds = %3
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %23
21: ; preds = %3
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %23
23: ; preds = %21, %19, %16, %12, %8
br label %3
24: ; preds = %5, %24
%25 = phi i32 [ %33, %24 ], [ %6, %5 ]
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %1, i64 %26
%28 = load i8*, i8** %27
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 %25, i8* %28)
%30 = load i32, i32* @optind
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %0)
%32 = load i32, i32* @optind
%33 = add nsw i32 %32, 1
store i32 %33, i32* @optind
%34 = icmp slt i32 %33, %0
br i1 %34, label %24, label %35
35: ; preds = %24, %5
%36 = load i32, i32* @EXIT_SUCCESS
ret i32 %36
}