#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 /*<<< orphan*/ GLsizei;
typedef double GLfloat;

/* 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 /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ gluOrtho2D(double, double, double, double);
void smooth_reshape(int w, int h) {
  glViewport(0, 0, (GLsizei)w, (GLsizei)h);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  if (w <= h) {
    gluOrtho2D(0.0, 30.0, 0.0, 30.0 * (GLfloat)h / (GLfloat)w);
  } else {
    gluOrtho2D(0.0, 30.0 * (GLfloat)h / (GLfloat)w, 0.0, 30.0);
  }
  glMatrixMode(GL_MODELVIEW);
}


x86 assembly (clang, -O0):
<smooth_reshape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
mov    %esi,%edi
call   1060 <glViewport@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
call   1030 <glMatrixMode@plt>
mov    $0x0,%al
call   1040 <glLoadIdentity@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b0 <smooth_reshape+0x70>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe75(%rip),%xmm3
mulsd  %xmm0,%xmm3
cvtsi2sdl -0x4(%rbp),%xmm0
divsd  %xmm0,%xmm3
xorps  %xmm2,%xmm2
movsd  0xe5d(%rip),%xmm1
movaps %xmm2,%xmm0
call   1050 <gluOrtho2D@plt>
jmp    11dd <smooth_reshape+0x9d>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe43(%rip),%xmm1
mulsd  %xmm0,%xmm1
cvtsi2sdl -0x4(%rbp),%xmm0
divsd  %xmm0,%xmm1
xorps  %xmm2,%xmm2
movsd  0xe2b(%rip),%xmm3
movaps %xmm2,%xmm0
call   1050 <gluOrtho2D@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   1030 <glMatrixMode@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smooth_reshape>:
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   1040 <glLoadIdentity@plt>
cvtsi2sd %ebx,%xmm4
mulsd  0xe8b(%rip),%xmm4
cvtsi2sd %ebp,%xmm0
divsd  %xmm0,%xmm4
cmp    %ebx,%ebp
jle    1196 <smooth_reshape+0x56>
movsd  0xe77(%rip),%xmm3
xorpd  %xmm0,%xmm0
xorps  %xmm2,%xmm2
movapd %xmm4,%xmm1
jmp    11a9 <smooth_reshape+0x69>
movsd  0xe62(%rip),%xmm1
xorpd  %xmm0,%xmm0
xorps  %xmm2,%xmm2
movapd %xmm4,%xmm3
call   1050 <gluOrtho2D@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <glMatrixMode@plt>

LLVM IR (-O0):
@GL_PROJECTION = global i32 0
@GL_MODELVIEW = global i32 0
define void @smooth_reshape(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = call i32 @glViewport(i32 0, i32 0, i32 %5, i32 %6)
%8 = load i32, i32* @GL_PROJECTION
%9 = call i32 @glMatrixMode(i32 %8)
%10 = call i32 (...) @glLoadIdentity()
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i32, i32* %4
%16 = sitofp i32 %15 to double
%17 = fmul double 3.000000e+01, %16
%18 = load i32, i32* %3
%19 = sitofp i32 %18 to double
%20 = fdiv double %17, %19
%21 = call i32 @gluOrtho2D(double 0.000000e+00, double 3.000000e+01, double 0.000000e+00, double %20)
br label %30
22: ; preds = %2
%23 = load i32, i32* %4
%24 = sitofp i32 %23 to double
%25 = fmul double 3.000000e+01, %24
%26 = load i32, i32* %3
%27 = sitofp i32 %26 to double
%28 = fdiv double %25, %27
%29 = call i32 @gluOrtho2D(double 0.000000e+00, double %28, double 0.000000e+00, double 3.000000e+01)
br label %30
30: ; preds = %22, %14
%31 = load i32, i32* @GL_MODELVIEW
%32 = call i32 @glMatrixMode(i32 %31)
ret void
}

LLVM IR (-O2):
@GL_PROJECTION = global i32 0
@GL_MODELVIEW = global i32 0
define void @smooth_reshape(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
%8 = sitofp i32 %1 to double
%9 = fmul double %8, 3.000000e+01
%10 = sitofp i32 %0 to double
%11 = fdiv double %9, %10
br i1 %7, label %14, label %12
12: ; preds = %2
%13 = tail call i32 @gluOrtho2D(double 0.000000e+00, double 3.000000e+01, double 0.000000e+00, double %11)
br label %16
14: ; preds = %2
%15 = tail call i32 @gluOrtho2D(double 0.000000e+00, double %11, double 0.000000e+00, double 3.000000e+01)
br label %16
16: ; preds = %14, %12
%17 = load i32, i32* @GL_MODELVIEW
%18 = tail call i32 @glMatrixMode(i32 %17)
ret void
}