#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*/ boot_property_add(char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
void hwLcd_setBootProperty(int density) {
  char temp[8];
  if (density != 213) {
    if (density < (120 + 160) / 2)
      density = 120;
    else if (density < (160 + 240) / 2)
      density = 160;
    else if (density < (240 + 320) / 2)
      density = 240;
    else
      density = 320;
  }
  snprintf(temp, sizeof temp, "%d", density);
  boot_property_add("qemu.sf.lcd_density", temp);
}


x86 assembly (clang, -O0):
<hwLcd_setBootProperty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0xd5,-0x4(%rbp)
je     1199 <hwLcd_setBootProperty+0x79>
cmpl   $0x8c,-0x4(%rbp)
jge    1151 <hwLcd_setBootProperty+0x31>
movl   $0x78,-0x4(%rbp)
jmp    1194 <hwLcd_setBootProperty+0x74>
cmpl   $0xc8,-0x4(%rbp)
jge    116a <hwLcd_setBootProperty+0x4a>
movl   $0xa0,-0x4(%rbp)
jmp    118f <hwLcd_setBootProperty+0x6f>
cmpl   $0x118,-0x4(%rbp)
jge    1183 <hwLcd_setBootProperty+0x63>
movl   $0xf0,-0x4(%rbp)
jmp    118a <hwLcd_setBootProperty+0x6a>
movl   $0x140,-0x4(%rbp)
jmp    118f <hwLcd_setBootProperty+0x6f>
jmp    1194 <hwLcd_setBootProperty+0x74>
jmp    1199 <hwLcd_setBootProperty+0x79>
lea    -0xc(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0x8,%esi
lea    0xe54(%rip),%rdx
call   1030 <snprintf@plt>
lea    -0xc(%rbp),%rsi
lea    0xe47(%rip),%rdi
call   1040 <boot_property_add@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hwLcd_setBootProperty>:
mov    $0xd5,%ecx
cmp    $0xd5,%edi
je     115a <hwLcd_setBootProperty+0x3a>
mov    $0x78,%ecx
cmp    $0x8c,%edi
jl     115a <hwLcd_setBootProperty+0x3a>
mov    $0xa0,%ecx
cmp    $0xc8,%edi
jb     115a <hwLcd_setBootProperty+0x3a>
cmp    $0x118,%edi
mov    $0xf0,%eax
mov    $0x140,%ecx
cmovb  %eax,%ecx
push   %rbx
sub    $0x10,%rsp
lea    0xe9a(%rip),%rdx
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1030 <snprintf@plt>
lea    0xe84(%rip),%rdi
mov    %rbx,%rsi
call   1040 <boot_property_add@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [20 x i8] c"qemu.sf.lcd_density\00"
define void @hwLcd_setBootProperty(i32 %0) {
%2 = alloca i32
%3 = alloca [8 x i8]
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 213
br i1 %5, label %6, label %22
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 140
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 120, i32* %2
br label %21
10: ; preds = %6
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 200
br i1 %12, label %13, label %14
13: ; preds = %10
store i32 160, i32* %2
br label %20
14: ; preds = %10
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 280
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 240, i32* %2
br label %19
18: ; preds = %14
store i32 320, i32* %2
br label %19
19: ; preds = %18, %17
br label %20
20: ; preds = %19, %13
br label %21
21: ; preds = %20, %9
br label %22
22: ; preds = %21, %1
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%24 = load i32, i32* %2
%25 = call i32 @snprintf(i8* %23, i32 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%27 = call i32 @boot_property_add(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %26)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [20 x i8] c"qemu.sf.lcd_density\00"
define void @hwLcd_setBootProperty(i32 %0) {
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32 %0, 213
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = icmp slt i32 %0, 140
br i1 %6, label %12, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 200
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 280
%11 = select i1 %10, i32 240, i32 320
br label %12
12: ; preds = %9, %7, %5, %1
%13 = phi i32 [ 213, %1 ], [ 120, %5 ], [ 160, %7 ], [ %11, %9 ]
%14 = call i32 @snprintf(i8* %3, i32 8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @boot_property_add(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %3)
ret void
}