#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*/ os_window_get_fbsize(int *, int *);
int /*<<< orphan*/ os_window_get_size(int *, int *);
float lovrGraphicsGetPixelDensity() {
  int width, height, framebufferWidth, framebufferHeight;
  os_window_get_size(&width, &height);
  os_window_get_fbsize(&framebufferWidth, &framebufferHeight);
  if (width == 0 || framebufferWidth == 0) {
    return 0.f;
  } else {
    return (float)framebufferWidth / (float)width;
  }
}


x86 assembly (clang, -O0):
<lovrGraphicsGetPixelDensity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <os_window_get_size@plt>
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <os_window_get_fbsize@plt>
cmpl   $0x0,-0x8(%rbp)
je     1156 <lovrGraphicsGetPixelDensity+0x36>
cmpl   $0x0,-0x10(%rbp)
jne    1163 <lovrGraphicsGetPixelDensity+0x43>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1176 <lovrGraphicsGetPixelDensity+0x56>
cvtsi2ssl -0x10(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lovrGraphicsGetPixelDensity>:
sub    $0x18,%rsp
lea    0xc(%rsp),%rdi
lea    0x14(%rsp),%rsi
call   1030 <os_window_get_size@plt>
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <os_window_get_fbsize@plt>
mov    0xc(%rsp),%eax
xorps  %xmm0,%xmm0
test   %eax,%eax
je     1164 <lovrGraphicsGetPixelDensity+0x44>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
je     1164 <lovrGraphicsGetPixelDensity+0x44>
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @lovrGraphicsGetPixelDensity() {
%1 = alloca float
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 @os_window_get_size(i32* %2, i32* %3)
%7 = call i32 @os_window_get_fbsize(i32* %4, i32* %5)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10, %0
store float 0.000000e+00, float* %1
br label %20
14: ; preds = %10
%15 = load i32, i32* %4
%16 = sitofp i32 %15 to float
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to float
%19 = fdiv float %16, %18
store float %19, float* %1
br label %20
20: ; preds = %14, %13
%21 = load float, float* %1
ret float %21
}

LLVM IR (-O2):
define float @lovrGraphicsGetPixelDensity() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 @os_window_get_size(i32* %1, i32* %2)
%10 = call i32 @os_window_get_fbsize(i32* %3, i32* %4)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %20, label %16
16: ; preds = %0
%17 = sitofp i32 %13 to float
%18 = sitofp i32 %11 to float
%19 = fdiv float %17, %18
br label %20
20: ; preds = %0, %16
%21 = phi float [ %19, %16 ], [ 0.000000e+00, %0 ]
ret float %21
}