#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*/ cmpKernelVersion(int, int, ...);
int /*<<< orphan*/ piBoardId(int *, int *, int *, int *, int *);
int wiringPiI2CSetupInterface(char const *, int const);
int wiringPiI2CSetup(const int devId) {
  int model, rev, mem, maker, overVolted;
  const char *device = NULL;
  piBoardId(&model, &rev, &mem, &maker, &overVolted);
  switch (model) {
  case 1:
  case 2:
    if (cmpKernelVersion(1, 4))
      device = "/dev/i2c-0";
    else
      device = "/dev/i2c-1";
    break;
  case 3:
    if (cmpKernelVersion(1, 5))
      device = "/dev/i2c-0";
    else
      device = "/dev/i2c-1";
    break;
  case 4:
    device = "/dev/i2c-4";
    break;
  case 5:
  case 6:
  case 7:
    if (cmpKernelVersion(3, 4, 9, 230))
      device = "/dev/i2c-0";
    else
      device = "/dev/i2c-2";
    break;
  }
  return wiringPiI2CSetupInterface(device, devId);
}


x86 assembly (clang, -O0):
<wiringPiI2CSetup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1050 <piBoardId@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x6,%eax
ja     124d <wiringPiI2CSetup+0x11d>
mov    -0x28(%rbp),%rax
lea    0xe84(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%edi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <cmpKernelVersion@plt>
cmp    $0x0,%eax
je     11af <wiringPiI2CSetup+0x7f>
lea    0xe76(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ba <wiringPiI2CSetup+0x8a>
lea    0xe71(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    124d <wiringPiI2CSetup+0x11d>
mov    $0x1,%edi
mov    $0x5,%esi
mov    $0x0,%al
call   1030 <cmpKernelVersion@plt>
cmp    $0x0,%eax
je     11e9 <wiringPiI2CSetup+0xb9>
lea    0xe3c(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11f4 <wiringPiI2CSetup+0xc4>
lea    0xe37(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    124d <wiringPiI2CSetup+0x11d>
lea    0xe32(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    124d <wiringPiI2CSetup+0x11d>
mov    $0x3,%edi
mov    $0x4,%esi
mov    $0x9,%edx
mov    $0xe6,%ecx
mov    $0x0,%al
call   1030 <cmpKernelVersion@plt>
cmp    $0x0,%eax
je     123d <wiringPiI2CSetup+0x10d>
lea    0xde8(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1248 <wiringPiI2CSetup+0x118>
lea    0xdf9(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    124d <wiringPiI2CSetup+0x11d>
mov    -0x20(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1040 <wiringPiI2CSetupInterface@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wiringPiI2CSetup>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
lea    0xc(%rsp),%rdi
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
call   1050 <piBoardId@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x6,%eax
ja     11a3 <wiringPiI2CSetup+0x73>
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x3,%edi
mov    $0x4,%esi
mov    $0x9,%edx
mov    $0xe6,%ecx
xor    %eax,%eax
call   1030 <cmpKernelVersion@plt>
test   %eax,%eax
lea    0xea8(%rip),%rax
jmp    11c1 <wiringPiI2CSetup+0x91>
mov    $0x1,%edi
mov    $0x4,%esi
jmp    11b1 <wiringPiI2CSetup+0x81>
xor    %edi,%edi
jmp    11cc <wiringPiI2CSetup+0x9c>
mov    $0x1,%edi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <cmpKernelVersion@plt>
test   %eax,%eax
lea    0xe66(%rip),%rax
lea    0xe54(%rip),%rdi
cmove  %rax,%rdi
mov    %ebx,%esi
call   1040 <wiringPiI2CSetupInterface@plt>
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe52(%rip),%rdi
jmp    11cc <wiringPiI2CSetup+0x9c>

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/i2c-0\00"
@.str.1 = [11 x i8] c"/dev/i2c-1\00"
@.str.2 = [11 x i8] c"/dev/i2c-4\00"
@.str.3 = [11 x i8] c"/dev/i2c-2\00"
define i32 @wiringPiI2CSetup(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %2
store i8* null, i8** %8
%9 = call i32 @piBoardId(i32* %3, i32* %4, i32* %5, i32* %6, i32* %7)
%10 = load i32, i32* %3
switch i32 %10, label %30 [
i32 1, label %11
i32 2, label %11
i32 3, label %17
i32 4, label %23
i32 5, label %24
i32 6, label %24
i32 7, label %24
]
11: ; preds = %1, %1
%12 = call i32 (i32, i32, ...) @cmpKernelVersion(i32 1, i32 4)
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %8
br label %16
15: ; preds = %11
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %8
br label %16
16: ; preds = %15, %14
br label %30
17: ; preds = %1
%18 = call i32 (i32, i32, ...) @cmpKernelVersion(i32 1, i32 5)
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %17
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %8
br label %22
21: ; preds = %17
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %8
br label %22
22: ; preds = %21, %20
br label %30
23: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %8
br label %30
24: ; preds = %1, %1, %1
%25 = call i32 (i32, i32, ...) @cmpKernelVersion(i32 3, i32 4, i32 9, i32 230)
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %8
br label %29
28: ; preds = %24
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8** %8
br label %29
29: ; preds = %28, %27
br label %30
30: ; preds = %1, %29, %23, %22, %16
%31 = load i8*, i8** %8
%32 = load i32, i32* %2
%33 = call i32 @wiringPiI2CSetupInterface(i8* %31, i32 %32)
ret i32 %33
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-0\00"
@.str.1 = [11 x i8] c"/dev/i2c-1\00"
@.str.2 = [11 x i8] c"/dev/i2c-4\00"
@.str.3 = [11 x i8] c"/dev/i2c-2\00"
define i32 @wiringPiI2CSetup(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = call i32 @piBoardId(i32* %2, i32* %3, i32* %4, i32* %5, i32* %6)
%13 = load i32, i32* %2
switch i32 %13, label %27 [
i32 1, label %14
i32 2, label %14
i32 3, label %18
i32 4, label %22
i32 5, label %23
i32 6, label %23
i32 7, label %23
]
14: ; preds = %1, %1
%15 = call i32 (i32, i32, ...) @cmpKernelVersion(i32 1, i32 4)
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0)
br label %27
18: ; preds = %1
%19 = call i32 (i32, i32, ...) @cmpKernelVersion(i32 1, i32 5)
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0)
br label %27
22: ; preds = %1
br label %27
23: ; preds = %1, %1, %1
%24 = call i32 (i32, i32, ...) @cmpKernelVersion(i32 3, i32 4, i32 9, i32 230)
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0)
br label %27
27: ; preds = %23, %18, %14, %1, %22
%28 = phi i8* [ null, %1 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %22 ], [ %17, %14 ], [ %21, %18 ], [ %26, %23 ]
%29 = call i32 @wiringPiI2CSetupInterface(i8* %28, i32 %0)
ret i32 %29
}