#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*/ perror(char *);
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strncmp(char *, char const *, int);
int getParamChar(char *param, const char *flag, int argc, char *argv[]) {
  int i;
  int ok = 1;
  for (i = 0; i < argc; i++) {
    if (strncmp(argv[i], flag, 2) == 0) {
      if (ok == 1) {
        if ((strcmp(flag, "-h") != 0) & (strcmp(flag, "-v") != 0) &
            (strcmp(flag, "-y") != 0)) {
          strcpy(param, argv[(i + 1)]);
          ok = 0;
        } else {
          strcpy(param, "null");
          ok = 0;
        }
      } else {
        perror("More than 1 input parameter of the same type!");
        return 1;
      }
    }
  }
  return ok;
}


x86 assembly (clang, -O0):
<getParamChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x1,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1286 <getParamChar+0x146>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1273 <getParamChar+0x133>
cmpl   $0x1,-0x30(%rbp)
jne    1256 <getParamChar+0x116>
mov    -0x18(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%eax
cmp    $0x0,%rcx
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
mov    -0x34(%rbp),%eax
cmp    $0x0,%rcx
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     123a <getParamChar+0xfa>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x30(%rbp)
jmp    1251 <getParamChar+0x111>
mov    -0x10(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1040 <strcpy@plt>
movl   $0x0,-0x30(%rbp)
jmp    126e <getParamChar+0x12e>
lea    0xdb1(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    128c <getParamChar+0x14c>
jmp    1273 <getParamChar+0x133>
jmp    1278 <getParamChar+0x138>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1165 <getParamChar+0x25>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getParamChar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,(%rsp)
test   %edx,%edx
jle    1211 <getParamChar+0xd1>
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %edx,%r13d
mov    $0x1,%r12d
xor    %r15d,%r15d
jmp    1189 <getParamChar+0x49>
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
call   1040 <strcpy@plt>
xor    %r12d,%r12d
add    $0x1,%r15
cmp    %r15,%r13
je     1217 <getParamChar+0xd7>
mov    (%r14,%r15,8),%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    117c <getParamChar+0x3c>
cmp    $0x1,%r12d
jne    1205 <getParamChar+0xc5>
mov    %rbx,%rdi
lea    0xe51(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
lea    0xe42(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%r12
mov    %rbx,%rdi
lea    0xe33(%rip),%rsi
call   1050 <strcmp@plt>
lea    0xe2a(%rip),%rcx
mov    %rcx,%rsi
test   %rbp,%rbp
je     1170 <getParamChar+0x30>
mov    %rcx,%rsi
test   %r12,%r12
je     1170 <getParamChar+0x30>
mov    %rcx,%rsi
test   %rax,%rax
je     1170 <getParamChar+0x30>
mov    0x8(%r14,%r15,8),%rsi
jmp    1170 <getParamChar+0x30>
lea    0xe02(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [3 x i8] c"-v\00"
@.str.2 = [3 x i8] c"-y\00"
@.str.3 = [5 x i8] c"null\00"
@.str.4 = [46 x i8] c"More than 1 input parameter of the same type!\00"
define i32 @getParamChar(i8* %0, i8* %1, i32 %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8** %3, i8*** %9
store i32 1, i32* %11
store i32 0, i32* %10
br label %12
12: ; preds = %61, %4
%13 = load i32, i32* %10
%14 = load i32, i32* %8
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %64
16: ; preds = %12
%17 = load i8**, i8*** %9
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = load i8*, i8** %7
%23 = call i64 @strncmp(i8* %21, i8* %22, i32 2)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %60
25: ; preds = %16
%26 = load i32, i32* %11
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %57
28: ; preds = %25
%29 = load i8*, i8** %7
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
%32 = zext i1 %31 to i32
%33 = load i8*, i8** %7
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
%36 = zext i1 %35 to i32
%37 = and i32 %32, %36
%38 = load i8*, i8** %7
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp ne i64 %39, 0
%41 = zext i1 %40 to i32
%42 = and i32 %37, %41
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %53
44: ; preds = %28
%45 = load i8*, i8** %6
%46 = load i8**, i8*** %9
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %46, i64 %49
%51 = load i8*, i8** %50
%52 = call i32 @strcpy(i8* %45, i8* %51)
store i32 0, i32* %11
br label %56
53: ; preds = %28
%54 = load i8*, i8** %6
%55 = call i32 @strcpy(i8* %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %11
br label %56
56: ; preds = %53, %44
br label %59
57: ; preds = %25
%58 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %5
br label %66
59: ; preds = %56
br label %60
60: ; preds = %59, %16
br label %61
61: ; preds = %60
%62 = load i32, i32* %10
%63 = add nsw i32 %62, 1
store i32 %63, i32* %10
br label %12
64: ; preds = %12
%65 = load i32, i32* %11
store i32 %65, i32* %5
br label %66
66: ; preds = %64, %57
%67 = load i32, i32* %5
ret i32 %67
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [3 x i8] c"-v\00"
@.str.2 = [3 x i8] c"-y\00"
@.str.3 = [5 x i8] c"null\00"
@.str.4 = [46 x i8] c"More than 1 input parameter of the same type!\00"
define i32 @getParamChar(i8* %0, i8* %1, i32 %2, i8** nocapture %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %39
6: ; preds = %4
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %35
%9 = phi i64 [ 0, %6 ], [ %37, %35 ]
%10 = phi i32 [ 1, %6 ], [ %36, %35 ]
%11 = getelementptr inbounds i8*, i8** %3, i64 %9
%12 = load i8*, i8** %11
%13 = tail call i64 @strncmp(i8* %12, i8* %1, i32 2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %35
15: ; preds = %8
%16 = icmp eq i32 %10, 1
br i1 %16, label %17, label %30
17: ; preds = %15
%18 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
%20 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
%22 = and i1 %19, %21
%23 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
%25 = and i1 %22, %24
br i1 %25, label %26, label %32
26: ; preds = %17
%27 = add nuw nsw i64 %9, 1
%28 = getelementptr inbounds i8*, i8** %3, i64 %27
%29 = load i8*, i8** %28
br label %32
30: ; preds = %15
%31 = tail call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
br label %39
32: ; preds = %17, %26
%33 = phi i8* [ %29, %26 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %17 ]
%34 = tail call i32 @strcpy(i8* %0, i8* %33)
br label %35
35: ; preds = %32, %8
%36 = phi i32 [ %10, %8 ], [ 0, %32 ]
%37 = add nuw nsw i64 %9, 1
%38 = icmp eq i64 %37, %7
br i1 %38, label %39, label %8
39: ; preds = %35, %4, %30
%40 = phi i32 [ 1, %30 ], [ 1, %4 ], [ %36, %35 ]
ret i32 %40
}