#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 */
char getopt(int, char **, char const *);
int cmdParse(int argc, char *argv[]) {
  const char *opt = "sudi";
  char ch;
  while ((ch = getopt(argc, argv, opt)) != -1) {
    switch (ch) {
    case 's':
      return 1;
    case 'u':
      return 2;
    case 'd':
      return 3;
    case 'i':
      return 4;
    default:
      return 0;
    }
    return 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<cmdParse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xf22(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <getopt@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     11af <cmdParse+0x9f>
movsbl -0x19(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x11,%eax
ja     11a3 <cmdParse+0x93>
mov    -0x28(%rbp),%rax
lea    0xe96(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    11b6 <cmdParse+0xa6>
movl   $0x2,-0x4(%rbp)
jmp    11b6 <cmdParse+0xa6>
movl   $0x3,-0x4(%rbp)
jmp    11b6 <cmdParse+0xa6>
movl   $0x4,-0x4(%rbp)
jmp    11b6 <cmdParse+0xa6>
movl   $0x0,-0x4(%rbp)
jmp    11b6 <cmdParse+0xa6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmdParse>:
push   %rax
lea    0xf30(%rip),%rdx
call   1030 <getopt@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xff,%cl
je     114f <cmdParse+0x3f>
movsbl %cl,%ecx
add    $0xffffff9c,%ecx
cmp    $0x11,%ecx
ja     114d <cmdParse+0x3d>
mov    $0x1,%eax
lea    0xec3(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x3,%eax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
mov    $0x4,%eax
pop    %rcx
ret
mov    $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"sudi\00"
define i32 @cmdParse(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
br label %8
8: ; preds = %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = load i8*, i8** %6
%12 = call signext i8 @getopt(i32 %9, i8** %10, i8* %11)
store i8 %12, i8* %7
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %23
15: ; preds = %8
%16 = load i8, i8* %7
%17 = sext i8 %16 to i32
switch i32 %17, label %22 [
i32 115, label %18
i32 117, label %19
i32 100, label %20
i32 105, label %21
]
18: ; preds = %15
store i32 1, i32* %3
br label %24
19: ; preds = %15
store i32 2, i32* %3
br label %24
20: ; preds = %15
store i32 3, i32* %3
br label %24
21: ; preds = %15
store i32 4, i32* %3
br label %24
22: ; preds = %15
store i32 0, i32* %3
br label %24
23: ; preds = %8
store i32 0, i32* %3
br label %24
24: ; preds = %23, %22, %21, %20, %19, %18
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [5 x i8] c"sudi\00"
define i32 @cmdParse(i32 %0, i8** %1) {
%3 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8 %3, -1
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = sext i8 %3 to i32
switch i32 %6, label %10 [
i32 115, label %11
i32 117, label %7
i32 100, label %8
i32 105, label %9
]
7: ; preds = %5
br label %11
8: ; preds = %5
br label %11
9: ; preds = %5
br label %11
10: ; preds = %5
br label %11
11: ; preds = %2, %5, %10, %9, %8, %7
%12 = phi i32 [ 0, %10 ], [ 4, %9 ], [ 3, %8 ], [ 2, %7 ], [ 1, %5 ], [ 0, %2 ]
ret i32 %12
}