#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*/ clockPulse();
int /*<<< orphan*/ setBPin(int, char *);
void ht1632_chipselect(int select) {
  unsigned char tmp = 0;
  if (select < 0) {
    setBPin(3, "LOW");
    for (tmp = 0; tmp < (2 * 4); tmp++) {
      clockPulse();
    }
  } else if (select == 0) {
    setBPin(3, "HIGH");
    for (tmp = 0; tmp < (2 * 4); tmp++) {
      clockPulse();
    }
  } else {
    setBPin(3, "HIGH");
    for (tmp = 0; tmp < (2 * 4); tmp++) {
      clockPulse();
    }
    setBPin(3, "LOW");
    clockPulse();
    setBPin(3, "HIGH");
    tmp = 1;
    for (; tmp < select; tmp++) {
      clockPulse();
    }
  }
}


x86 assembly (clang, -O0):
<ht1632_chipselect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x5(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1174 <ht1632_chipselect+0x54>
mov    $0x3,%edi
lea    0xebb(%rip),%rsi
call   1040 <setBPin@plt>
movb   $0x0,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x8,%eax
jge    116f <ht1632_chipselect+0x4f>
mov    $0x0,%al
call   1030 <clockPulse@plt>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
jmp    114e <ht1632_chipselect+0x2e>
jmp    1247 <ht1632_chipselect+0x127>
cmpl   $0x0,-0x4(%rbp)
jne    11b9 <ht1632_chipselect+0x99>
mov    $0x3,%edi
lea    0xe7a(%rip),%rsi
call   1040 <setBPin@plt>
movb   $0x0,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x8,%eax
jge    11b4 <ht1632_chipselect+0x94>
mov    $0x0,%al
call   1030 <clockPulse@plt>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
jmp    1193 <ht1632_chipselect+0x73>
jmp    1242 <ht1632_chipselect+0x122>
mov    $0x3,%edi
lea    0xe3f(%rip),%rsi
call   1040 <setBPin@plt>
movb   $0x0,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    $0x8,%eax
jge    11ef <ht1632_chipselect+0xcf>
mov    $0x0,%al
call   1030 <clockPulse@plt>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
jmp    11ce <ht1632_chipselect+0xae>
mov    $0x3,%edi
lea    0xe05(%rip),%rsi
call   1040 <setBPin@plt>
mov    $0x0,%al
call   1030 <clockPulse@plt>
mov    $0x3,%edi
lea    0xdf1(%rip),%rsi
call   1040 <setBPin@plt>
movb   $0x1,-0x5(%rbp)
movzbl -0x5(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    123d <ht1632_chipselect+0x11d>
mov    $0x0,%al
call   1030 <clockPulse@plt>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
jmp    121c <ht1632_chipselect+0xfc>
jmp    1242 <ht1632_chipselect+0x122>
jmp    1247 <ht1632_chipselect+0x127>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ht1632_chipselect>:
push   %rbp
push   %rbx
push   %rax
test   %edi,%edi
js     11c9 <ht1632_chipselect+0xa9>
mov    %edi,%ebx
lea    0xed0(%rip),%rsi
mov    $0x3,%edi
call   1040 <setBPin@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
test   %ebx,%ebx
je     11c2 <ht1632_chipselect+0xa2>
lea    0xe7f(%rip),%rsi
mov    $0x3,%edi
call   1040 <setBPin@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
lea    0xe6b(%rip),%rsi
mov    $0x3,%edi
call   1040 <setBPin@plt>
cmp    $0x1,%ebx
je     11c2 <ht1632_chipselect+0xa2>
mov    $0x2,%bpl
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <clockPulse@plt>
movzbl %bpl,%eax
lea    0x1(%rax),%ebp
cmp    %ebx,%eax
jl     11b0 <ht1632_chipselect+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe30(%rip),%rsi
mov    $0x3,%edi
call   1040 <setBPin@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
call   1030 <clockPulse@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <clockPulse@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"LOW\00"
@.str.1 = [5 x i8] c"HIGH\00"
define void @ht1632_chipselect(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
store i8 0, i8* %3
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %18
6: ; preds = %1
%7 = call i32 @setBPin(i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8 0, i8* %3
br label %8
8: ; preds = %14, %6
%9 = load i8, i8* %3
%10 = zext i8 %9 to i32
%11 = icmp slt i32 %10, 8
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = call i32 (...) @clockPulse()
br label %14
14: ; preds = %12
%15 = load i8, i8* %3
%16 = add i8 %15, 1
store i8 %16, i8* %3
br label %8
17: ; preds = %8
br label %60
18: ; preds = %1
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = call i32 @setBPin(i32 3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8 0, i8* %3
br label %23
23: ; preds = %29, %21
%24 = load i8, i8* %3
%25 = zext i8 %24 to i32
%26 = icmp slt i32 %25, 8
br i1 %26, label %27, label %32
27: ; preds = %23
%28 = call i32 (...) @clockPulse()
br label %29
29: ; preds = %27
%30 = load i8, i8* %3
%31 = add i8 %30, 1
store i8 %31, i8* %3
br label %23
32: ; preds = %23
br label %59
33: ; preds = %18
%34 = call i32 @setBPin(i32 3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8 0, i8* %3
br label %35
35: ; preds = %41, %33
%36 = load i8, i8* %3
%37 = zext i8 %36 to i32
%38 = icmp slt i32 %37, 8
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = call i32 (...) @clockPulse()
br label %41
41: ; preds = %39
%42 = load i8, i8* %3
%43 = add i8 %42, 1
store i8 %43, i8* %3
br label %35
44: ; preds = %35
%45 = call i32 @setBPin(i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%46 = call i32 (...) @clockPulse()
%47 = call i32 @setBPin(i32 3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8 1, i8* %3
br label %48
48: ; preds = %55, %44
%49 = load i8, i8* %3
%50 = zext i8 %49 to i32
%51 = load i32, i32* %2
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %58
53: ; preds = %48
%54 = call i32 (...) @clockPulse()
br label %55
55: ; preds = %53
%56 = load i8, i8* %3
%57 = add i8 %56, 1
store i8 %57, i8* %3
br label %48
58: ; preds = %48
br label %59
59: ; preds = %58, %32
br label %60
60: ; preds = %59, %17
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"LOW\00"
@.str.1 = [5 x i8] c"HIGH\00"
define void @ht1632_chipselect(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %13
3: ; preds = %1
%4 = tail call i32 @setBPin(i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (...) @clockPulse()
%6 = tail call i32 (...) @clockPulse()
%7 = tail call i32 (...) @clockPulse()
%8 = tail call i32 (...) @clockPulse()
%9 = tail call i32 (...) @clockPulse()
%10 = tail call i32 (...) @clockPulse()
%11 = tail call i32 (...) @clockPulse()
%12 = tail call i32 (...) @clockPulse()
br label %35
13: ; preds = %1
%14 = icmp eq i32 %0, 0
%15 = tail call i32 @setBPin(i32 3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 (...) @clockPulse()
%17 = tail call i32 (...) @clockPulse()
%18 = tail call i32 (...) @clockPulse()
%19 = tail call i32 (...) @clockPulse()
%20 = tail call i32 (...) @clockPulse()
%21 = tail call i32 (...) @clockPulse()
%22 = tail call i32 (...) @clockPulse()
%23 = tail call i32 (...) @clockPulse()
br i1 %14, label %35, label %24
24: ; preds = %13
%25 = tail call i32 @setBPin(i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%26 = tail call i32 (...) @clockPulse()
%27 = tail call i32 @setBPin(i32 3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i32 %0, 1
br i1 %28, label %35, label %29
29: ; preds = %24, %29
%30 = phi i8 [ %32, %29 ], [ 1, %24 ]
%31 = tail call i32 (...) @clockPulse()
%32 = add i8 %30, 1
%33 = zext i8 %32 to i32
%34 = icmp slt i32 %33, %0
br i1 %34, label %29, label %35
35: ; preds = %29, %13, %3, %24
ret void
}