#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*/ setArgumentUnsignedHex4(int /*<<< orphan*/, char *);
int /*<<< orphan*/ setFunction(char *, int, int);
int /*<<< orphan*/ setResultUnsignedHex2(int /*<<< orphan*/, char *);
int deviceTest2GetInterface(unsigned char commandHeader, int mode,
                            bool fillDeviceArgumentList) {
  if (commandHeader == 'w') {
    if (fillDeviceArgumentList) {
      setFunction("test2", 2, 1);
      setArgumentUnsignedHex2(0, "a");
      setArgumentUnsignedHex2(1, "b");
      setResultUnsignedHex2(0, "result");
    }
    return commandLengthValueForMode(mode, 4, 2);
  } else if (commandHeader == 'I') {
    if (fillDeviceArgumentList) {
      setFunction("testDriverIntensive", 1, 0);
      setArgumentUnsignedHex4(0, "count");
    }
    return commandLengthValueForMode(mode, 4, 0);
  }
  return -1;
}


x86 assembly (clang, -O0):
<deviceTest2GetInterface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x77,%eax
jne    11d8 <deviceTest2GetInterface+0x88>
cmpl   $0x0,-0x10(%rbp)
je     11be <deviceTest2GetInterface+0x6e>
lea    0xe7e(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
call   1070 <setFunction@plt>
xor    %edi,%edi
lea    0xe6c(%rip),%rsi
call   1050 <setArgumentUnsignedHex2@plt>
mov    $0x1,%edi
lea    0xe5d(%rip),%rsi
call   1050 <setArgumentUnsignedHex2@plt>
xor    %edi,%edi
lea    0xe51(%rip),%rsi
call   1030 <setResultUnsignedHex2@plt>
mov    -0xc(%rbp),%edi
mov    $0x4,%esi
mov    $0x2,%edx
call   1040 <commandLengthValueForMode@plt>
mov    %eax,-0x4(%rbp)
jmp    1233 <deviceTest2GetInterface+0xe3>
movzbl -0x5(%rbp),%eax
cmp    $0x49,%eax
jne    1227 <deviceTest2GetInterface+0xd7>
cmpl   $0x0,-0x10(%rbp)
je     1210 <deviceTest2GetInterface+0xc0>
lea    0xe1b(%rip),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <setFunction@plt>
xor    %edi,%edi
lea    0xe1a(%rip),%rsi
call   1060 <setArgumentUnsignedHex4@plt>
mov    -0xc(%rbp),%edi
mov    $0x4,%esi
xor    %edx,%edx
call   1040 <commandLengthValueForMode@plt>
mov    %eax,-0x4(%rbp)
jmp    1233 <deviceTest2GetInterface+0xe3>
jmp    122c <deviceTest2GetInterface+0xdc>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deviceTest2GetInterface>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
cmp    $0x49,%dil
je     11af <deviceTest2GetInterface+0x5f>
cmp    $0x77,%dil
jne    11d8 <deviceTest2GetInterface+0x88>
test   %edx,%edx
je     11e4 <deviceTest2GetInterface+0x94>
lea    0xe94(%rip),%rdi
mov    $0x2,%ebp
mov    $0x2,%esi
mov    $0x1,%edx
call   1070 <setFunction@plt>
lea    0xe7f(%rip),%rsi
xor    %edi,%edi
call   1050 <setArgumentUnsignedHex2@plt>
lea    0xe73(%rip),%rsi
mov    $0x1,%edi
call   1050 <setArgumentUnsignedHex2@plt>
lea    0xe64(%rip),%rsi
xor    %edi,%edi
call   1030 <setResultUnsignedHex2@plt>
jmp    11ed <deviceTest2GetInterface+0x9d>
test   %edx,%edx
je     11eb <deviceTest2GetInterface+0x9b>
lea    0xe57(%rip),%rdi
xor    %ebp,%ebp
mov    $0x1,%esi
xor    %edx,%edx
call   1070 <setFunction@plt>
lea    0xe56(%rip),%rsi
xor    %edi,%edi
call   1060 <setArgumentUnsignedHex4@plt>
jmp    11ed <deviceTest2GetInterface+0x9d>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x2,%ebp
jmp    11ed <deviceTest2GetInterface+0x9d>
xor    %ebp,%ebp
mov    %ebx,%edi
mov    $0x4,%esi
mov    %ebp,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <commandLengthValueForMode@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"test2\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [7 x i8] c"result\00"
@.str.4 = [20 x i8] c"testDriverIntensive\00"
@.str.5 = [6 x i8] c"count\00"
define i32 @deviceTest2GetInterface(i8 zeroext %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 = zext i8 %8 to i32
%10 = icmp eq i32 %9, 119
br i1 %10, label %11, label %22
11: ; preds = %3
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = call i32 @setFunction(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 2, i32 1)
%16 = call i32 @setArgumentUnsignedHex2(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @setArgumentUnsignedHex2(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @setResultUnsignedHex2(i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %14, %11
%20 = load i32, i32* %6
%21 = call i32 @commandLengthValueForMode(i32 %20, i32 4, i32 2)
store i32 %21, i32* %4
br label %37
22: ; preds = %3
%23 = load i8, i8* %5
%24 = zext i8 %23 to i32
%25 = icmp eq i32 %24, 73
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = call i32 @setFunction(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
%31 = call i32 @setArgumentUnsignedHex4(i32 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %29, %26
%33 = load i32, i32* %6
%34 = call i32 @commandLengthValueForMode(i32 %33, i32 4, i32 0)
store i32 %34, i32* %4
br label %37
35: ; preds = %22
br label %36
36: ; preds = %35
store i32 -1, i32* %4
br label %37
37: ; preds = %36, %32, %19
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@.str = [6 x i8] c"test2\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [7 x i8] c"result\00"
@.str.4 = [20 x i8] c"testDriverIntensive\00"
@.str.5 = [6 x i8] c"count\00"
define i32 @deviceTest2GetInterface(i8 zeroext %0, i32 %1, i32 %2) {
switch i8 %0, label %19 [
i8 119, label %4
i8 73, label %11
]
4: ; preds = %3
%5 = icmp eq i32 %2, 0
br i1 %5, label %16, label %6
6: ; preds = %4
%7 = tail call i32 @setFunction(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 2, i32 1)
%8 = tail call i32 @setArgumentUnsignedHex2(i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @setArgumentUnsignedHex2(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @setResultUnsignedHex2(i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %16
11: ; preds = %3
%12 = icmp eq i32 %2, 0
br i1 %12, label %16, label %13
13: ; preds = %11
%14 = tail call i32 @setFunction(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 0)
%15 = tail call i32 @setArgumentUnsignedHex4(i32 0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %16
16: ; preds = %11, %13, %4, %6
%17 = phi i32 [ 2, %6 ], [ 2, %4 ], [ 0, %13 ], [ 0, %11 ]
%18 = tail call i32 @commandLengthValueForMode(i32 %1, i32 4, i32 %17)
br label %19
19: ; preds = %16, %3
%20 = phi i32 [ -1, %3 ], [ %18, %16 ]
ret i32 %20
}