#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*/ set_rs485_mode(int);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strupr(char *);
int check_parameter(int argc, char *argv[]) {
  int i;
  char str[32];
  char *tmp_str = str;
  if (argc < 0 || argc > 3)
    return 0;
  if (argc == 1) {
    set_rs485_mode(0);
    return 1;
  }
  strcpy(tmp_str, argv[1]);
  if (*tmp_str == '-')
    ++tmp_str;
  else
    return 0;
  if (strcmp(strupr(tmp_str), "HALF") == 0) {
    set_rs485_mode(0);
  } else if (strcmp(strupr(tmp_str), "FULL") == 0) {
    set_rs485_mode(1);
  } else
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<check_parameter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     116b <check_parameter+0x2b>
cmpl   $0x3,-0x8(%rbp)
jle    1177 <check_parameter+0x37>
movl   $0x0,-0x4(%rbp)
jmp    1247 <check_parameter+0x107>
cmpl   $0x1,-0x8(%rbp)
jne    1194 <check_parameter+0x54>
xor    %edi,%edi
call   1060 <set_rs485_mode@plt>
movl   $0x1,-0x4(%rbp)
jmp    1247 <check_parameter+0x107>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11c6 <check_parameter+0x86>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    11d2 <check_parameter+0x92>
movl   $0x0,-0x4(%rbp)
jmp    1247 <check_parameter+0x107>
mov    -0x48(%rbp),%rdi
call   1050 <strupr@plt>
mov    %eax,%edi
lea    0xe1c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ff <check_parameter+0xbf>
xor    %edi,%edi
call   1060 <set_rs485_mode@plt>
jmp    1240 <check_parameter+0x100>
mov    -0x48(%rbp),%rdi
call   1050 <strupr@plt>
mov    %eax,%edi
lea    0xdf4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    122f <check_parameter+0xef>
mov    $0x1,%edi
call   1060 <set_rs485_mode@plt>
jmp    123b <check_parameter+0xfb>
movl   $0x0,-0x4(%rbp)
jmp    1247 <check_parameter+0x107>
jmp    1240 <check_parameter+0x100>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_parameter>:
push   %r14
push   %rbx
sub    $0x28,%rsp
xor    %ebx,%ebx
cmp    $0x3,%edi
ja     11bd <check_parameter+0x7d>
cmp    $0x1,%edi
jne    1161 <check_parameter+0x21>
xor    %edi,%edi
call   1060 <set_rs485_mode@plt>
mov    $0x1,%ebx
jmp    11bd <check_parameter+0x7d>
mov    0x8(%rsi),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
cmpb   $0x2d,(%rsp)
jne    11bd <check_parameter+0x7d>
lea    0x1(%rsp),%r14
mov    %r14,%rdi
call   1050 <strupr@plt>
lea    0xe79(%rip),%rsi
mov    %eax,%edi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1153 <check_parameter+0x13>
mov    %r14,%rdi
call   1050 <strupr@plt>
lea    0xe63(%rip),%rsi
mov    %eax,%edi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11bd <check_parameter+0x7d>
mov    $0x1,%ebx
mov    $0x1,%edi
call   1060 <set_rs485_mode@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HALF\00"
@.str.1 = [5 x i8] c"FULL\00"
define i32 @check_parameter(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [32 x i8]
%8 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
store i8* %9, i8** %8
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 3
br i1 %14, label %15, label %16
15: ; preds = %12, %2
store i32 0, i32* %3
br label %52
16: ; preds = %12
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @set_rs485_mode(i32 0)
store i32 1, i32* %3
br label %52
21: ; preds = %16
%22 = load i8*, i8** %8
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @strcpy(i8* %22, i8* %25)
%27 = load i8*, i8** %8
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 45
br i1 %30, label %31, label %34
31: ; preds = %21
%32 = load i8*, i8** %8
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %8
br label %35
34: ; preds = %21
store i32 0, i32* %3
br label %52
35: ; preds = %31
%36 = load i8*, i8** %8
%37 = call i32 @strupr(i8* %36)
%38 = call i64 @strcmp(i32 %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = call i32 @set_rs485_mode(i32 0)
br label %51
42: ; preds = %35
%43 = load i8*, i8** %8
%44 = call i32 @strupr(i8* %43)
%45 = call i64 @strcmp(i32 %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %42
%48 = call i32 @set_rs485_mode(i32 1)
br label %50
49: ; preds = %42
store i32 0, i32* %3
br label %52
50: ; preds = %47
br label %51
51: ; preds = %50, %40
store i32 1, i32* %3
br label %52
52: ; preds = %51, %49, %34, %19, %15
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@.str = [5 x i8] c"HALF\00"
@.str.1 = [5 x i8] c"FULL\00"
define i32 @check_parameter(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%5 = icmp ugt i32 %0, 3
br i1 %5, label %29, label %6
6: ; preds = %2
%7 = icmp eq i32 %0, 1
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @set_rs485_mode(i32 0)
br label %29
10: ; preds = %6
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strcpy(i8* %4, i8* %12)
%14 = load i8, i8* %4
%15 = icmp eq i8 %14, 45
br i1 %15, label %16, label %29
16: ; preds = %10
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 1
%18 = call i32 @strupr(i8* %17)
%19 = call i64 @strcmp(i32 %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @set_rs485_mode(i32 0)
br label %29
23: ; preds = %16
%24 = call i32 @strupr(i8* %17)
%25 = call i64 @strcmp(i32 %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 @set_rs485_mode(i32 1)
br label %29
29: ; preds = %21, %27, %23, %10, %2, %8
%30 = phi i32 [ 1, %8 ], [ 0, %2 ], [ 0, %10 ], [ 0, %23 ], [ 1, %27 ], [ 1, %21 ]
ret i32 %30
}