#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ help(int, char **);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
void parse_params(int argc, char **argv, char *path, int *row, int *col,
                  int *ker_size, int *thresh) {
  if (argc == 1) {
    puts(">> Use Built-in Params.");
  } else if (argc == 6) {
    puts(">> Load Params from Console. Single Thresh");
    path = argv[1];
    *row = atoi(argv[2]);
    *col = atoi(argv[3]);
    *ker_size = atoi(argv[4]);
    *thresh = atoi(argv[5]);
  } else if (argc > 7) {
    puts(">> Load Params from Console. Multi Thresh");
    path = argv[1];
    *row = atoi(argv[2]);
    *col = atoi(argv[3]);
    *ker_size = atoi(argv[4]);
    if (atoi(argv[5]) != 0) {
      puts("Multi Thresh Usage.");
      printf(">>  %s <raw_img_path> <row> <col> <kernel_size> 0 <threshold1> "
             "<threshold2> ...\n",
             argv[0]);
      exit(-1);
    }
    *thresh = atoi(argv[6]);
  } else {
    help(argc, argv);
    exit(-1);
  }
  return;
}


x86 assembly (clang, -O0):
<parse_params>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    118e <parse_params+0x3e>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
jmp    12e3 <parse_params+0x193>
cmpl   $0x6,-0x4(%rbp)
jne    1209 <parse_params+0xb9>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    12de <parse_params+0x18e>
cmpl   $0x7,-0x4(%rbp)
jle    12c3 <parse_params+0x173>
lea    0xe29(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1060 <atoi@plt>
cmp    $0x0,%eax
je     12a9 <parse_params+0x159>
lea    0xde6(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xde7(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    12d9 <parse_params+0x189>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <help@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
jmp    12de <parse_params+0x18e>
jmp    12e3 <parse_params+0x193>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_params>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    %rsi,%rbx
mov    0x30(%rsp),%r13
cmp    $0x6,%edi
je     1189 <parse_params+0x39>
cmp    $0x1,%edi
jne    11c0 <parse_params+0x70>
lea    0xe85(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <puts@plt>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,(%r12)
mov    0x18(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,(%r15)
mov    0x20(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,(%r14)
mov    0x28(%rbx),%rdi
jmp    1207 <parse_params+0xb7>
cmp    $0x8,%edi
jl     121a <parse_params+0xca>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,(%r12)
mov    0x18(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,(%r15)
mov    0x20(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,(%r14)
mov    0x28(%rbx),%rdi
call   1060 <atoi@plt>
test   %eax,%eax
jne    122c <parse_params+0xdc>
mov    0x30(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,0x0(%r13)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %rbx,%rsi
call   1050 <help@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c">> Use Built-in Params.\00"
@.str.1 = [43 x i8] c">> Load Params from Console. Single Thresh\00"
@.str.2 = [42 x i8] c">> Load Params from Console. Multi Thresh\00"
@.str.3 = [20 x i8] c"Multi Thresh Usage.\00"
@.str.4 = [81 x i8] c">> %s <raw_img_path> <row> <col> <kernel_size> 0 <threshold1> <threshold2> ...\0A\00"
define void @parse_params(i32 %0, i8** %1, i8* %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
store i32 %0, i32* %8
store i8** %1, i8*** %9
store i8* %2, i8** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%15 = load i32, i32* %8
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %7
%18 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %95
19: ; preds = %7
%20 = load i32, i32* %8
%21 = icmp eq i32 %20, 6
br i1 %21, label %22, label %47
22: ; preds = %19
%23 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%24 = load i8**, i8*** %9
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %10
%27 = load i8**, i8*** %9
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
%31 = load i32*, i32** %11
store i32 %30, i32* %31
%32 = load i8**, i8*** %9
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
%36 = load i32*, i32** %12
store i32 %35, i32* %36
%37 = load i8**, i8*** %9
%38 = getelementptr inbounds i8*, i8** %37, i64 4
%39 = load i8*, i8** %38
%40 = call i32 @atoi(i8* %39)
%41 = load i32*, i32** %13
store i32 %40, i32* %41
%42 = load i8**, i8*** %9
%43 = getelementptr inbounds i8*, i8** %42, i64 5
%44 = load i8*, i8** %43
%45 = call i32 @atoi(i8* %44)
%46 = load i32*, i32** %14
store i32 %45, i32* %46
br label %94
47: ; preds = %19
%48 = load i32, i32* %8
%49 = icmp sgt i32 %48, 7
br i1 %49, label %50, label %88
50: ; preds = %47
%51 = call i32 @puts(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%52 = load i8**, i8*** %9
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
store i8* %54, i8** %10
%55 = load i8**, i8*** %9
%56 = getelementptr inbounds i8*, i8** %55, i64 2
%57 = load i8*, i8** %56
%58 = call i32 @atoi(i8* %57)
%59 = load i32*, i32** %11
store i32 %58, i32* %59
%60 = load i8**, i8*** %9
%61 = getelementptr inbounds i8*, i8** %60, i64 3
%62 = load i8*, i8** %61
%63 = call i32 @atoi(i8* %62)
%64 = load i32*, i32** %12
store i32 %63, i32* %64
%65 = load i8**, i8*** %9
%66 = getelementptr inbounds i8*, i8** %65, i64 4
%67 = load i8*, i8** %66
%68 = call i32 @atoi(i8* %67)
%69 = load i32*, i32** %13
store i32 %68, i32* %69
%70 = load i8**, i8*** %9
%71 = getelementptr inbounds i8*, i8** %70, i64 5
%72 = load i8*, i8** %71
%73 = call i32 @atoi(i8* %72)
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %82
75: ; preds = %50
%76 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%77 = load i8**, i8*** %9
%78 = getelementptr inbounds i8*, i8** %77, i64 0
%79 = load i8*, i8** %78
%80 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.4, i64 0, i64 0), i8* %79)
%81 = call i32 @exit(i32 -1)
unreachable
82: ; preds = %50
%83 = load i8**, i8*** %9
%84 = getelementptr inbounds i8*, i8** %83, i64 6
%85 = load i8*, i8** %84
%86 = call i32 @atoi(i8* %85)
%87 = load i32*, i32** %14
store i32 %86, i32* %87
br label %93
88: ; preds = %47
%89 = load i32, i32* %8
%90 = load i8**, i8*** %9
%91 = call i32 @help(i32 %89, i8** %90)
%92 = call i32 @exit(i32 -1)
unreachable
93: ; preds = %82
br label %94
94: ; preds = %93, %22
br label %95
95: ; preds = %94, %17
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c">> Use Built-in Params.\00"
@.str.1 = [43 x i8] c">> Load Params from Console. Single Thresh\00"
@.str.2 = [42 x i8] c">> Load Params from Console. Multi Thresh\00"
@.str.3 = [20 x i8] c"Multi Thresh Usage.\00"
@.str.4 = [81 x i8] c">> %s <raw_img_path> <row> <col> <kernel_size> 0 <threshold1> <threshold2> ...\0A\00"
define void @parse_params(i32 %0, i8** %1, i8* nocapture readnone %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6) {
switch i32 %0, label %24 [
i32 1, label %8
i32 6, label %10
]
8: ; preds = %7
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %53
10: ; preds = %7
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
store i32 %14, i32* %3
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
store i32 %17, i32* %4
%18 = getelementptr inbounds i8*, i8** %1, i64 4
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
store i32 %20, i32* %5
%21 = getelementptr inbounds i8*, i8** %1, i64 5
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
store i32 %23, i32* %6
br label %53
24: ; preds = %7
%25 = icmp sgt i32 %0, 7
br i1 %25, label %26, label %50
26: ; preds = %24
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32 @atoi(i8* %29)
store i32 %30, i32* %3
%31 = getelementptr inbounds i8*, i8** %1, i64 3
%32 = load i8*, i8** %31
%33 = tail call i32 @atoi(i8* %32)
store i32 %33, i32* %4
%34 = getelementptr inbounds i8*, i8** %1, i64 4
%35 = load i8*, i8** %34
%36 = tail call i32 @atoi(i8* %35)
store i32 %36, i32* %5
%37 = getelementptr inbounds i8*, i8** %1, i64 5
%38 = load i8*, i8** %37
%39 = tail call i32 @atoi(i8* %38)
%40 = icmp eq i32 %39, 0
br i1 %40, label %46, label %41
41: ; preds = %26
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%43 = load i8*, i8** %1
%44 = tail call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = tail call i32 @exit(i32 -1)
unreachable
46: ; preds = %26
%47 = getelementptr inbounds i8*, i8** %1, i64 6
%48 = load i8*, i8** %47
%49 = tail call i32 @atoi(i8* %48)
store i32 %49, i32* %6
br label %53
50: ; preds = %24
%51 = tail call i32 @help(i32 %0, i8** %1)
%52 = tail call i32 @exit(i32 -1)
unreachable
53: ; preds = %10, %46, %8
ret void
}