#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 */
void cl_set_dim(size_t *global, size_t *local, int M, int N) {
  int H = M % 16 == 0 ? M : M + M % 16;
  int W = N % 16 == 0 ? N : N + N % 16;
  global[0] = H;
  local[0] = 16;
  global[1] = W;
  local[1] = 16;
}


x86 assembly (clang, -O0):
<cl_set_dim>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1131 <cl_set_dim+0x31>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    114a <cl_set_dim+0x4a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    116f <cl_set_dim+0x6f>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1188 <cl_set_dim+0x88>
mov    -0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x20(%rbp)
movslq -0x1c(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movq   $0x10,(%rax)
movslq -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
movq   $0x10,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cl_set_dim>:
lea    0xf(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xfffffff0,%eax
mov    %edx,%r8d
sub    %eax,%r8d
add    %edx,%r8d
lea    0xf(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
and    $0xfffffff0,%eax
mov    %ecx,%edx
sub    %eax,%edx
add    %ecx,%edx
movslq %r8d,%rax
mov    %rax,(%rdi)
movq   $0x10,(%rsi)
movslq %edx,%rax
mov    %rax,0x8(%rdi)
movq   $0x10,0x8(%rsi)
ret

LLVM IR (-O0):
define void @cl_set_dim(i64* %0, i64* %1, i32 %2, i32 %3) {
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i64* %0, i64** %5
store i64* %1, i64** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* %7
%12 = srem i32 %11, 16
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %4
%15 = load i32, i32* %7
br label %21
16: ; preds = %4
%17 = load i32, i32* %7
%18 = load i32, i32* %7
%19 = srem i32 %18, 16
%20 = add nsw i32 %17, %19
br label %21
21: ; preds = %16, %14
%22 = phi i32 [ %15, %14 ], [ %20, %16 ]
store i32 %22, i32* %9
%23 = load i32, i32* %8
%24 = srem i32 %23, 16
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = load i32, i32* %8
br label %33
28: ; preds = %21
%29 = load i32, i32* %8
%30 = load i32, i32* %8
%31 = srem i32 %30, 16
%32 = add nsw i32 %29, %31
br label %33
33: ; preds = %28, %26
%34 = phi i32 [ %27, %26 ], [ %32, %28 ]
store i32 %34, i32* %10
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = load i64*, i64** %5
%38 = getelementptr inbounds i64, i64* %37, i64 0
store i64 %36, i64* %38
%39 = load i64*, i64** %6
%40 = getelementptr inbounds i64, i64* %39, i64 0
store i64 16, i64* %40
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = load i64*, i64** %5
%44 = getelementptr inbounds i64, i64* %43, i64 1
store i64 %42, i64* %44
%45 = load i64*, i64** %6
%46 = getelementptr inbounds i64, i64* %45, i64 1
store i64 16, i64* %46
ret void
}

LLVM IR (-O2):
define void @cl_set_dim(i64* nocapture writeonly %0, i64* nocapture writeonly %1, i32 %2, i32 %3) {
%5 = srem i32 %2, 16
%6 = add nsw i32 %5, %2
%7 = srem i32 %3, 16
%8 = add nsw i32 %7, %3
%9 = sext i32 %6 to i64
store i64 %9, i64* %0
store i64 16, i64* %1
%10 = sext i32 %8 to i64
%11 = getelementptr inbounds i64, i64* %0, i64 1
store i64 %10, i64* %11
%12 = getelementptr inbounds i64, i64* %1, i64 1
store i64 16, i64* %12
ret void
}