void setplane(unsigned char plane, int i, int state) {
  if (plane == "x") {
    if (state > 0) {
      setplane_x(i);
    } else {
      clrplane_x(i);
    }
  }
  if (plane == "y") {
    if (state > 0) {
      setplane_y(i);
    } else {
      clrplane_y(i);
    }
  }
  if (plane == "z") {
    if (state > 0) {
      setplane_z(i);
    } else {
      clrplane_z(i);
    }
  }
}


x86 assembly (clang, -O0):
<setplane>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movzbl -0x1(%rbp),%eax
lea    0xe81(%rip),%rcx
cmp    %rcx,%rax
jne    11b0 <setplane+0x50>
cmpl   $0x0,-0xc(%rbp)
jle    11a1 <setplane+0x41>
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1060 <setplane_x@plt>
jmp    11ab <setplane+0x4b>
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1070 <clrplane_x@plt>
jmp    11b0 <setplane+0x50>
movzbl -0x1(%rbp),%eax
lea    0xe47(%rip),%rcx
cmp    %rcx,%rax
jne    11ec <setplane+0x8c>
cmpl   $0x0,-0xc(%rbp)
jle    11dd <setplane+0x7d>
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1030 <setplane_y@plt>
jmp    11e7 <setplane+0x87>
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1040 <clrplane_y@plt>
jmp    11ec <setplane+0x8c>
movzbl -0x1(%rbp),%eax
lea    0xe0d(%rip),%rcx
cmp    %rcx,%rax
jne    1228 <setplane+0xc8>
cmpl   $0x0,-0xc(%rbp)
jle    1219 <setplane+0xb9>
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1050 <setplane_z@plt>
jmp    1223 <setplane+0xc3>
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1080 <clrplane_z@plt>
jmp    1228 <setplane+0xc8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setplane>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %edi,%ebx
lea    0xe8e(%rip),%rax
cmp    %rax,%rbx
jne    118c <setplane+0x2c>
mov    %r14d,%edi
xor    %eax,%eax
test   %ebp,%ebp
jle    1187 <setplane+0x27>
call   1060 <setplane_x@plt>
jmp    118c <setplane+0x2c>
call   1070 <clrplane_x@plt>
lea    0xe6f(%rip),%rax
cmp    %rax,%rbx
jne    11ad <setplane+0x4d>
mov    %r14d,%edi
xor    %eax,%eax
test   %ebp,%ebp
jle    11a8 <setplane+0x48>
call   1030 <setplane_y@plt>
jmp    11ad <setplane+0x4d>
call   1040 <clrplane_y@plt>
lea    0xe50(%rip),%rax
cmp    %rax,%rbx
je     11be <setplane+0x5e>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %r14d,%edi
xor    %eax,%eax
test   %ebp,%ebp
jle    11d0 <setplane+0x70>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <setplane_z@plt>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <clrplane_z@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"x\00"
@.str.1 = [2 x i8] c"y\00"
@.str.2 = [2 x i8] c"z\00"
define void @setplane(i8 zeroext %0, i32 %1, i32 %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i8, i8* %4
%8 = zext i8 %7 to i64
%9 = inttoptr i64 %8 to i8*
%10 = icmp eq i8* %9, getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
br i1 %10, label %11, label %21
11: ; preds = %3
%12 = load i32, i32* %6
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %5
%16 = call i32 (i32, ...) bitcast (i32 (...)* @setplane_x to i32 (i32, ...)*)(i32 %15)
br label %20
17: ; preds = %11
%18 = load i32, i32* %5
%19 = call i32 (i32, ...) bitcast (i32 (...)* @clrplane_x to i32 (i32, ...)*)(i32 %18)
br label %20
20: ; preds = %17, %14
br label %21
21: ; preds = %20, %3
%22 = load i8, i8* %4
%23 = zext i8 %22 to i64
%24 = inttoptr i64 %23 to i8*
%25 = icmp eq i8* %24, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
br i1 %25, label %26, label %36
26: ; preds = %21
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %5
%31 = call i32 (i32, ...) bitcast (i32 (...)* @setplane_y to i32 (i32, ...)*)(i32 %30)
br label %35
32: ; preds = %26
%33 = load i32, i32* %5
%34 = call i32 (i32, ...) bitcast (i32 (...)* @clrplane_y to i32 (i32, ...)*)(i32 %33)
br label %35
35: ; preds = %32, %29
br label %36
36: ; preds = %35, %21
%37 = load i8, i8* %4
%38 = zext i8 %37 to i64
%39 = inttoptr i64 %38 to i8*
%40 = icmp eq i8* %39, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
br i1 %40, label %41, label %51
41: ; preds = %36
%42 = load i32, i32* %6
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32, i32* %5
%46 = call i32 (i32, ...) bitcast (i32 (...)* @setplane_z to i32 (i32, ...)*)(i32 %45)
br label %50
47: ; preds = %41
%48 = load i32, i32* %5
%49 = call i32 (i32, ...) bitcast (i32 (...)* @clrplane_z to i32 (i32, ...)*)(i32 %48)
br label %50
50: ; preds = %47, %44
br label %51
51: ; preds = %50, %36
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"x\00"
@.str.1 = [2 x i8] c"y\00"
@.str.2 = [2 x i8] c"z\00"
define void @setplane(i8 zeroext %0, i32 %1, i32 %2) {
%4 = zext i8 %0 to i64
%5 = inttoptr i64 %4 to i8*
%6 = icmp eq i8* %5, getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
br i1 %6, label %7, label %13
7: ; preds = %3
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @setplane_x to i32 (i32, ...)*)(i32 %1)
br label %13
11: ; preds = %7
%12 = tail call i32 (i32, ...) bitcast (i32 (...)* @clrplane_x to i32 (i32, ...)*)(i32 %1)
br label %13
13: ; preds = %9, %11, %3
%14 = icmp eq i8* %5, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
br i1 %14, label %15, label %21
15: ; preds = %13
%16 = icmp sgt i32 %2, 0
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 (i32, ...) bitcast (i32 (...)* @setplane_y to i32 (i32, ...)*)(i32 %1)
br label %21
19: ; preds = %15
%20 = tail call i32 (i32, ...) bitcast (i32 (...)* @clrplane_y to i32 (i32, ...)*)(i32 %1)
br label %21
21: ; preds = %17, %19, %13
%22 = icmp eq i8* %5, getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
br i1 %22, label %23, label %29
23: ; preds = %21
%24 = icmp sgt i32 %2, 0
br i1 %24, label %25, label %27
25: ; preds = %23
%26 = tail call i32 (i32, ...) bitcast (i32 (...)* @setplane_z to i32 (i32, ...)*)(i32 %1)
br label %29
27: ; preds = %23
%28 = tail call i32 (i32, ...) bitcast (i32 (...)* @clrplane_z to i32 (i32, ...)*)(i32 %1)
br label %29
29: ; preds = %25, %27, %21
ret void
}