#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 get_resize_dimensions(size_t img_width, size_t img_height, size_t max_width,
                          size_t max_height, size_t *restrict new_width,
                          size_t *restrict new_height) {
  *new_width = max_height * img_width / img_height;
  (*new_height = max_height);
  if (*new_width <= max_width)
    return 1;
  *new_height = max_width * img_width / img_height;
  *new_width = max_width;
  return 0;
}


x86 assembly (clang, -O0):
<get_resize_dimensions>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x28(%rbp),%rax
imul   -0x10(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
cmp    -0x20(%rbp),%rax
ja     115f <get_resize_dimensions+0x5f>
movl   $0x1,-0x4(%rbp)
jmp    118c <get_resize_dimensions+0x8c>
mov    -0x20(%rbp),%rax
imul   -0x10(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_resize_dimensions>:
mov    %rdx,%r10
mov    %rcx,%rax
imul   %rdi,%rax
mov    %rax,%rdx
or     %rsi,%rdx
shr    $0x20,%rdx
je     111d <get_resize_dimensions+0x1d>
xor    %edx,%edx
div    %rsi
jmp    1121 <get_resize_dimensions+0x21>
xor    %edx,%edx
div    %esi
mov    %rax,(%r8)
mov    %rcx,(%r9)
mov    $0x1,%ecx
cmp    %r10,%rax
jbe    1159 <get_resize_dimensions+0x59>
imul   %r10,%rdi
mov    %rdi,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     114b <get_resize_dimensions+0x4b>
mov    %rdi,%rax
xor    %edx,%edx
div    %rsi
jmp    1151 <get_resize_dimensions+0x51>
mov    %edi,%eax
xor    %edx,%edx
div    %esi
mov    %rax,(%r9)
mov    %r10,(%r8)
xor    %ecx,%ecx
mov    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @get_resize_dimensions(i64 %0, i64 %1, i64 %2, i64 %3, i64* noalias %4, i64* noalias %5) {
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64*
%13 = alloca i64*
store i64 %0, i64* %8
store i64 %1, i64* %9
store i64 %2, i64* %10
store i64 %3, i64* %11
store i64* %4, i64** %12
store i64* %5, i64** %13
%14 = load i64, i64* %11
%15 = load i64, i64* %8
%16 = mul i64 %14, %15
%17 = load i64, i64* %9
%18 = udiv i64 %16, %17
%19 = load i64*, i64** %12
store i64 %18, i64* %19
%20 = load i64, i64* %11
%21 = load i64*, i64** %13
store i64 %20, i64* %21
%22 = load i64*, i64** %12
%23 = load i64, i64* %22
%24 = load i64, i64* %10
%25 = icmp ule i64 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %6
store i32 1, i32* %7
br label %36
27: ; preds = %6
%28 = load i64, i64* %10
%29 = load i64, i64* %8
%30 = mul i64 %28, %29
%31 = load i64, i64* %9
%32 = udiv i64 %30, %31
%33 = load i64*, i64** %13
store i64 %32, i64* %33
%34 = load i64, i64* %10
%35 = load i64*, i64** %12
store i64 %34, i64* %35
store i32 0, i32* %7
br label %36
36: ; preds = %27, %26
%37 = load i32, i32* %7
ret i32 %37
}

LLVM IR (-O2):
define i32 @get_resize_dimensions(i64 %0, i64 %1, i64 %2, i64 %3, i64* noalias nocapture writeonly %4, i64* noalias nocapture writeonly %5) {
%7 = mul i64 %3, %0
%8 = udiv i64 %7, %1
store i64 %8, i64* %4
store i64 %3, i64* %5
%9 = icmp ugt i64 %8, %2
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = mul i64 %2, %0
%12 = udiv i64 %11, %1
store i64 %12, i64* %5
store i64 %2, i64* %4
br label %13
13: ; preds = %6, %10
%14 = phi i32 [ 0, %10 ], [ 1, %6 ]
ret i32 %14
}