#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*/ glViewport(int, int, int, int);
int /*<<< orphan*/ glutPostRedisplay();
int /*<<< orphan*/ glutReshapeWindow(int, int);
void reshape(int width, int height) {
  int size;
  size = (width < height ? width : height);
  glViewport((width - size) / 2, (height - size) / 2, size, size);
  glutReshapeWindow(size, size);
  glutPostRedisplay();
}


x86 assembly (clang, -O0):
<reshape>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1155 <reshape+0x25>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    115b <reshape+0x2b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1050 <glViewport@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <glutReshapeWindow@plt>
mov    $0x0,%al
call   1040 <glutPostRedisplay@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reshape>:
push   %rbx
cmp    %esi,%edi
mov    %esi,%ebx
cmovl  %edi,%ebx
sub    %ebx,%edi
mov    %edi,%eax
shr    $0x1f,%eax
add    %eax,%edi
sar    %edi
sub    %ebx,%esi
mov    %esi,%eax
shr    $0x1f,%eax
add    %eax,%esi
sar    %esi
mov    %ebx,%edx
mov    %ebx,%ecx
call   1050 <glViewport@plt>
mov    %ebx,%edi
mov    %ebx,%esi
call   1030 <glutReshapeWindow@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <glutPostRedisplay@plt>

LLVM IR (-O0):
define void @reshape(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = load i32, i32* %4
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i32, i32* %3
br label %13
11: ; preds = %2
%12 = load i32, i32* %4
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ %10, %9 ], [ %12, %11 ]
store i32 %14, i32* %5
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = sub nsw i32 %15, %16
%18 = sdiv i32 %17, 2
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = sub nsw i32 %19, %20
%22 = sdiv i32 %21, 2
%23 = load i32, i32* %5
%24 = load i32, i32* %5
%25 = call i32 @glViewport(i32 %18, i32 %22, i32 %23, i32 %24)
%26 = load i32, i32* %5
%27 = load i32, i32* %5
%28 = call i32 @glutReshapeWindow(i32 %26, i32 %27)
%29 = call i32 (...) @glutPostRedisplay()
ret void
}

LLVM IR (-O2):
define void @reshape(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, %1
%4 = select i1 %3, i32 %0, i32 %1
%5 = sub nsw i32 %0, %4
%6 = sdiv i32 %5, 2
%7 = sub nsw i32 %1, %4
%8 = sdiv i32 %7, 2
%9 = tail call i32 @glViewport(i32 %6, i32 %8, i32 %4, i32 %4)
%10 = tail call i32 @glutReshapeWindow(i32 %4, i32 %4)
%11 = tail call i32 (...) @glutPostRedisplay()
ret void
}