#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 __gen_ocl_get_global_offset0();
int __gen_ocl_get_global_offset1();
int __gen_ocl_get_global_offset2();
__attribute__((always_)) unsigned get_global_offset(unsigned int dim) {
  if (dim == 0)
    return __gen_ocl_get_global_offset0();
  else if (dim == 1)
    return __gen_ocl_get_global_offset1();
  else if (dim == 2)
    return __gen_ocl_get_global_offset2();
  else
    return 0;
}


x86 assembly (clang, -O0):
<get_global_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1154 <get_global_offset+0x24>
mov    $0x0,%al
call   1030 <__gen_ocl_get_global_offset0@plt>
mov    %eax,-0x4(%rbp)
jmp    118d <get_global_offset+0x5d>
cmpl   $0x1,-0x8(%rbp)
jne    116d <get_global_offset+0x3d>
mov    $0x0,%al
call   1050 <__gen_ocl_get_global_offset1@plt>
mov    %eax,-0x4(%rbp)
jmp    118d <get_global_offset+0x5d>
cmpl   $0x2,-0x8(%rbp)
jne    1186 <get_global_offset+0x56>
mov    $0x0,%al
call   1040 <__gen_ocl_get_global_offset2@plt>
mov    %eax,-0x4(%rbp)
jmp    118d <get_global_offset+0x5d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_global_offset>:
cmp    $0x2,%edi
je     1145 <get_global_offset+0x15>
cmp    $0x1,%edi
je     114c <get_global_offset+0x1c>
test   %edi,%edi
jne    1153 <get_global_offset+0x23>
xor    %eax,%eax
jmp    1030 <__gen_ocl_get_global_offset0@plt>
xor    %eax,%eax
jmp    1040 <__gen_ocl_get_global_offset2@plt>
xor    %eax,%eax
jmp    1050 <__gen_ocl_get_global_offset1@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @get_global_offset(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 (...) @__gen_ocl_get_global_offset0()
store i32 %7, i32* %2
br label %19
8: ; preds = %1
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 (...) @__gen_ocl_get_global_offset1()
store i32 %12, i32* %2
br label %19
13: ; preds = %8
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (...) @__gen_ocl_get_global_offset2()
store i32 %17, i32* %2
br label %19
18: ; preds = %13
store i32 0, i32* %2
br label %19
19: ; preds = %18, %16, %11, %6
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
define i32 @get_global_offset(i32 %0) {
switch i32 %0, label %8 [
i32 0, label %2
i32 1, label %4
i32 2, label %6
]
2: ; preds = %1
%3 = tail call i32 (...) @__gen_ocl_get_global_offset0()
br label %8
4: ; preds = %1
%5 = tail call i32 (...) @__gen_ocl_get_global_offset1()
br label %8
6: ; preds = %1
%7 = tail call i32 (...) @__gen_ocl_get_global_offset2()
br label %8
8: ; preds = %1, %6, %4, %2
%9 = phi i32 [ %3, %2 ], [ %5, %4 ], [ %7, %6 ], [ 0, %1 ]
ret i32 %9
}