#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 i2c_smbus_read_byte_data(int, unsigned char);
int /*<<< orphan*/ i2c_smbus_read_word_data(int, unsigned char);
int swap16(int /*<<< orphan*/);
int ds1621_read_value(int client, unsigned char reg) {
  if ((reg == 0xAC) || (reg == 0xA8) || (reg == 0xA9))
    return i2c_smbus_read_byte_data(client, reg);
  else {
    return swap16(i2c_smbus_read_word_data(client, reg));
  }
}


x86 assembly (clang, -O0):
<ds1621_read_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
cmp    $0xac,%eax
je     116e <ds1621_read_value+0x3e>
movzbl -0x9(%rbp),%eax
cmp    $0xa8,%eax
je     116e <ds1621_read_value+0x3e>
movzbl -0x9(%rbp),%eax
cmp    $0xa9,%eax
jne    1182 <ds1621_read_value+0x52>
mov    -0x8(%rbp),%edi
movzbl -0x9(%rbp),%esi
call   1050 <i2c_smbus_read_byte_data@plt>
mov    %eax,-0x4(%rbp)
jmp    1198 <ds1621_read_value+0x68>
mov    -0x8(%rbp),%edi
movzbl -0x9(%rbp),%esi
call   1040 <i2c_smbus_read_word_data@plt>
mov    %eax,%edi
call   1030 <swap16@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ds1621_read_value>:
lea    0x58(%rsi),%eax
cmp    $0x4,%al
ja     114d <ds1621_read_value+0x1d>
movzbl %al,%eax
mov    $0x13,%ecx
bt     %eax,%ecx
jae    114d <ds1621_read_value+0x1d>
movzbl %sil,%esi
jmp    1050 <i2c_smbus_read_byte_data@plt>
push   %rax
movzbl %sil,%esi
call   1040 <i2c_smbus_read_word_data@plt>
mov    %eax,%edi
pop    %rax
jmp    1030 <swap16@plt>

LLVM IR (-O0):
define i32 @ds1621_read_value(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 %0, i32* %4
store i8 %1, i8* %5
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = icmp eq i32 %7, 172
br i1 %8, label %17, label %9
9: ; preds = %2
%10 = load i8, i8* %5
%11 = zext i8 %10 to i32
%12 = icmp eq i32 %11, 168
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = load i8, i8* %5
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 169
br i1 %16, label %17, label %21
17: ; preds = %13, %9, %2
%18 = load i32, i32* %4
%19 = load i8, i8* %5
%20 = call i32 @i2c_smbus_read_byte_data(i32 %18, i8 zeroext %19)
store i32 %20, i32* %3
br label %26
21: ; preds = %13
%22 = load i32, i32* %4
%23 = load i8, i8* %5
%24 = call i32 @i2c_smbus_read_word_data(i32 %22, i8 zeroext %23)
%25 = call i32 @swap16(i32 %24)
store i32 %25, i32* %3
br label %26
26: ; preds = %21, %17
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @ds1621_read_value(i32 %0, i8 zeroext %1) {
switch i8 %1, label %5 [
i8 -84, label %3
i8 -87, label %3
i8 -88, label %3
]
3: ; preds = %2, %2, %2
%4 = tail call i32 @i2c_smbus_read_byte_data(i32 %0, i8 zeroext %1)
br label %8
5: ; preds = %2
%6 = tail call i32 @i2c_smbus_read_word_data(i32 %0, i8 zeroext %1)
%7 = tail call i32 @swap16(i32 %6)
br label %8
8: ; preds = %5, %3
%9 = phi i32 [ %4, %3 ], [ %7, %5 ]
ret i32 %9
}