#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 */

/* Variables and functions */
int atoi(char const *);
char *read_ventil();
scalar_t__ strcmp(char const *, char *);
const char *const read_ventil_text(void) {
  const char *result;
  result = read_ventil();
  if (strcmp(result, "NULL") == 0)
    return "NULL";
  switch (atoi(result)) {
  case 0:
    return "undefiniert";
  case 1:
    return "Heizkreis";
  case 2:
    return "Mittelstellung";
  case 3:
    return "Warmwasserbereitung";
  default:
    return "UNKNOWN";
  }
}


x86 assembly (clang, -O0):
<read_ventil_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1040 <read_ventil@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116d <read_ventil_text+0x3d>
lea    0xeac(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <read_ventil_text+0xb4>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11d9 <read_ventil_text+0xa9>
mov    -0x18(%rbp),%rax
lea    0xe70(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe75(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <read_ventil_text+0xb4>
lea    0xe71(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <read_ventil_text+0xb4>
lea    0xe6b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <read_ventil_text+0xb4>
lea    0xe6a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e4 <read_ventil_text+0xb4>
lea    0xe6e(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_ventil_text>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <read_ventil@plt>
mov    %rax,%r14
lea    0xebb(%rip),%rbx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     117b <read_ventil_text+0x4b>
mov    %r14,%rdi
call   1050 <atoi@plt>
cmp    $0x3,%eax
ja     1174 <read_ventil_text+0x44>
cltq
lea    0xedd(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    117b <read_ventil_text+0x4b>
lea    0xec3(%rip),%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"NULL\00"
@.str.1 = [12 x i8] c"undefiniert\00"
@.str.2 = [10 x i8] c"Heizkreis\00"
@.str.3 = [15 x i8] c"Mittelstellung\00"
@.str.4 = [20 x i8] c"Warmwasserbereitung\00"
@.str.5 = [8 x i8] c"UNKNOWN\00"
define i8* @read_ventil_text() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* (...) @read_ventil()
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %1
br label %16
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i32 @atoi(i8* %9)
switch i32 %10, label %15 [
i32 0, label %11
i32 1, label %12
i32 2, label %13
i32 3, label %14
]
11: ; preds = %8
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %16
12: ; preds = %8
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %16
13: ; preds = %8
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %16
14: ; preds = %8
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %16
15: ; preds = %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %1
br label %16
16: ; preds = %15, %14, %13, %12, %11, %7
%17 = load i8*, i8** %1
ret i8* %17
}

LLVM IR (-O2):
@.str = [5 x i8] c"NULL\00"
@.str.1 = [12 x i8] c"undefiniert\00"
@.str.2 = [10 x i8] c"Heizkreis\00"
@.str.3 = [15 x i8] c"Mittelstellung\00"
@.str.4 = [20 x i8] c"Warmwasserbereitung\00"
@.str.5 = [8 x i8] c"UNKNOWN\00"
@reltable.read_ventil_text = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.read_ventil_text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.read_ventil_text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.read_ventil_text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.read_ventil_text to i64)) to i32)]
define i8* @read_ventil_text() {
%1 = tail call i8* (...) @read_ventil()
%2 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %0
%5 = tail call i32 @atoi(i8* %1)
%6 = icmp ult i32 %5, 4
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.read_ventil_text to i8*), i64 %9)
br label %11
11: ; preds = %4, %7, %0
%12 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %0 ], [ %10, %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %4 ]
ret i8* %12
}