#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write_byte_data(int, int, int);
void set_port(uint8_t address, uint8_t port, uint8_t value, uint8_t a_register,
              uint8_t b_register) {
  if (port == 0) {
    write_byte_data(address, a_register, value);
  } else if (port == 1) {
    write_byte_data(address, b_register, value);
  } else {
    printf("port out of range: 0 or 1");
  }
}


x86 assembly (clang, -O0):
<set_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1155 <set_port+0x35>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <write_byte_data@plt>
jmp    1183 <set_port+0x63>
cmpl   $0x1,-0x8(%rbp)
jne    1172 <set_port+0x52>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <write_byte_data@plt>
jmp    117e <set_port+0x5e>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
jmp    1183 <set_port+0x63>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_port>:
cmp    $0x1,%esi
je     1130 <set_port+0x10>
test   %esi,%esi
jne    1138 <set_port+0x18>
mov    %ecx,%esi
jmp    1040 <write_byte_data@plt>
mov    %r8d,%esi
jmp    1040 <write_byte_data@plt>
lea    0xec1(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"port out of range: 0 or 1\00"
define void @set_port(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %5
%14 = load i32, i32* %6
%15 = load i32, i32* %9
%16 = load i32, i32* %8
%17 = call i32 @write_byte_data(i32 %14, i32 %15, i32 %16)
br label %29
18: ; preds = %5
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %6
%23 = load i32, i32* %10
%24 = load i32, i32* %8
%25 = call i32 @write_byte_data(i32 %22, i32 %23, i32 %24)
br label %28
26: ; preds = %18
%27 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %21
br label %29
29: ; preds = %28, %13
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"port out of range: 0 or 1\00"
define void @set_port(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
switch i32 %1, label %10 [
i32 0, label %6
i32 1, label %8
]
6: ; preds = %5
%7 = tail call i32 @write_byte_data(i32 %0, i32 %3, i32 %2)
br label %12
8: ; preds = %5
%9 = tail call i32 @write_byte_data(i32 %0, i32 %4, i32 %2)
br label %12
10: ; preds = %5
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %8, %10, %6
ret void
}