#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*/ GL_MODELVIEW;
int /*<<< orphan*/ GL_PROJECTION;
int /*<<< orphan*/ glLoadIdentity();
int /*<<< orphan*/ glMatrixMode(int /*<<< orphan*/);
int /*<<< orphan*/ glOrtho(float, float, float, float, float, float);
int /*<<< orphan*/ glViewport(int /*<<< orphan*/, int /*<<< orphan*/, int, int);
void skaliraj(int w, int h) {
  float a = 2.0, b;
  glViewport(0, 0, w, h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  if (w > h) {
    b = a * (float)w / (float)h;
    glOrtho(-b + 0.5, b - 0.5, -a + 1.0, a, -a, a);
  } else {
    b = a * (float)h / (float)w;
    glOrtho(-a + 0.5, a - 0.5, -b + 1.0, b, -a, a);
  }
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
}


x86 assembly (clang, -O0):
<skaliraj>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movss  0xeaa(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
mov    %esi,%edi
call   1060 <glViewport@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1030 <glMatrixMode@plt>
mov    $0x0,%al
call   1050 <glLoadIdentity@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1232 <skaliraj+0xf2>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe4b(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe32(%rip),%xmm2
subsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
cvtss2sd %xmm2,%xmm2
movsd  0xe04(%rip),%xmm3
addsd  %xmm3,%xmm2
cvtsd2ss %xmm2,%xmm2
movss  -0xc(%rbp),%xmm3
movss  -0xc(%rbp),%xmm4
movd   %xmm4,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm4
movss  -0xc(%rbp),%xmm5
call   1040 <glOrtho@plt>
jmp    12d4 <skaliraj+0x194>
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xda4(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xd8b(%rip),%xmm2
subsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
movss  -0x10(%rbp),%xmm2
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
cvtss2sd %xmm2,%xmm2
movsd  0xd5d(%rip),%xmm3
addsd  %xmm3,%xmm2
cvtsd2ss %xmm2,%xmm2
movss  -0x10(%rbp),%xmm3
movss  -0xc(%rbp),%xmm4
movd   %xmm4,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm4
movss  -0xc(%rbp),%xmm5
call   1040 <glOrtho@plt>
mov    0x2d0d(%rip),%rax
mov    (%rax),%edi
call   1030 <glMatrixMode@plt>
mov    $0x0,%al
call   1050 <glLoadIdentity@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skaliraj>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
xor    %esi,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1060 <glViewport@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1030 <glMatrixMode@plt>
xor    %eax,%eax
call   1050 <glLoadIdentity@plt>
cmp    %ebx,%ebp
jle    11ae <skaliraj+0x6e>
cvtsi2ss %ebp,%xmm1
addss  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm0
divss  %xmm0,%xmm1
movss  0xe8f(%rip),%xmm0
subss  %xmm1,%xmm0
addss  0xe87(%rip),%xmm1
movss  0xe83(%rip),%xmm2
movss  0xe6b(%rip),%xmm4
movss  0xe67(%rip),%xmm3
movaps %xmm3,%xmm5
jmp    11ea <skaliraj+0xaa>
cvtsi2ss %ebx,%xmm3
cvtsi2ss %ebp,%xmm0
addss  %xmm3,%xmm3
divss  %xmm0,%xmm3
movss  0xe3a(%rip),%xmm2
subss  %xmm3,%xmm2
movss  0xe32(%rip),%xmm0
movss  0xe2e(%rip),%xmm1
movss  0xe2a(%rip),%xmm4
movss  0xe26(%rip),%xmm5
call   1040 <glOrtho@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1030 <glMatrixMode@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <glLoadIdentity@plt>

LLVM IR (-O0):
@GL_PROJECTION = global i32 0
@GL_MODELVIEW = global i32 0
define void @skaliraj(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
store i32 %0, i32* %3
store i32 %1, i32* %4
store float 2.000000e+00, float* %5
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = call i32 @glViewport(i32 0, i32 0, i32 %7, i32 %8)
%10 = load i32, i32* @GL_PROJECTION
%11 = call i32 @glMatrixMode(i32 %10)
%12 = call i32 (...) @glLoadIdentity()
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %43
16: ; preds = %2
%17 = load float, float* %5
%18 = load i32, i32* %3
%19 = sitofp i32 %18 to float
%20 = fmul float %17, %19
%21 = load i32, i32* %4
%22 = sitofp i32 %21 to float
%23 = fdiv float %20, %22
store float %23, float* %6
%24 = load float, float* %6
%25 = fneg float %24
%26 = fpext float %25 to double
%27 = fadd double %26, 5.000000e-01
%28 = fptrunc double %27 to float
%29 = load float, float* %6
%30 = fpext float %29 to double
%31 = fsub double %30, 5.000000e-01
%32 = fptrunc double %31 to float
%33 = load float, float* %5
%34 = fneg float %33
%35 = fpext float %34 to double
%36 = fadd double %35, 1.000000e+00
%37 = fptrunc double %36 to float
%38 = load float, float* %5
%39 = load float, float* %5
%40 = fneg float %39
%41 = load float, float* %5
%42 = call i32 @glOrtho(float %28, float %32, float %37, float %38, float %40, float %41)
br label %70
43: ; preds = %2
%44 = load float, float* %5
%45 = load i32, i32* %4
%46 = sitofp i32 %45 to float
%47 = fmul float %44, %46
%48 = load i32, i32* %3
%49 = sitofp i32 %48 to float
%50 = fdiv float %47, %49
store float %50, float* %6
%51 = load float, float* %5
%52 = fneg float %51
%53 = fpext float %52 to double
%54 = fadd double %53, 5.000000e-01
%55 = fptrunc double %54 to float
%56 = load float, float* %5
%57 = fpext float %56 to double
%58 = fsub double %57, 5.000000e-01
%59 = fptrunc double %58 to float
%60 = load float, float* %6
%61 = fneg float %60
%62 = fpext float %61 to double
%63 = fadd double %62, 1.000000e+00
%64 = fptrunc double %63 to float
%65 = load float, float* %6
%66 = load float, float* %5
%67 = fneg float %66
%68 = load float, float* %5
%69 = call i32 @glOrtho(float %55, float %59, float %64, float %65, float %67, float %68)
br label %70
70: ; preds = %43, %16
%71 = load i32, i32* @GL_MODELVIEW
%72 = call i32 @glMatrixMode(i32 %71)
%73 = call i32 (...) @glLoadIdentity()
ret void
}

LLVM IR (-O2):
@GL_PROJECTION = global i32 0
@GL_MODELVIEW = global i32 0
define void @skaliraj(i32 %0, i32 %1) {
%3 = tail call i32 @glViewport(i32 0, i32 0, i32 %0, i32 %1)
%4 = load i32, i32* @GL_PROJECTION
%5 = tail call i32 @glMatrixMode(i32 %4)
%6 = tail call i32 (...) @glLoadIdentity()
%7 = icmp sgt i32 %0, %1
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = sitofp i32 %0 to float
%10 = fmul float %9, 2.000000e+00
%11 = sitofp i32 %1 to float
%12 = fdiv float %10, %11
%13 = fsub float 5.000000e-01, %12
%14 = fadd float %12, -5.000000e-01
%15 = tail call i32 @glOrtho(float %13, float %14, float -1.000000e+00, float 2.000000e+00, float -2.000000e+00, float 2.000000e+00)
br label %23
16: ; preds = %2
%17 = sitofp i32 %1 to float
%18 = fmul float %17, 2.000000e+00
%19 = sitofp i32 %0 to float
%20 = fdiv float %18, %19
%21 = fsub float 1.000000e+00, %20
%22 = tail call i32 @glOrtho(float -1.500000e+00, float 1.500000e+00, float %21, float %20, float -2.000000e+00, float 2.000000e+00)
br label %23
23: ; preds = %16, %8
%24 = load i32, i32* @GL_MODELVIEW
%25 = tail call i32 @glMatrixMode(i32 %24)
%26 = tail call i32 (...) @glLoadIdentity()
ret void
}