#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*/ piBoardId(int *, int *, int *, int *, int *);
int piGpioLayout();
int wiringPiI2CSetupInterface(char const *, int const);
int wiringPiI2CSetup(const int devId) {
  const char *device;
  int model, rev, mem, maker, overVolted;
  piBoardId(&model, &rev, &mem, &maker, &overVolted);
  if (model == 13 || model == 15)
    device = "/dev/i2c-1";
  else if (model == 14)
    device = "/dev/i2c-4";
  else {
    rev = piGpioLayout();
    if (rev == 1)
      device = "/dev/i2c-0";
    else
      device = "/dev/i2c-1";
  }
  return wiringPiI2CSetupInterface(device, devId);
}


x86 assembly (clang, -O0):
<wiringPiI2CSetup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
call   1050 <piBoardId@plt>
cmpl   $0xd,-0x14(%rbp)
je     1168 <wiringPiI2CSetup+0x38>
cmpl   $0xf,-0x14(%rbp)
jne    1178 <wiringPiI2CSetup+0x48>
lea    0xe91(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11cb <wiringPiI2CSetup+0x9b>
cmpl   $0xe,-0x14(%rbp)
jne    1192 <wiringPiI2CSetup+0x62>
lea    0xe82(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c6 <wiringPiI2CSetup+0x96>
mov    $0x0,%al
call   1030 <piGpioLayout@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    11b6 <wiringPiI2CSetup+0x86>
lea    0xe69(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c1 <wiringPiI2CSetup+0x91>
lea    0xe43(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11c6 <wiringPiI2CSetup+0x96>
jmp    11cb <wiringPiI2CSetup+0x9b>
mov    -0x10(%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    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x14(%rsp),%r8
call   1050 <piBoardId@plt>
mov    0x10(%rsp),%eax
mov    %eax,%ecx
and    $0xfffffffd,%ecx
cmp    $0xd,%ecx
jne    116c <wiringPiI2CSetup+0x3c>
lea    0xe96(%rip),%rdi
jmp    119a <wiringPiI2CSetup+0x6a>
cmp    $0xe,%eax
jne    117a <wiringPiI2CSetup+0x4a>
lea    0xe93(%rip),%rdi
jmp    119a <wiringPiI2CSetup+0x6a>
xor    %eax,%eax
call   1030 <piGpioLayout@plt>
mov    %eax,0xc(%rsp)
cmp    $0x1,%eax
lea    0xe87(%rip),%rax
lea    0xe6a(%rip),%rdi
cmove  %rax,%rdi
mov    %ebx,%esi
call   1040 <wiringPiI2CSetupInterface@plt>
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/i2c-1\00"
@.str.1 = [11 x i8] c"/dev/i2c-4\00"
@.str.2 = [11 x i8] c"/dev/i2c-0\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
%14 = and i32 %13, -3
%15 = icmp eq i32 %14, 13
br i1 %15, label %22, label %16
16: ; preds = %1
%17 = icmp eq i32 %13, 14
br i1 %17, label %22, label %18
18: ; preds = %16
%19 = call i32 (...) @piGpioLayout()
store i32 %19, i32* %3
%20 = icmp eq i32 %19, 1
%21 = select i1 %20, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0)
br label %22
22: ; preds = %18, %16, %1
%23 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %16 ], [ %21, %18 ]
%24 = call i32 @wiringPiI2CSetupInterface(i8* %23, i32 %0)
ret i32 %24
}