#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 /*<<< orphan*/ fast_speed();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ spooler_open(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcasecmp(char *, char *);
scalar_t__ strcmp(char *, char *);
void handle_cli_args(int argc, char **argv) {
  int arg_pos = 0;
  char *cli_switch;
  while (arg_pos < argc) {
    cli_switch = argv[arg_pos];
    if (strcasecmp("-s", cli_switch) == 0) {
      if (strcmp("-S", cli_switch) == 0) {
        fast_speed();
      }
      if (++arg_pos < argc) {
        spooler_open(argv[arg_pos]);
      } else {
        fprintf(stderr, "Error: Missing filename for %s arg\n", cli_switch);
      }
    }
    arg_pos++;
  }
}


x86 assembly (clang, -O0):
<handle_cli_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1211 <handle_cli_args+0xc1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1203 <handle_cli_args+0xb3>
mov    -0x20(%rbp),%rsi
lea    0xe5c(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11bd <handle_cli_args+0x6d>
mov    $0x0,%al
call   1040 <fast_speed@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    -0x4(%rbp),%eax
jge    11e5 <handle_cli_args+0x95>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <spooler_open@plt>
jmp    11fe <handle_cli_args+0xae>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe0d(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1203 <handle_cli_args+0xb3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <handle_cli_args+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_cli_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11f0 <handle_cli_args+0xa0>
mov    %rsi,%r13
mov    %edi,%ebp
lea    0xe91(%rip),%r14
lea    0xe8d(%rip),%r15
xor    %r12d,%r12d
jmp    11a9 <handle_cli_args+0x59>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r12d
cmp    %ebp,%r12d
jge    11f0 <handle_cli_args+0xa0>
movslq %r12d,%rax
mov    0x0(%r13,%rax,8),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    11a0 <handle_cli_args+0x50>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11d8 <handle_cli_args+0x88>
xor    %eax,%eax
call   1040 <fast_speed@plt>
add    $0x1,%r12d
cmp    %ebp,%r12d
jge    117b <handle_cli_args+0x2b>
movslq %r12d,%rax
mov    0x0(%r13,%rax,8),%rdi
call   1070 <spooler_open@plt>
jmp    11a0 <handle_cli_args+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-s\00"
@.str.1 = [3 x i8] c"-S\00"
@stderr = global i32 0
@.str.2 = [36 x i8] c"Error: Missing filename for %s arg\0A\00"
define void @handle_cli_args(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %5
br label %7
7: ; preds = %43, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %46
11: ; preds = %7
%12 = load i8**, i8*** %4
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = call i64 @strcasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %43
20: ; preds = %11
%21 = load i8*, i8** %6
%22 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (...) @fast_speed()
br label %26
26: ; preds = %24, %20
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
%29 = load i32, i32* %3
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %38
31: ; preds = %26
%32 = load i8**, i8*** %4
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32 @spooler_open(i8* %36)
br label %42
38: ; preds = %26
%39 = load i32, i32* @stderr
%40 = load i8*, i8** %6
%41 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %38, %31
br label %43
43: ; preds = %42, %11
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %7
46: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"-s\00"
@.str.1 = [3 x i8] c"-S\00"
@stderr = global i32 0
@.str.2 = [36 x i8] c"Error: Missing filename for %s arg\0A\00"
define void @handle_cli_args(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %31
4: ; preds = %2, %27
%5 = phi i32 [ %29, %27 ], [ 0, %2 ]
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8*, i8** %1, i64 %6
%8 = load i8*, i8** %7
%9 = tail call i64 @strcasecmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %4
%12 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 (...) @fast_speed()
br label %16
16: ; preds = %14, %11
%17 = add nsw i32 %5, 1
%18 = icmp slt i32 %17, %0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = sext i32 %17 to i64
%21 = getelementptr inbounds i8*, i8** %1, i64 %20
%22 = load i8*, i8** %21
%23 = tail call i32 @spooler_open(i8* %22)
br label %27
24: ; preds = %16
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %8)
br label %27
27: ; preds = %19, %24, %4
%28 = phi i32 [ %17, %19 ], [ %17, %24 ], [ %5, %4 ]
%29 = add nsw i32 %28, 1
%30 = icmp slt i32 %29, %0
br i1 %30, label %4, label %31
31: ; preds = %27, %2
ret void
}