#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 */
typedef int uint8_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ set_led_8_8_12(int, int, int, int);
void set_z(uint8_t x, uint8_t y, uint16_t intensity) {
  if (intensity > ((8 - 1) * (1 << 12) - 1))
    return;
  uint8_t lower_z = intensity >> 12;
  uint16_t upper_i = intensity & ((1 << 12) - 1);
  uint16_t lower_i = ((1 << 12) - 1) - upper_i;
  set_led_8_8_12(x, y, lower_z, lower_i);
  set_led_8_8_12(x, y, lower_z + 1, upper_i);
}


x86 assembly (clang, -O0):
<set_z>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x6fff,-0xc(%rbp)
jle    1133 <set_z+0x23>
jmp    1177 <set_z+0x67>
mov    -0xc(%rbp),%eax
sar    $0xc,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfff,%eax
mov    %eax,-0x14(%rbp)
mov    $0xfff,%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <set_led_8_8_12@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
mov    -0x14(%rbp),%ecx
call   1030 <set_led_8_8_12@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_z>:
cmp    $0x6fff,%edx
jle    1119 <set_z+0x9>
ret
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r15d
mov    %edx,%ebp
sar    $0xc,%ebp
and    $0xfff,%ebx
mov    %ebx,%ecx
xor    $0xfff,%ecx
mov    %ebp,%edx
call   1030 <set_led_8_8_12@plt>
add    $0x1,%ebp
mov    %r15d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <set_led_8_8_12@plt>

LLVM IR (-O0):
define void @set_z(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = icmp sgt i32 %10, 28671
br i1 %11, label %12, label %13
12: ; preds = %3
br label %31
13: ; preds = %3
%14 = load i32, i32* %6
%15 = ashr i32 %14, 12
store i32 %15, i32* %7
%16 = load i32, i32* %6
%17 = and i32 %16, 4095
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = sub nsw i32 4095, %18
store i32 %19, i32* %9
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = load i32, i32* %7
%23 = load i32, i32* %9
%24 = call i32 @set_led_8_8_12(i32 %20, i32 %21, i32 %22, i32 %23)
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
%29 = load i32, i32* %8
%30 = call i32 @set_led_8_8_12(i32 %25, i32 %26, i32 %28, i32 %29)
br label %31
31: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
define void @set_z(i32 %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %2, 28671
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = ashr i32 %2, 12
%7 = and i32 %2, 4095
%8 = xor i32 %7, 4095
%9 = tail call i32 @set_led_8_8_12(i32 %0, i32 %1, i32 %6, i32 %8)
%10 = add nsw i32 %6, 1
%11 = tail call i32 @set_led_8_8_12(i32 %0, i32 %1, i32 %10, i32 %7)
br label %12
12: ; preds = %3, %5
ret void
}