int switch_relay(relay_no, status) {
  if (relay_no == 1) {
    if (status == 1) {
      outb(0xC0, 0x378);
      return 1;
    } else if (status == 0) {
      outb(0, 0x378);
      return 1;
    }
  }
  if (relay_no == 2) {
    if (status == 1) {
      outb(0x84, 0x378);
      return 1;
    } else if (status == 0) {
      outb(0, 0x378);
      return 1;
    }
  }
}


x86 assembly (clang, -O0):
<switch_relay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    117d <switch_relay+0x6d>
cmpl   $0x1,-0xc(%rbp)
jne    114f <switch_relay+0x3f>
mov    $0xc0,%edi
mov    $0x378,%esi
mov    $0x0,%al
call   1030 <outb@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dc <switch_relay+0xcc>
cmpl   $0x0,-0xc(%rbp)
jne    1173 <switch_relay+0x63>
xor    %edi,%edi
mov    $0x378,%esi
mov    $0x0,%al
call   1030 <outb@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dc <switch_relay+0xcc>
jmp    1178 <switch_relay+0x68>
jmp    117d <switch_relay+0x6d>
cmpl   $0x2,-0x8(%rbp)
jne    11dc <switch_relay+0xcc>
cmpl   $0x1,-0xc(%rbp)
jne    11ae <switch_relay+0x9e>
mov    $0x84,%edi
mov    $0x378,%esi
mov    $0x0,%al
call   1030 <outb@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dc <switch_relay+0xcc>
cmpl   $0x0,-0xc(%rbp)
jne    11d2 <switch_relay+0xc2>
xor    %edi,%edi
mov    $0x378,%esi
mov    $0x0,%al
call   1030 <outb@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dc <switch_relay+0xcc>
jmp    11d7 <switch_relay+0xc7>
jmp    11dc <switch_relay+0xcc>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<switch_relay>:
cmp    $0x2,%edi
je     1126 <switch_relay+0x16>
cmp    $0x1,%edi
jne    1149 <switch_relay+0x39>
cmp    $0x1,%esi
jne    112b <switch_relay+0x1b>
mov    $0xc0,%edi
jmp    1138 <switch_relay+0x28>
cmp    $0x1,%esi
je     1133 <switch_relay+0x23>
test   %esi,%esi
jne    1149 <switch_relay+0x39>
xor    %edi,%edi
jmp    1138 <switch_relay+0x28>
mov    $0x84,%edi
push   %rax
mov    $0x378,%esi
xor    %eax,%eax
call   1030 <outb@plt>
add    $0x8,%rsp
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @switch_relay(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %20
8: ; preds = %2
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 192, i32 888)
store i32 1, i32* %3
br label %35
13: ; preds = %8
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 0, i32 888)
store i32 1, i32* %3
br label %35
18: ; preds = %13
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19, %2
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 2
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load i32, i32* %5
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 132, i32 888)
store i32 1, i32* %3
br label %35
28: ; preds = %23
%29 = load i32, i32* %5
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 0, i32 888)
store i32 1, i32* %3
br label %35
33: ; preds = %28
br label %34
34: ; preds = %33
br label %35
35: ; preds = %11, %16, %26, %31, %34, %20
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
define i32 @switch_relay(i32 %0, i32 %1) {
switch i32 %0, label %10 [
i32 1, label %3
i32 2, label %5
]
3: ; preds = %2
switch i32 %1, label %10 [
i32 1, label %7
i32 0, label %4
]
4: ; preds = %3
br label %7
5: ; preds = %2
switch i32 %1, label %10 [
i32 1, label %7
i32 0, label %6
]
6: ; preds = %5
br label %7
7: ; preds = %5, %3, %6, %4
%8 = phi i32 [ 0, %4 ], [ 0, %6 ], [ 192, %3 ], [ 132, %5 ]
%9 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @outb to i32 (i32, i32, ...)*)(i32 %8, i32 888)
br label %10
10: ; preds = %7, %3, %5, %2
ret i32 1
}