#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 commandLengthValueForMode(int, int, int);
int /*<<< orphan*/ setArgumentUnsignedHex2(int, char *);
int /*<<< orphan*/ setFunction(char *, int, int);
int /*<<< orphan*/ setResultUnsignedHex2(int /*<<< orphan*/, char *);
int devicePinGetInterface(char header, int mode, bool fillDeviceArgumentList) {
  if (header == 'V') {
    if (fillDeviceArgumentList) {
      setFunction("setPin", 2, 0);
      setArgumentUnsignedHex2(0, "pinIxx");
      setArgumentUnsignedHex2(1, "value");
    }
    return commandLengthValueForMode(mode, 4, 0);
  } else if (header == 'v') {
    if (mode == 0) {
      if (fillDeviceArgumentList) {
        setFunction("getPin", 1, 1);
        setArgumentUnsignedHex2(0, "pinIdx");
        setResultUnsignedHex2(0, "value");
      }
      return commandLengthValueForMode(mode, 2, 2);
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<devicePinGetInterface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x56,%eax
jne    11b4 <devicePinGetInterface+0x74>
cmpl   $0x0,-0x10(%rbp)
je     119d <devicePinGetInterface+0x5d>
lea    0xe8e(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1060 <setFunction@plt>
xor    %edi,%edi
lea    0xe80(%rip),%rsi
call   1050 <setArgumentUnsignedHex2@plt>
mov    $0x1,%edi
lea    0xe76(%rip),%rsi
call   1050 <setArgumentUnsignedHex2@plt>
mov    -0xc(%rbp),%edi
mov    $0x4,%esi
xor    %edx,%edx
call   1040 <commandLengthValueForMode@plt>
mov    %eax,-0x4(%rbp)
jmp    122c <devicePinGetInterface+0xec>
movsbl -0x5(%rbp),%eax
cmp    $0x76,%eax
jne    1220 <devicePinGetInterface+0xe0>
cmpl   $0x0,-0xc(%rbp)
jne    121b <devicePinGetInterface+0xdb>
cmpl   $0x0,-0x10(%rbp)
je     1204 <devicePinGetInterface+0xc4>
lea    0xe38(%rip),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <setFunction@plt>
xor    %edi,%edi
lea    0xe2a(%rip),%rsi
call   1050 <setArgumentUnsignedHex2@plt>
xor    %edi,%edi
lea    0xe0f(%rip),%rsi
call   1030 <setResultUnsignedHex2@plt>
mov    -0xc(%rbp),%edi
mov    $0x2,%edx
mov    %edx,%esi
call   1040 <commandLengthValueForMode@plt>
mov    %eax,-0x4(%rbp)
jmp    122c <devicePinGetInterface+0xec>
jmp    1220 <devicePinGetInterface+0xe0>
jmp    1225 <devicePinGetInterface+0xe5>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<devicePinGetInterface>:
push   %rbx
mov    %esi,%ebx
cmp    $0x56,%dil
jne    118e <devicePinGetInterface+0x4e>
test   %edx,%edx
je     117f <devicePinGetInterface+0x3f>
lea    0xeac(%rip),%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1060 <setFunction@plt>
lea    0xea0(%rip),%rsi
xor    %edi,%edi
call   1050 <setArgumentUnsignedHex2@plt>
lea    0xe99(%rip),%rsi
mov    $0x1,%edi
call   1050 <setArgumentUnsignedHex2@plt>
mov    %ebx,%edi
mov    $0x4,%esi
xor    %edx,%edx
pop    %rbx
jmp    1040 <commandLengthValueForMode@plt>
cmp    $0x76,%dil
jne    11e0 <devicePinGetInterface+0xa0>
test   %ebx,%ebx
jne    11e0 <devicePinGetInterface+0xa0>
test   %edx,%edx
je     11ce <devicePinGetInterface+0x8e>
lea    0xe71(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1060 <setFunction@plt>
lea    0xe62(%rip),%rsi
xor    %edi,%edi
call   1050 <setArgumentUnsignedHex2@plt>
lea    0xe47(%rip),%rsi
xor    %edi,%edi
call   1030 <setResultUnsignedHex2@plt>
xor    %edi,%edi
mov    $0x2,%esi
mov    $0x2,%edx
pop    %rbx
jmp    1040 <commandLengthValueForMode@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"setPin\00"
@.str.1 = [7 x i8] c"pinIxx\00"
@.str.2 = [6 x i8] c"value\00"
@.str.3 = [7 x i8] c"getPin\00"
@.str.4 = [7 x i8] c"pinIdx\00"
define i32 @devicePinGetInterface(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
store i8 %0, i8* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 86
br i1 %10, label %11, label %21
11: ; preds = %3
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = call i32 @setFunction(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 2, i32 0)
%16 = call i32 @setArgumentUnsignedHex2(i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @setArgumentUnsignedHex2(i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %14, %11
%19 = load i32, i32* %6
%20 = call i32 @commandLengthValueForMode(i32 %19, i32 4, i32 0)
store i32 %20, i32* %4
br label %41
21: ; preds = %3
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 118
br i1 %24, label %25, label %39
25: ; preds = %21
%26 = load i32, i32* %6
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %25
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = call i32 @setFunction(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 1)
%33 = call i32 @setArgumentUnsignedHex2(i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @setResultUnsignedHex2(i32 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %31, %28
%36 = load i32, i32* %6
%37 = call i32 @commandLengthValueForMode(i32 %36, i32 2, i32 2)
store i32 %37, i32* %4
br label %41
38: ; preds = %25
br label %39
39: ; preds = %38, %21
br label %40
40: ; preds = %39
store i32 -1, i32* %4
br label %41
41: ; preds = %40, %35, %18
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
@.str = [7 x i8] c"setPin\00"
@.str.1 = [7 x i8] c"pinIxx\00"
@.str.2 = [6 x i8] c"value\00"
@.str.3 = [7 x i8] c"getPin\00"
@.str.4 = [7 x i8] c"pinIdx\00"
define i32 @devicePinGetInterface(i8 signext %0, i32 %1, i32 %2) {
%4 = icmp eq i8 %0, 86
br i1 %4, label %5, label %13
5: ; preds = %3
%6 = icmp eq i32 %2, 0
br i1 %6, label %11, label %7
7: ; preds = %5
%8 = tail call i32 @setFunction(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 2, i32 0)
%9 = tail call i32 @setArgumentUnsignedHex2(i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @setArgumentUnsignedHex2(i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %7, %5
%12 = tail call i32 @commandLengthValueForMode(i32 %1, i32 4, i32 0)
br label %25
13: ; preds = %3
%14 = icmp eq i8 %0, 118
%15 = icmp eq i32 %1, 0
%16 = and i1 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = icmp eq i32 %2, 0
br i1 %18, label %23, label %19
19: ; preds = %17
%20 = tail call i32 @setFunction(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 1)
%21 = tail call i32 @setArgumentUnsignedHex2(i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%22 = tail call i32 @setResultUnsignedHex2(i32 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %19, %17
%24 = tail call i32 @commandLengthValueForMode(i32 0, i32 2, i32 2)
br label %25
25: ; preds = %13, %23, %11
%26 = phi i32 [ %12, %11 ], [ %24, %23 ], [ -1, %13 ]
ret i32 %26
}