#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*/ glViewport(int /*<<< orphan*/, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ gluPerspective(double, float, double, double);
void on_reshape_msg(int width, int height) {
  if (height) {
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0, (float)width / (float)height, 0.1, 100.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
  }
}


x86 assembly (clang, -O0):
<on_reshape_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11bc <on_reshape_msg+0x7c>
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
mov    %esi,%edi
call   1060 <glViewport@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1030 <glMatrixMode@plt>
mov    $0x0,%al
call   1050 <glLoadIdentity@plt>
cvtsi2ssl -0x4(%rbp),%xmm1
cvtsi2ssl -0x8(%rbp),%xmm0
divss  %xmm0,%xmm1
movsd  0xe6e(%rip),%xmm0
movsd  0xe6e(%rip),%xmm2
movsd  0xe6e(%rip),%xmm3
call   1040 <gluPerspective@plt>
mov    0x2e3a(%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):
<on_reshape_msg>:
test   %esi,%esi
je     11b1 <on_reshape_msg+0x71>
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    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1030 <glMatrixMode@plt>
xor    %eax,%eax
call   1050 <glLoadIdentity@plt>
cvtsi2ss %ebp,%xmm1
cvtsi2ss %ebx,%xmm0
divss  %xmm0,%xmm1
movsd  0xe7f(%rip),%xmm0
movsd  0xe7f(%rip),%xmm2
movsd  0xe7f(%rip),%xmm3
call   1040 <gluPerspective@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1030 <glMatrixMode@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <glLoadIdentity@plt>
ret

LLVM IR (-O0):
@GL_PROJECTION = global i32 0
@GL_MODELVIEW = global i32 0
define void @on_reshape_msg(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %2
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @glViewport(i32 0, i32 0, i32 %8, i32 %9)
%11 = load i32, i32* @GL_PROJECTION
%12 = call i32 @glMatrixMode(i32 %11)
%13 = call i32 (...) @glLoadIdentity()
%14 = load i32, i32* %3
%15 = sitofp i32 %14 to float
%16 = load i32, i32* %4
%17 = sitofp i32 %16 to float
%18 = fdiv float %15, %17
%19 = call i32 @gluPerspective(double 4.500000e+01, float %18, double 1.000000e-01, double 1.000000e+02)
%20 = load i32, i32* @GL_MODELVIEW
%21 = call i32 @glMatrixMode(i32 %20)
%22 = call i32 (...) @glLoadIdentity()
br label %23
23: ; preds = %7, %2
ret void
}

LLVM IR (-O2):
@GL_PROJECTION = global i32 0
@GL_MODELVIEW = global i32 0
define void @on_reshape_msg(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %16, label %4
4: ; preds = %2
%5 = tail call i32 @glViewport(i32 0, i32 0, i32 %0, i32 %1)
%6 = load i32, i32* @GL_PROJECTION
%7 = tail call i32 @glMatrixMode(i32 %6)
%8 = tail call i32 (...) @glLoadIdentity()
%9 = sitofp i32 %0 to float
%10 = sitofp i32 %1 to float
%11 = fdiv float %9, %10
%12 = tail call i32 @gluPerspective(double 4.500000e+01, float %11, double 1.000000e-01, double 1.000000e+02)
%13 = load i32, i32* @GL_MODELVIEW
%14 = tail call i32 @glMatrixMode(i32 %13)
%15 = tail call i32 (...) @glLoadIdentity()
br label %16
16: ; preds = %4, %2
ret void
}