int corner_vertex(int index, int width, int height, double *x, double *y) {
  switch (index) {
  case 1:
    *x = 0.0;
    *y = height + 1;
    break;
  case 2:
    *x = 0.0;
    *y = 0.0;
    break;
  case 3:
    *x = width + 1;
    *y = 0.0;
    break;
  case 4:
    *x = width + 1;
    *y = height + 1;
  default:
    break;
  }
  index = index + 1;
  if (index > 4)
    index = 1;
  return (index);
}


x86 assembly (clang, -O0):
<corner_vertex>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     11c1 <corner_vertex+0xc1>
mov    -0x28(%rbp),%rax
lea    0xecb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11c6 <corner_vertex+0xc6>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    11c6 <corner_vertex+0xc6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    11c6 <corner_vertex+0xc6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11c6 <corner_vertex+0xc6>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jle    11e0 <corner_vertex+0xe0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<corner_vertex>:
lea    -0x1(%rdi),%eax
cmp    $0x3,%eax
ja     1159 <corner_vertex+0x59>
lea    0xef1(%rip),%r9
movslq (%r9,%rax,4),%rax
add    %r9,%rax
jmp    *%rax
movq   $0x0,(%rcx)
jmp    114a <corner_vertex+0x4a>
movq   $0x0,(%rcx)
xorpd  %xmm0,%xmm0
jmp    1154 <corner_vertex+0x54>
add    $0x1,%esi
cvtsi2sd %esi,%xmm0
movsd  %xmm0,(%rcx)
xorpd  %xmm0,%xmm0
jmp    1154 <corner_vertex+0x54>
add    $0x1,%esi
cvtsi2sd %esi,%xmm0
movsd  %xmm0,(%rcx)
add    $0x1,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movsd  %xmm0,(%r8)
lea    0x1(%rdi),%ecx
cmp    $0x4,%edi
mov    $0x1,%eax
cmovl  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @corner_vertex(i32 %0, i32 %1, i32 %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double* %3, double** %9
store double* %4, double** %10
%11 = load i32, i32* %6
switch i32 %11, label %36 [
i32 1, label %12
i32 2, label %18
i32 3, label %21
i32 4, label %27
]
12: ; preds = %5
%13 = load double*, double** %9
store double 0.000000e+00, double* %13
%14 = load i32, i32* %8
%15 = add nsw i32 %14, 1
%16 = sitofp i32 %15 to double
%17 = load double*, double** %10
store double %16, double* %17
br label %37
18: ; preds = %5
%19 = load double*, double** %9
store double 0.000000e+00, double* %19
%20 = load double*, double** %10
store double 0.000000e+00, double* %20
br label %37
21: ; preds = %5
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
%24 = sitofp i32 %23 to double
%25 = load double*, double** %9
store double %24, double* %25
%26 = load double*, double** %10
store double 0.000000e+00, double* %26
br label %37
27: ; preds = %5
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
%30 = sitofp i32 %29 to double
%31 = load double*, double** %9
store double %30, double* %31
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
%34 = sitofp i32 %33 to double
%35 = load double*, double** %10
store double %34, double* %35
br label %36
36: ; preds = %5, %27
br label %37
37: ; preds = %36, %21, %18, %12
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = icmp sgt i32 %40, 4
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 1, i32* %6
br label %43
43: ; preds = %42, %37
%44 = load i32, i32* %6
ret i32 %44
}

LLVM IR (-O2):
define i32 @corner_vertex(i32 %0, i32 %1, i32 %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
switch i32 %0, label %20 [
i32 1, label %6
i32 2, label %9
i32 3, label %10
i32 4, label %13
]
6: ; preds = %5
store double 0.000000e+00, double* %3
%7 = add nsw i32 %2, 1
%8 = sitofp i32 %7 to double
br label %18
9: ; preds = %5
store double 0.000000e+00, double* %3
br label %18
10: ; preds = %5
%11 = add nsw i32 %1, 1
%12 = sitofp i32 %11 to double
store double %12, double* %3
br label %18
13: ; preds = %5
%14 = add nsw i32 %1, 1
%15 = sitofp i32 %14 to double
store double %15, double* %3
%16 = add nsw i32 %2, 1
%17 = sitofp i32 %16 to double
br label %18
18: ; preds = %6, %9, %10, %13
%19 = phi double [ %17, %13 ], [ 0.000000e+00, %10 ], [ 0.000000e+00, %9 ], [ %8, %6 ]
store double %19, double* %4
br label %20
20: ; preds = %18, %5
%21 = add nsw i32 %0, 1
%22 = icmp sgt i32 %0, 3
%23 = select i1 %22, i32 1, i32 %21
ret i32 %23
}