#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*/ delay(int);
int main() {
  LED_Init(7, 0);
  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(400);
    }
  }
  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>
lea    -0x40(%rbp),%rdi
lea    0xe6a(%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     11f2 <main+0x82>
mov    $0x0,%al
call   1040 <LED_GetState@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1090 <LED_SetState@plt>
mov    $0x190,%edi
call   1060 <delay@plt>
jmp    11b6 <main+0x46>
jmp    11a9 <main+0x39>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    $0x7,%edi
xor    %esi,%esi
call   1030 <LED_Init@plt>
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe8c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe70(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
call   1070 <KEYPAD_Init@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <KEYPAD_Read@plt>
test   %eax,%eax
je     11a0 <main+0x40>
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   1080 <LED_SetState@plt>
mov    $0x190,%edi
call   1060 <delay@plt>
inc    %ebx
jne    11c0 <main+0x60>
jmp    11a0 <main+0x40>

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 = bitcast [12 x i32]* %2 to i8*
%6 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 0
%7 = call i32 @KEYPAD_Init(i32* %6)
br label %8
8: ; preds = %0, %22
%9 = call i32 (...) @KEYPAD_Read()
%10 = mul nsw i32 %9, 2
store i32 %10, i32* %3
br label %11
11: ; preds = %15, %8
%12 = load i32, i32* %3
%13 = add nsw i32 %12, -1
store i32 %13, i32* %3
%14 = icmp ne i32 %12, 0
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = call i32 (...) @LED_GetState()
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = call i32 @LED_SetState(i32 %19)
%21 = call i32 @delay(i32 400)
br label %11
22: ; preds = %11
br label %8
}

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 = bitcast [12 x i32]* %1 to i8*
%4 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 0
%5 = call i32 @KEYPAD_Init(i32* %4)
br label %6
6: ; preds = %9, %0
%7 = call i32 (...) @KEYPAD_Read()
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %12, %6
br label %6
10: ; preds = %6
%11 = shl nsw i32 %7, 1
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ %14, %12 ], [ %11, %10 ]
%14 = add nsw i32 %13, -1
%15 = call i32 (...) @LED_GetState()
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @LED_SetState(i32 %17)
%19 = call i32 @delay(i32 400)
%20 = icmp eq i32 %14, 0
br i1 %20, label %9, label %12
}