#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 getopt_long(int, char **, char *, struct option *, int /*<<< orphan*/ *);
#define no_argument 129
char *optarg;
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, ...);
#define required_argument 128
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int ch;
  static struct option longopts[] = {
      {"str", required_argument, NULL, 's'},
      {"int", required_argument, NULL, 'i'},
      {"float", required_argument, NULL, 'd'},
      {"flag", no_argument, NULL, 'f'},
      {"help", no_argument, NULL, 'h'},
      {NULL, 0, 0, 0},
  };
  while ((ch = getopt_long(argc, argv, "hs:fi:d:", longopts, NULL)) != -1) {
    switch (ch) {
    case 's':
      printf("Arg -s : Value : %s \n", optarg);
      break;
    case 'i':
      printf("Arg -i : Value : %s \n", optarg);
      break;
    case 'd':
      printf("Arg -d : Value : %s \n", optarg);
      break;
    case 'f':
      printf("Arg -f : Value : boolean/set \n");
      break;
    case '?':
    case 'h':
    default:
      usage(argv[0]);
      break;
    }
  }
  argc -= optind;
  argv += optind;
}


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    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xf98(%rip),%rdx
lea    0x2ee5(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <getopt_long@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     121a <main+0xea>
mov    -0x14(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x34,%eax
ja     1209 <main+0xd9>
mov    -0x20(%rbp),%rax
lea    0xe6f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e57(%rip),%rax
mov    (%rax),%rsi
lea    0xf4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1215 <main+0xe5>
mov    0x2e3a(%rip),%rax
mov    (%rax),%rsi
lea    0xf43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1215 <main+0xe5>
mov    0x2e1d(%rip),%rax
mov    (%rax),%rsi
lea    0xf3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1215 <main+0xe5>
lea    0xf3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1215 <main+0xe5>
jmp    1209 <main+0xd9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
jmp    1146 <main+0x16>
mov    0x2dbf(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2dab(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%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
lea    0xf01(%rip),%r14
lea    0x2ef2(%rip),%r15
lea    0xe9b(%rip),%r12
mov    0x2e8c(%rip),%r13
jmp    1180 <main+0x40>
mov    0x0(%r13),%rsi
lea    0xee8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
lea    -0x64(%rax),%ecx
cmp    $0xf,%ecx
ja     11cc <main+0x8c>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
mov    0x0(%r13),%rsi
lea    0xede(%rip),%rdi
jmp    1179 <main+0x39>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
jmp    1180 <main+0x40>
mov    0x0(%r13),%rsi
lea    0xead(%rip),%rdi
jmp    1179 <main+0x39>
cmp    $0xffffffff,%eax
je     11db <main+0x9b>
mov    (%rbx),%rdi
call   1060 <usage@plt>
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
@main.longopts = internal global [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 115 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 105 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32* null, i32 100 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -127, i32* null, i32 102 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8 -127, i32* null, i32 104 }, %struct.option zeroinitializer]
@.str = [4 x i8] c"str\00"
@.str.1 = [4 x i8] c"int\00"
@.str.2 = [6 x i8] c"float\00"
@.str.3 = [5 x i8] c"flag\00"
@.str.4 = [5 x i8] c"help\00"
@.str.5 = [9 x i8] c"hs:fi:d:\00"
@.str.6 = [22 x i8] c"Arg -s : Value : %s \0A\00"
@optarg = global i8* null
@.str.7 = [22 x i8] c"Arg -i : Value : %s \0A\00"
@.str.8 = [22 x i8] c"Arg -d : Value : %s \0A\00"
@.str.9 = [31 x i8] c"Arg -f : Value : boolean/set \0A\00"
@optind = global i64 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
br label %7
7: ; preds = %31, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt_long(i32 %8, i8** %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.longopts, i64 0, i64 0), i32* null)
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 %26 [
i32 115, label %14
i32 105, label %17
i32 100, label %20
i32 102, label %23
i32 63, label %25
i32 104, label %25
]
14: ; preds = %12
%15 = load i8*, i8** @optarg
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %15)
br label %31
17: ; preds = %12
%18 = load i8*, i8** @optarg
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %18)
br label %31
20: ; preds = %12
%21 = load i8*, i8** @optarg
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %21)
br label %31
23: ; preds = %12
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
br label %31
25: ; preds = %12, %12
br label %26
26: ; preds = %12, %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @usage(i8* %29)
br label %31
31: ; preds = %26, %23, %20, %17, %14
br label %7
32: ; preds = %7
%33 = load i64, i64* @optind
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = sub nsw i64 %35, %33
%37 = trunc i64 %36 to i32
store i32 %37, i32* %4
%38 = load i64, i64* @optind
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 %38
store i8** %40, i8*** %5
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
@main.longopts = internal global [6 x %struct.option] [%struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 115 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 105 }, %struct.option { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8 -128, i32* null, i32 100 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8 -127, i32* null, i32 102 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8 -127, i32* null, i32 104 }, %struct.option zeroinitializer]
@.str = [4 x i8] c"str\00"
@.str.1 = [4 x i8] c"int\00"
@.str.2 = [6 x i8] c"float\00"
@.str.3 = [5 x i8] c"flag\00"
@.str.4 = [5 x i8] c"help\00"
@.str.5 = [9 x i8] c"hs:fi:d:\00"
@.str.6 = [22 x i8] c"Arg -s : Value : %s \0A\00"
@optarg = global i8* null
@.str.7 = [22 x i8] c"Arg -i : Value : %s \0A\00"
@.str.8 = [22 x i8] c"Arg -d : Value : %s \0A\00"
@optind = global i64 0
@str = [30 x i8] c"Arg -f : Value : boolean/set \00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %19, %2
%4 = tail call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), %struct.option* getelementptr inbounds ([6 x %struct.option], [6 x %struct.option]* @main.longopts, i64 0, i64 0), i32* null)
switch i32 %4, label %16 [
i32 -1, label %20
i32 115, label %5
i32 105, label %8
i32 100, label %11
i32 102, label %14
]
5: ; preds = %3
%6 = load i8*, i8** @optarg
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %6)
br label %19
8: ; preds = %3
%9 = load i8*, i8** @optarg
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i8* %9)
br label %19
11: ; preds = %3
%12 = load i8*, i8** @optarg
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %12)
br label %19
14: ; preds = %3
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %19
16: ; preds = %3
%17 = load i8*, i8** %1
%18 = tail call i32 @usage(i8* %17)
br label %19
19: ; preds = %16, %14, %11, %8, %5
br label %3
20: ; preds = %3
ret i32 0
}