#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 getopt(int, char **, char *);
char *optarg;
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int ch;
  while ((ch = getopt(argc, argv, "hs:fi:d:")) != -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    0xf80(%rip),%rdx
call   1050 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     120e <main+0xde>
mov    -0x14(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x34,%eax
ja     11fd <main+0xcd>
mov    -0x20(%rbp),%rax
lea    0xe7b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e63(%rip),%rax
mov    (%rax),%rsi
lea    0xf3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1209 <main+0xd9>
mov    0x2e46(%rip),%rax
mov    (%rax),%rsi
lea    0xf37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1209 <main+0xd9>
mov    0x2e29(%rip),%rax
mov    (%rax),%rsi
lea    0xf30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1209 <main+0xd9>
lea    0xf33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1209 <main+0xd9>
jmp    11fd <main+0xcd>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
jmp    1146 <main+0x16>
mov    0x2dcb(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2db7(%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    0xee9(%rip),%r14
lea    0xea2(%rip),%r12
mov    0x2e93(%rip),%r13
lea    0xedd(%rip),%r15
jmp    117c <main+0x3c>
mov    0x0(%r13),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <getopt@plt>
lea    -0x64(%rax),%ecx
cmp    $0xf,%ecx
ja     11c2 <main+0x82>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
mov    0x0(%r13),%rsi
lea    0xed0(%rip),%rdi
jmp    1175 <main+0x35>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
jmp    117c <main+0x3c>
mov    0x0(%r13),%rsi
lea    0xe9f(%rip),%rdi
jmp    1175 <main+0x35>
cmp    $0xffffffff,%eax
je     11d1 <main+0x91>
mov    (%rbx),%rdi
call   1050 <usage@plt>
jmp    117c <main+0x3c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"hs:fi:d:\00"
@.str.1 = [22 x i8] c"Arg -s : Value : %s \0A\00"
@optarg = global i8* null
@.str.2 = [22 x i8] c"Arg -i : Value : %s \0A\00"
@.str.3 = [22 x i8] c"Arg -d : Value : %s \0A\00"
@.str.4 = [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(i32 %8, i8** %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, 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 %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.1, 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.2, 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.3, 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.4, 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):
@.str = [9 x i8] c"hs:fi:d:\00"
@.str.1 = [22 x i8] c"Arg -s : Value : %s \0A\00"
@optarg = global i8* null
@.str.2 = [22 x i8] c"Arg -i : Value : %s \0A\00"
@.str.3 = [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(i32 %0, i8** %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
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.1, 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.2, 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.3, 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
}