#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
void ivb_debug_port(char *result, int len, int reg, uint32_t val,
                    uint32_t devid) {
  const char *drrs = NULL;
  switch (val & (2 << 30)) {
  case (0 << 30):
    drrs = "off";
    break;
  case (1 << 30):
    drrs = "low";
    break;
  case (2 << 30):
    drrs = "high";
    break;
  }
  snprintf(result, len, "HW DRRS %s", drrs);
}


x86 assembly (clang, -O0):
<ivb_debug_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
and    $0x80000000,%eax
mov    %eax,-0x24(%rbp)
jne    118a <ivb_debug_port+0x7a>
jmp    1147 <ivb_debug_port+0x37>
mov    -0x24(%rbp),%eax
test   %eax,%eax
je     116a <ivb_debug_port+0x5a>
jmp    1157 <ivb_debug_port+0x47>
mov    -0x24(%rbp),%eax
sub    $0x40000000,%eax
je     117a <ivb_debug_port+0x6a>
jmp    1195 <ivb_debug_port+0x85>
lea    0xe8f(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1195 <ivb_debug_port+0x85>
lea    0xe83(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1195 <ivb_debug_port+0x85>
lea    0xe77(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
lea    0xe66(%rip),%rdx
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ivb_debug_port>:
test   %ecx,%ecx
lea    0xee7(%rip),%rax
lea    0xee4(%rip),%rcx
cmovns %rax,%rcx
lea    0xede(%rip),%rdx
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"off\00"
@.str.1 = [4 x i8] c"low\00"
@.str.2 = [5 x i8] c"high\00"
@.str.3 = [11 x i8] c"HW DRRS %s\00"
define void @ivb_debug_port(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i8* null, i8** %11
%12 = load i32, i32* %9
%13 = and i32 %12, -2147483648
switch i32 %13, label %17 [
i32 0, label %14
i32 1073741824, label %15
i32 -2147483648, label %16
]
14: ; preds = %5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %11
br label %17
15: ; preds = %5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %11
br label %17
16: ; preds = %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %11
br label %17
17: ; preds = %5, %16, %15, %14
%18 = load i8*, i8** %6
%19 = load i32, i32* %7
%20 = load i8*, i8** %11
%21 = call i32 @snprintf(i8* %18, i32 %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %20)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"off\00"
@.str.2 = [5 x i8] c"high\00"
@.str.3 = [11 x i8] c"HW DRRS %s\00"
define void @ivb_debug_port(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp sgt i32 %3, -1
%7 = select i1 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%8 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %7)
ret void
}