#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 */
unsigned char inb(unsigned int);
int /*<<< orphan*/ outb(unsigned char, unsigned int);
int smbus_wait(unsigned int);
int smbus_start_condition(unsigned smbus_io_base) {
  unsigned char val;
  val = inb(smbus_io_base + 0x03);
  outb(val | (0x01 << 0), smbus_io_base + 0x03);
  val = inb(smbus_io_base + 0x01);
  if ((val & (0x01 << 5)) != 0)
    return -1;
  return smbus_wait(smbus_io_base);
}


x86 assembly (clang, -O0):
<smbus_start_condition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
add    $0x3,%edi
call   1050 <inb@plt>
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
or     $0x1,%eax
mov    -0x8(%rbp),%esi
add    $0x3,%esi
movzbl %al,%edi
call   1030 <outb@plt>
mov    -0x8(%rbp),%edi
add    $0x1,%edi
call   1050 <inb@plt>
mov    %al,-0x9(%rbp)
movzbl -0x9(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     1188 <smbus_start_condition+0x58>
movl   $0xffffffff,-0x4(%rbp)
jmp    1193 <smbus_start_condition+0x63>
mov    -0x8(%rbp),%edi
call   1040 <smbus_wait@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smbus_start_condition>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x3(%rbx),%ebp
mov    %ebp,%edi
call   1050 <inb@plt>
or     $0x1,%al
movzbl %al,%edi
mov    %ebp,%esi
call   1030 <outb@plt>
lea    0x1(%rbx),%edi
call   1050 <inb@plt>
test   $0x20,%al
jne    1164 <smbus_start_condition+0x34>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <smbus_wait@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @smbus_start_condition(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = add i32 %5, 3
%7 = call zeroext i8 @inb(i32 %6)
store i8 %7, i8* %4
%8 = load i8, i8* %4
%9 = zext i8 %8 to i32
%10 = or i32 %9, 1
%11 = trunc i32 %10 to i8
%12 = load i32, i32* %3
%13 = add i32 %12, 3
%14 = call i32 @outb(i8 zeroext %11, i32 %13)
%15 = load i32, i32* %3
%16 = add i32 %15, 1
%17 = call zeroext i8 @inb(i32 %16)
store i8 %17, i8* %4
%18 = load i8, i8* %4
%19 = zext i8 %18 to i32
%20 = and i32 %19, 32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %1
store i32 -1, i32* %2
br label %26
23: ; preds = %1
%24 = load i32, i32* %3
%25 = call i32 @smbus_wait(i32 %24)
store i32 %25, i32* %2
br label %26
26: ; preds = %23, %22
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @smbus_start_condition(i32 %0) {
%2 = add i32 %0, 3
%3 = tail call zeroext i8 @inb(i32 %2)
%4 = or i8 %3, 1
%5 = tail call i32 @outb(i8 zeroext %4, i32 %2)
%6 = add i32 %0, 1
%7 = tail call zeroext i8 @inb(i32 %6)
%8 = and i8 %7, 32
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = tail call i32 @smbus_wait(i32 %0)
br label %12
12: ; preds = %1, %10
%13 = phi i32 [ %11, %10 ], [ -1, %1 ]
ret i32 %13
}