#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 */
typedef int uint8_t;

/* Variables and functions */
scalar_t__ gpio_iic_Gack();
int /*<<< orphan*/ gpio_iic_start();
int /*<<< orphan*/ gpio_iic_stop();
int /*<<< orphan*/ gpio_iic_write(int);
uint8_t LTC2309_set_channel(uint8_t channel) {
  gpio_iic_start();
  gpio_iic_write((0x10));
  if (gpio_iic_Gack())
    return 1;
  else {
    gpio_iic_write(channel);
    if (gpio_iic_Gack())
      return 1;
    else {
      gpio_iic_stop();
      return 0;
    }
  }
}


x86 assembly (clang, -O0):
<LTC2309_set_channel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <gpio_iic_start@plt>
mov    $0x10,%edi
call   1030 <gpio_iic_write@plt>
mov    $0x0,%al
call   1040 <gpio_iic_Gack@plt>
cmp    $0x0,%rax
je     1179 <LTC2309_set_channel+0x39>
movl   $0x1,-0x4(%rbp)
jmp    11ac <LTC2309_set_channel+0x6c>
mov    -0x8(%rbp),%edi
call   1030 <gpio_iic_write@plt>
mov    $0x0,%al
call   1040 <gpio_iic_Gack@plt>
cmp    $0x0,%rax
je     119e <LTC2309_set_channel+0x5e>
movl   $0x1,-0x4(%rbp)
jmp    11ac <LTC2309_set_channel+0x6c>
mov    $0x0,%al
call   1050 <gpio_iic_stop@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LTC2309_set_channel>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <gpio_iic_start@plt>
mov    $0x10,%edi
call   1030 <gpio_iic_write@plt>
xor    %eax,%eax
call   1040 <gpio_iic_Gack@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    1183 <LTC2309_set_channel+0x43>
mov    %ebp,%edi
call   1030 <gpio_iic_write@plt>
xor    %eax,%eax
call   1040 <gpio_iic_Gack@plt>
test   %rax,%rax
jne    1183 <LTC2309_set_channel+0x43>
xor    %eax,%eax
call   1050 <gpio_iic_stop@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @LTC2309_set_channel(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = call i32 (...) @gpio_iic_start()
%5 = call i32 @gpio_iic_write(i32 16)
%6 = call i64 (...) @gpio_iic_Gack()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 1, i32* %2
br label %17
9: ; preds = %1
%10 = load i32, i32* %3
%11 = call i32 @gpio_iic_write(i32 %10)
%12 = call i64 (...) @gpio_iic_Gack()
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9
store i32 1, i32* %2
br label %17
15: ; preds = %9
%16 = call i32 (...) @gpio_iic_stop()
store i32 0, i32* %2
br label %17
17: ; preds = %15, %14, %8
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
define i32 @LTC2309_set_channel(i32 %0) {
%2 = tail call i32 (...) @gpio_iic_start()
%3 = tail call i32 @gpio_iic_write(i32 16)
%4 = tail call i64 (...) @gpio_iic_Gack()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = tail call i32 @gpio_iic_write(i32 %0)
%8 = tail call i64 (...) @gpio_iic_Gack()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 (...) @gpio_iic_stop()
br label %12
12: ; preds = %6, %1, %10
%13 = phi i32 [ 0, %10 ], [ 1, %1 ], [ 1, %6 ]
ret i32 %13
}