#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;
};

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
int getopt_long(int, char **, char *, struct option *, int *);
#define no_argument 129
char *optarg;
int optind;
int /*<<< orphan*/ printf(char *, ...);
#define required_argument 128
int main(int argc, char **argv) {
  int c;
  char *optstring = "t:f:s";
  char *type;
  char *flags;
  int read_stdin = 0;
  while (1) {
    static struct option long_options[] = {
        {"type", required_argument, NULL, 't'},
        {"flags", required_argument, NULL, 'f'},
        {"stdin", no_argument, NULL, 's'},
        {0, 0, 0, 0}};
    int option_index = 0;
    c = getopt_long(argc, argv, optstring, long_options, &option_index);
    if (c == -1) {
      break;
    }
    switch (c) {
    case 't':
      type = optarg;
      break;
    case 'f':
      flags = optarg;
      break;
    case 's':
      read_stdin = 1;
      break;
    case '?':
      break;
    default:
      printf("Error beim Parsen der Argumente!\n");
      exit(1);
      break;
    }
  }
  printf("type: %s, flags: %s, read_stdin: %d\n", type, flags, read_stdin);
  if (optind < argc) {
    printf("Es gibt weitere ARGV-Elemente: ");
    while (optind < argc) {
      printf("%s", argv[optind++]);
    }
    printf("\n");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0x2ecf(%rip),%rcx
lea    -0x38(%rbp),%r8
call   1030 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    118c <main+0x5c>
jmp    1227 <main+0xf7>
mov    -0x14(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3f,%eax
je     1205 <main+0xd5>
jmp    11a0 <main+0x70>
mov    -0x3c(%rbp),%eax
sub    $0x66,%eax
je     11e6 <main+0xb6>
jmp    11b1 <main+0x81>
mov    -0x3c(%rbp),%eax
sub    $0x73,%eax
je     11f9 <main+0xc9>
jmp    11c2 <main+0x92>
mov    -0x3c(%rbp),%eax
sub    $0x74,%eax
jne    120a <main+0xda>
jmp    11d3 <main+0xa3>
mov    0x2e1e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1222 <main+0xf2>
mov    0x2e0b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1222 <main+0xf2>
movl   $0x1,-0x34(%rbp)
jmp    1222 <main+0xf2>
jmp    1222 <main+0xf2>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    1158 <main+0x28>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    12b5 <main+0x185>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    12a7 <main+0x177>
mov    -0x10(%rbp),%rax
mov    0x2d63(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    0x2d55(%rip),%rdx
mov    %esi,(%rdx)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1260 <main+0x130>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x0,(%rsp)
lea    0xe8f(%rip),%r13
lea    0x2ed8(%rip),%r14
lea    0x4(%rsp),%r15
mov    0x2e74(%rip),%r12
jmp    1197 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
movl   $0x1,(%rsp)
movl   $0x0,0x4(%rsp)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1050 <getopt_long@plt>
cmp    $0x72,%eax
jg     11d0 <main+0x80>
cmp    $0x3f,%eax
je     1197 <main+0x47>
cmp    $0x66,%eax
jne    11e9 <main+0x99>
mov    (%r12),%rax
mov    %rax,0x10(%rsp)
jmp    1197 <main+0x47>
nopl   0x0(%rax)
cmp    $0x73,%eax
je     1190 <main+0x40>
cmp    $0x74,%eax
jne    127f <main+0x12f>
mov    (%r12),%rax
mov    %rax,0x8(%rsp)
jmp    1197 <main+0x47>
cmp    $0xffffffff,%eax
jne    127f <main+0x12f>
lea    0xe1e(%rip),%rdi
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    (%rsp),%ecx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2dcc(%rip),%r15
cmp    %ebp,(%r15)
jge    1267 <main+0x117>
lea    0xe1c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r15),%eax
cmp    %ebp,%eax
jge    125d <main+0x10d>
lea    0xe27(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x1(%rax),%ecx
mov    %ecx,(%r15)
cltq
mov    (%rbx,%rax,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r15),%eax
cmp    %ebp,%eax
jl     1240 <main+0xf0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdd9(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [6 x i8] c"t:f:s\00"
@main.long_options = internal global [4 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 116 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32* null, i32 102 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8 -127, i32* null, i32 115 }, %struct.option zeroinitializer]
@.str.1 = [5 x i8] c"type\00"
@.str.2 = [6 x i8] c"flags\00"
@.str.3 = [6 x i8] c"stdin\00"
@optarg = global i8* null
@.str.4 = [34 x i8] c"Error beim Parsen der Argumente!\0A\00"
@.str.5 = [37 x i8] c"type: %s, flags: %s, read_stdin: %d\0A\00"
@optind = global i32 0
@.str.6 = [32 x i8] c"Es gibt weitere ARGV-Elemente: \00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [2 x i8] c"\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
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %7
store i32 0, i32* %10
br label %12
12: ; preds = %2, %31
store i32 0, i32* %11
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = load i8*, i8** %7
%16 = call i32 @getopt_long(i32 %13, i8** %14, i8* %15, %struct.option* getelementptr inbounds ([4 x %struct.option], [4 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %11)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %12
br label %32
20: ; preds = %12
%21 = load i32, i32* %6
switch i32 %21, label %28 [
i32 116, label %22
i32 102, label %24
i32 115, label %26
i32 63, label %27
]
22: ; preds = %20
%23 = load i8*, i8** @optarg
store i8* %23, i8** %8
br label %31
24: ; preds = %20
%25 = load i8*, i8** @optarg
store i8* %25, i8** %9
br label %31
26: ; preds = %20
store i32 1, i32* %10
br label %31
27: ; preds = %20
br label %31
28: ; preds = %20
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %27, %26, %24, %22
br label %12
32: ; preds = %19
%33 = load i8*, i8** %8
%34 = load i8*, i8** %9
%35 = load i32, i32* %10
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* %33, i8* %34, i32 %35)
%37 = load i32, i32* @optind
%38 = load i32, i32* %4
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %56
40: ; preds = %32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %42
42: ; preds = %46, %40
%43 = load i32, i32* @optind
%44 = load i32, i32* %4
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %54
46: ; preds = %42
%47 = load i8**, i8*** %5
%48 = load i32, i32* @optind
%49 = add nsw i32 %48, 1
store i32 %49, i32* @optind
%50 = sext i32 %48 to i64
%51 = getelementptr inbounds i8*, i8** %47, i64 %50
%52 = load i8*, i8** %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %52)
br label %42
54: ; preds = %42
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %56
56: ; preds = %54, %32
%57 = load i32, i32* @EXIT_SUCCESS
ret i32 %57
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@.str = [6 x i8] c"t:f:s\00"
@main.long_options = internal global [4 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 116 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32* null, i32 102 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8 -127, i32* null, i32 115 }, %struct.option zeroinitializer]
@.str.1 = [5 x i8] c"type\00"
@.str.2 = [6 x i8] c"flags\00"
@.str.3 = [6 x i8] c"stdin\00"
@optarg = global i8* null
@.str.5 = [37 x i8] c"type: %s, flags: %s, read_stdin: %d\0A\00"
@optind = global i32 0
@.str.6 = [32 x i8] c"Es gibt weitere ARGV-Elemente: \00"
@.str.7 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
@str = [33 x i8] c"Error beim Parsen der Argumente!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %18, %2
%6 = phi i8* [ undef, %2 ], [ %19, %18 ]
%7 = phi i8* [ undef, %2 ], [ %20, %18 ]
%8 = phi i32 [ 0, %2 ], [ %21, %18 ]
store i32 0, i32* %3
%9 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.option* getelementptr inbounds ([4 x %struct.option], [4 x %struct.option]* @main.long_options, i64 0, i64 0), i32* %3)
switch i32 %9, label %15 [
i32 -1, label %22
i32 116, label %10
i32 102, label %12
i32 115, label %14
i32 63, label %18
]
10: ; preds = %5
%11 = load i8*, i8** @optarg
br label %18
12: ; preds = %5
%13 = load i8*, i8** @optarg
br label %18
14: ; preds = %5
br label %18
15: ; preds = %5
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %10, %12, %14, %5
%19 = phi i8* [ %6, %14 ], [ %6, %12 ], [ %11, %10 ], [ %6, %5 ]
%20 = phi i8* [ %7, %14 ], [ %13, %12 ], [ %7, %10 ], [ %7, %5 ]
%21 = phi i32 [ 1, %14 ], [ %8, %12 ], [ %8, %10 ], [ %8, %5 ]
br label %5
22: ; preds = %5
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* %6, i8* %7, i32 %8)
%24 = load i32, i32* @optind
%25 = icmp slt i32 %24, %0
br i1 %25, label %26, label %41
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%28 = load i32, i32* @optind
%29 = icmp slt i32 %28, %0
br i1 %29, label %30, label %39
30: ; preds = %26, %30
%31 = phi i32 [ %37, %30 ], [ %28, %26 ]
%32 = add nsw i32 %31, 1
store i32 %32, i32* @optind
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @optind
%38 = icmp slt i32 %37, %0
br i1 %38, label %30, label %39
39: ; preds = %30, %26
%40 = call i32 @putchar(i32 10)
br label %41
41: ; preds = %39, %22
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}