#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 */
scalar_t__ strcmp(char *, char *);
short readSwitch(int argc, char *argv[], char *strID) {
  short n;
  for (n = 0; n < argc; n++) {
    if (strcmp(argv[n], strID) == 0) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<readSwitch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movw   $0x0,-0x1a(%rbp)
movswl -0x1a(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1177 <readSwitch+0x67>
mov    -0x10(%rbp),%rax
movswq -0x1a(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1161 <readSwitch+0x51>
movw   $0x1,-0x2(%rbp)
jmp    117d <readSwitch+0x6d>
jmp    1166 <readSwitch+0x56>
mov    -0x1a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x1a(%rbp)
jmp    1129 <readSwitch+0x19>
movw   $0x0,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readSwitch>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    114f <readSwitch+0x3f>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movswq %bx,%rax
mov    (%r15,%rax,8),%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1153 <readSwitch+0x43>
add    $0x1,%ebx
movswl %bx,%eax
cmp    %ebp,%eax
jl     1130 <readSwitch+0x20>
xor    %eax,%eax
jmp    1157 <readSwitch+0x47>
mov    $0x1,%ax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i16 @readSwitch(i32 %0, i8** %1, i8* %2) {
%4 = alloca i16
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i16
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store i16 0, i16* %8
br label %9
9: ; preds = %25, %3
%10 = load i16, i16* %8
%11 = sext i16 %10 to i32
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %28
14: ; preds = %9
%15 = load i8**, i8*** %6
%16 = load i16, i16* %8
%17 = sext i16 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = load i8*, i8** %7
%21 = call i64 @strcmp(i8* %19, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %14
store i16 1, i16* %4
br label %29
24: ; preds = %14
br label %25
25: ; preds = %24
%26 = load i16, i16* %8
%27 = add i16 %26, 1
store i16 %27, i16* %8
br label %9
28: ; preds = %9
store i16 0, i16* %4
br label %29
29: ; preds = %28, %23
%30 = load i16, i16* %4
ret i16 %30
}

LLVM IR (-O2):
define signext i16 @readSwitch(i32 %0, i8** nocapture %1, i8* %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %8, label %16
5: ; preds = %8
%6 = sext i16 %15 to i32
%7 = icmp slt i32 %6, %0
br i1 %7, label %8, label %16
8: ; preds = %3, %5
%9 = phi i16 [ %15, %5 ], [ 0, %3 ]
%10 = sext i16 %9 to i64
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i64 @strcmp(i8* %12, i8* %2)
%14 = icmp eq i64 %13, 0
%15 = add i16 %9, 1
br i1 %14, label %16, label %5
16: ; preds = %8, %5, %3
%17 = phi i16 [ 0, %3 ], [ 0, %5 ], [ 1, %8 ]
ret i16 %17
}