#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*/ OS_udelay(int);
int write_whitney(int, int);
int LLI2C_output_clock(int state) {
  int err;
  if (state) {
    err = write_whitney(0x5014, 0x0001);
    if (err)
      return err;
    err = write_whitney(0x5014, 0x0000);
    if (err)
      return err;
    OS_udelay(5);
  } else {
    err = write_whitney(0x5014, 0x0003);
    if (err)
      return err;
    err = write_whitney(0x5014, 0x0002);
    if (err)
      return err;
  }
  return 0;
}


x86 assembly (clang, -O0):
<LLI2C_output_clock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     118f <LLI2C_output_clock+0x6f>
mov    $0x5014,%edi
mov    $0x1,%esi
call   1040 <write_whitney@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     115c <LLI2C_output_clock+0x3c>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e9 <LLI2C_output_clock+0xc9>
mov    $0x5014,%edi
xor    %esi,%esi
call   1040 <write_whitney@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1180 <LLI2C_output_clock+0x60>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e9 <LLI2C_output_clock+0xc9>
mov    $0x5,%edi
call   1030 <OS_udelay@plt>
jmp    11e2 <LLI2C_output_clock+0xc2>
mov    $0x5014,%edi
mov    $0x3,%esi
call   1040 <write_whitney@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11b6 <LLI2C_output_clock+0x96>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e9 <LLI2C_output_clock+0xc9>
mov    $0x5014,%edi
mov    $0x2,%esi
call   1040 <write_whitney@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11dd <LLI2C_output_clock+0xbd>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e9 <LLI2C_output_clock+0xc9>
jmp    11e2 <LLI2C_output_clock+0xc2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LLI2C_output_clock>:
push   %rax
test   %edi,%edi
je     113a <LLI2C_output_clock+0x1a>
mov    $0x5014,%edi
mov    $0x1,%esi
call   1040 <write_whitney@plt>
test   %eax,%eax
je     1162 <LLI2C_output_clock+0x42>
pop    %rcx
ret
mov    $0x5014,%edi
mov    $0x3,%esi
call   1040 <write_whitney@plt>
test   %eax,%eax
jne    1138 <LLI2C_output_clock+0x18>
mov    $0x5014,%edi
mov    $0x2,%esi
call   1040 <write_whitney@plt>
test   %eax,%eax
jne    1138 <LLI2C_output_clock+0x18>
jmp    117c <LLI2C_output_clock+0x5c>
mov    $0x5014,%edi
xor    %esi,%esi
call   1040 <write_whitney@plt>
test   %eax,%eax
jne    1138 <LLI2C_output_clock+0x18>
mov    $0x5,%edi
call   1030 <OS_udelay@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @LLI2C_output_clock(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %1
%8 = call i32 @write_whitney(i32 20500, i32 1)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = load i32, i32* %4
store i32 %12, i32* %2
br label %35
13: ; preds = %7
%14 = call i32 @write_whitney(i32 20500, i32 0)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = load i32, i32* %4
store i32 %18, i32* %2
br label %35
19: ; preds = %13
%20 = call i32 @OS_udelay(i32 5)
br label %34
21: ; preds = %1
%22 = call i32 @write_whitney(i32 20500, i32 3)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load i32, i32* %4
store i32 %26, i32* %2
br label %35
27: ; preds = %21
%28 = call i32 @write_whitney(i32 20500, i32 2)
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = load i32, i32* %4
store i32 %32, i32* %2
br label %35
33: ; preds = %27
br label %34
34: ; preds = %33, %19
store i32 0, i32* %2
br label %35
35: ; preds = %34, %31, %25, %17, %11
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
define i32 @LLI2C_output_clock(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = tail call i32 @write_whitney(i32 20500, i32 1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %18
6: ; preds = %3
%7 = tail call i32 @write_whitney(i32 20500, i32 0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = tail call i32 @OS_udelay(i32 5)
br label %17
11: ; preds = %1
%12 = tail call i32 @write_whitney(i32 20500, i32 3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = tail call i32 @write_whitney(i32 20500, i32 2)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14, %9
br label %18
18: ; preds = %14, %11, %6, %3, %17
%19 = phi i32 [ 0, %17 ], [ %4, %3 ], [ %7, %6 ], [ %12, %11 ], [ %15, %14 ]
ret i32 %19
}