#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 */
struct dvb_frontend_info {
  int type;
  char *name;
};

/* Variables and functions */
int EINVAL;
#define FE_OFDM 130
#define FE_QAM 129
#define FE_QPSK 128
int /*<<< orphan*/ printf(char *, ...);
int FEDumpInfo(struct dvb_frontend_info *info) {
  if (!info)
    return -EINVAL;
  switch (info->type) {
  case FE_QAM:
    printf("FE Type: QAM\n");
    break;
  case FE_QPSK:
    printf("FE Type: QPSK\n");
    break;
  case FE_OFDM:
    printf("FE Type: OFDM\n");
    break;
  default:
    printf("FE Type: unknown!\n");
  }
  printf("FE Name: %s\n", info->name);
  return 0;
}


x86 assembly (clang, -O0):
<FEDumpInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113a <FEDumpInfo+0x2a>
xor    %eax,%eax
mov    0x2eb0(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11dd <FEDumpInfo+0xcd>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x80,%eax
je     118c <FEDumpInfo+0x7c>
jmp    1153 <FEDumpInfo+0x43>
mov    -0x14(%rbp),%eax
sub    $0x81,%eax
je     1179 <FEDumpInfo+0x69>
jmp    1166 <FEDumpInfo+0x56>
mov    -0x14(%rbp),%eax
sub    $0x82,%eax
je     119f <FEDumpInfo+0x8f>
jmp    11b2 <FEDumpInfo+0xa2>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c0 <FEDumpInfo+0xb0>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c0 <FEDumpInfo+0xb0>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c0 <FEDumpInfo+0xb0>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FEDumpInfo>:
push   %rbx
test   %rdi,%rdi
je     1145 <FEDumpInfo+0x25>
mov    %rdi,%rbx
mov    (%rdi),%eax
add    $0xffffff80,%eax
cmp    $0x2,%eax
ja     1152 <FEDumpInfo+0x32>
cltq
lea    0xf0c(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1159 <FEDumpInfo+0x39>
mov    0x2e94(%rip),%rax
xor    %ebx,%ebx
sub    (%rax),%ebx
jmp    1172 <FEDumpInfo+0x52>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rbx),%rsi
lea    0xe97(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.dvb_frontend_info = type { i32, i8* }
@EINVAL = global i32 0
@.str = [14 x i8] c"FE Type: QAM\0A\00"
@.str.1 = [15 x i8] c"FE Type: QPSK\0A\00"
@.str.2 = [15 x i8] c"FE Type: OFDM\0A\00"
@.str.3 = [19 x i8] c"FE Type: unknown!\0A\00"
@.str.4 = [13 x i8] c"FE Name: %s\0A\00"
define i32 @FEDumpInfo(%struct.dvb_frontend_info* %0) {
%2 = alloca i32
%3 = alloca %struct.dvb_frontend_info*
store %struct.dvb_frontend_info* %0, %struct.dvb_frontend_info** %3
%4 = load %struct.dvb_frontend_info*, %struct.dvb_frontend_info** %3
%5 = icmp ne %struct.dvb_frontend_info* %4, null
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @EINVAL
%8 = sub nsw i32 0, %7
store i32 %8, i32* %2
br label %26
9: ; preds = %1
%10 = load %struct.dvb_frontend_info*, %struct.dvb_frontend_info** %3
%11 = getelementptr inbounds %struct.dvb_frontend_info, %struct.dvb_frontend_info* %10, i32 0, i32 0
%12 = load i32, i32* %11
switch i32 %12, label %19 [
i32 129, label %13
i32 128, label %15
i32 130, label %17
]
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %21
15: ; preds = %9
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %21
17: ; preds = %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %21
19: ; preds = %9
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %17, %15, %13
%22 = load %struct.dvb_frontend_info*, %struct.dvb_frontend_info** %3
%23 = getelementptr inbounds %struct.dvb_frontend_info, %struct.dvb_frontend_info* %22, i32 0, i32 1
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %24)
store i32 0, i32* %2
br label %26
26: ; preds = %21, %6
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
%struct.dvb_frontend_info = type { i32, i8* }
@EINVAL = global i32 0
@.str.4 = [13 x i8] c"FE Name: %s\0A\00"
@str = [14 x i8] c"FE Type: OFDM\00"
@str.5 = [14 x i8] c"FE Type: QPSK\00"
@str.6 = [13 x i8] c"FE Type: QAM\00"
@str.7 = [18 x i8] c"FE Type: unknown!\00"
@reltable.FEDumpInfo = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.FEDumpInfo to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @str.6 to i64), i64 ptrtoint ([3 x i32]* @reltable.FEDumpInfo to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @str to i64), i64 ptrtoint ([3 x i32]* @reltable.FEDumpInfo to i64)) to i32)]
define i32 @FEDumpInfo(%struct.dvb_frontend_info* %0) {
%2 = icmp eq %struct.dvb_frontend_info* %0, null
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @EINVAL
%5 = sub nsw i32 0, %4
br label %21
6: ; preds = %1
%7 = getelementptr inbounds %struct.dvb_frontend_info, %struct.dvb_frontend_info* %0, i64 0, i32 0
%8 = load i32, i32* %7
%9 = add i32 %8, -128
%10 = icmp ult i32 %9, 3
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = sext i32 %9 to i64
%13 = shl i64 %12, 2
%14 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.FEDumpInfo to i8*), i64 %13)
br label %15
15: ; preds = %6, %11
%16 = phi i8* [ %14, %11 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.7, i64 0, i64 0), %6 ]
%17 = tail call i32 @puts(i8* dereferenceable(1) %16)
%18 = getelementptr inbounds %struct.dvb_frontend_info, %struct.dvb_frontend_info* %0, i64 0, i32 1
%19 = load i8*, i8** %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %15, %3
%22 = phi i32 [ 0, %15 ], [ %5, %3 ]
ret i32 %22
}