#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*/ KEYPAD_Init(int *);
int KEYPAD_Read();
int /*<<< orphan*/ LED_GetState();
int /*<<< orphan*/ LED_Init(int, int /*<<< orphan*/);
int /*<<< orphan*/ LED_SetState(int);
int /*<<< orphan*/ TIMER0_Init(int);
int /*<<< orphan*/ delay(int);
int main() {
  LED_Init(7, 0);
  TIMER0_Init(1);
  int layoutTest[] = {5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17};
  KEYPAD_Init(layoutTest);
  int i;
  while (1) {
    i = KEYPAD_Read() * 2;
    while (i--) {
      LED_SetState(!LED_GetState());
      delay(1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x7,%edi
xor    %esi,%esi
call   1030 <LED_Init@plt>
mov    $0x1,%edi
call   1090 <TIMER0_Init@plt>
lea    -0x40(%rbp),%rdi
lea    0xe50(%rip),%rsi
mov    $0x30,%edx
call   1070 <memcpy@plt>
lea    -0x40(%rbp),%rdi
call   1080 <KEYPAD_Init@plt>
mov    $0x0,%al
call   1050 <KEYPAD_Read@plt>
shl    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x44(%rbp)
cmp    $0x0,%eax
je     120c <main+0x8c>
mov    $0x0,%al
call   1040 <LED_GetState@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <LED_SetState@plt>
mov    $0x1,%edi
call   1060 <delay@plt>
jmp    11d0 <main+0x50>
jmp    11c3 <main+0x43>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    $0x7,%edi
xor    %esi,%esi
call   1030 <LED_Init@plt>
mov    $0x1,%edi
call   1080 <TIMER0_Init@plt>
movaps 0xe8e(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe72(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe56(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1070 <KEYPAD_Init@plt>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <KEYPAD_Read@plt>
test   %eax,%eax
je     11c0 <main+0x50>
mov    %eax,%ebx
add    %eax,%ebx
neg    %ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <LED_GetState@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1090 <LED_SetState@plt>
mov    $0x1,%edi
call   1060 <delay@plt>
inc    %ebx
jne    11e0 <main+0x70>
jmp    11c0 <main+0x50>

LLVM IR (-O0):
@__const.main.layoutTest = [12 x i32] [i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 14, i32 15, i32 16, i32 17]
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @LED_Init(i32 7, i32 0)
%5 = call i32 @TIMER0_Init(i32 1)
%6 = bitcast [12 x i32]* %2 to i8*
%7 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 0
%8 = call i32 @KEYPAD_Init(i32* %7)
br label %9
9: ; preds = %0, %23
%10 = call i32 (...) @KEYPAD_Read()
%11 = mul nsw i32 %10, 2
store i32 %11, i32* %3
br label %12
12: ; preds = %16, %9
%13 = load i32, i32* %3
%14 = add nsw i32 %13, -1
store i32 %14, i32* %3
%15 = icmp ne i32 %13, 0
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = call i32 (...) @LED_GetState()
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
%20 = zext i1 %19 to i32
%21 = call i32 @LED_SetState(i32 %20)
%22 = call i32 @delay(i32 1)
br label %12
23: ; preds = %12
br label %9
}

LLVM IR (-O2):
@__const.main.layoutTest = [12 x i32] [i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 14, i32 15, i32 16, i32 17]
define i32 @main() {
%1 = alloca [12 x i32]
%2 = tail call i32 @LED_Init(i32 7, i32 0)
%3 = tail call i32 @TIMER0_Init(i32 1)
%4 = bitcast [12 x i32]* %1 to i8*
%5 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 0
%6 = call i32 @KEYPAD_Init(i32* %5)
br label %7
7: ; preds = %10, %0
%8 = call i32 (...) @KEYPAD_Read()
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %13, %7
br label %7
11: ; preds = %7
%12 = shl nsw i32 %8, 1
br label %13
13: ; preds = %11, %13
%14 = phi i32 [ %15, %13 ], [ %12, %11 ]
%15 = add nsw i32 %14, -1
%16 = call i32 (...) @LED_GetState()
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @LED_SetState(i32 %18)
%20 = call i32 @delay(i32 1)
%21 = icmp eq i32 %15, 0
br i1 %21, label %10, label %13
}