#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*/ Uart_SendString(char *);
int led_ctl(int lednumber, int ctl) {
  int bits = (*(volatile unsigned *)0x56000014);
  if ((lednumber > 4) && (lednumber < 1)) {
    Uart_SendString("bad lde number\n");
    return -1;
  }
  if (ctl != 0) {
    (*(volatile unsigned *)0x56000014) = bits & (~(1 << (3 + lednumber)));
  } else {
    (*(volatile unsigned *)0x56000014) = bits | (1 << (3 + lednumber));
  }
  return 0;
}


x86 assembly (clang, -O0):
<led_ctl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x56000014,%eax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    1154 <led_ctl+0x44>
cmpl   $0x1,-0x8(%rbp)
jge    1154 <led_ctl+0x44>
lea    0xebd(%rip),%rdi
call   1030 <Uart_SendString@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ab <led_ctl+0x9b>
cmpl   $0x0,-0xc(%rbp)
je     1185 <led_ctl+0x75>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%ecx
add    $0x3,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x14(%rbp),%ecx
xor    $0xffffffff,%eax
and    %eax,%ecx
mov    $0x56000014,%eax
mov    %ecx,(%rax)
jmp    11a4 <led_ctl+0x94>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%ecx
add    $0x3,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x18(%rbp),%ecx
or     %eax,%ecx
mov    $0x56000014,%eax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<led_ctl>:
mov    0x56000014,%eax
add    $0x3,%dil
mov    %eax,%ecx
btr    %edi,%ecx
bts    %edi,%eax
test   %esi,%esi
cmovne %ecx,%eax
mov    %eax,0x56000014
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [16 x i8] c"bad lde number\0A\00"
define i32 @led_ctl(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load volatile i32, i32* inttoptr (i64 1442840596 to i32*)
store i32 %7, i32* %6
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 4
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @Uart_SendString(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %32
15: ; preds = %10, %2
%16 = load i32, i32* %5
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %15
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = add nsw i32 3, %20
%22 = shl i32 1, %21
%23 = xor i32 %22, -1
%24 = and i32 %19, %23
store volatile i32 %24, i32* inttoptr (i64 1442840596 to i32*)
br label %31
25: ; preds = %15
%26 = load i32, i32* %6
%27 = load i32, i32* %4
%28 = add nsw i32 3, %27
%29 = shl i32 1, %28
%30 = or i32 %26, %29
store volatile i32 %30, i32* inttoptr (i64 1442840596 to i32*)
br label %31
31: ; preds = %25, %18
store i32 0, i32* %3
br label %32
32: ; preds = %31, %13
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @led_ctl(i32 %0, i32 %1) {
%3 = load volatile i32, i32* inttoptr (i64 1442840596 to i32*)
%4 = icmp eq i32 %1, 0
%5 = add nsw i32 %0, 3
%6 = shl nuw i32 1, %5
%7 = xor i32 %6, -1
%8 = and i32 %3, %7
%9 = or i32 %3, %6
%10 = select i1 %4, i32 %9, i32 %8
store volatile i32 %10, i32* inttoptr (i64 1442840596 to i32*)
ret i32 0
}