#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 *const);
char *read_mode();
scalar_t__ strcmp(char const *const, char *);
const char *const read_mode_text(void) {
  const char *const mode = read_mode();
  if (strcmp(mode, "NULL") == 0)
    return "NULL";
  switch (atoi(mode)) {
  case 0:
    return "Adirhaltbetrieb";
  case 1:
    return "Nur Warmwasser";
  case 2:
    return "Heizen und Warmwasser";
  default:
    return "UNKNOWN";
  }
}


x86 assembly (clang, -O0):
<read_mode_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1030 <read_mode@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    116d <read_mode_text+0x3d>
lea    0xe9c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e5 <read_mode_text+0xb5>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
test   %eax,%eax
je     11aa <read_mode_text+0x7a>
jmp    1188 <read_mode_text+0x58>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     11ba <read_mode_text+0x8a>
jmp    1199 <read_mode_text+0x69>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11ca <read_mode_text+0x9a>
jmp    11da <read_mode_text+0xaa>
lea    0xe54(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e5 <read_mode_text+0xb5>
lea    0xe54(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e5 <read_mode_text+0xb5>
lea    0xe53(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e5 <read_mode_text+0xb5>
lea    0xe59(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_mode_text>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <read_mode@plt>
mov    %rax,%r14
lea    0xebb(%rip),%rbx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     117b <read_mode_text+0x4b>
mov    %r14,%rdi
call   1050 <atoi@plt>
cmp    $0x2,%eax
ja     1174 <read_mode_text+0x44>
cltq
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    117b <read_mode_text+0x4b>
lea    0xebf(%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 = [16 x i8] c"Adirhaltbetrieb\00"
@.str.2 = [15 x i8] c"Nur Warmwasser\00"
@.str.3 = [22 x i8] c"Heizen und Warmwasser\00"
@.str.4 = [8 x i8] c"UNKNOWN\00"
define i8* @read_mode_text() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* (...) @read_mode()
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 %15
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i32 @atoi(i8* %9)
switch i32 %10, label %14 [
i32 0, label %11
i32 1, label %12
i32 2, label %13
]
11: ; preds = %8
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %15
12: ; preds = %8
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %1
br label %15
13: ; preds = %8
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %15
14: ; preds = %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %15
15: ; preds = %14, %13, %12, %11, %7
%16 = load i8*, i8** %1
ret i8* %16
}

LLVM IR (-O2):
@.str = [5 x i8] c"NULL\00"
@.str.1 = [16 x i8] c"Adirhaltbetrieb\00"
@.str.2 = [15 x i8] c"Nur Warmwasser\00"
@.str.3 = [22 x i8] c"Heizen und Warmwasser\00"
@.str.4 = [8 x i8] c"UNKNOWN\00"
@reltable.read_mode_text = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.read_mode_text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.read_mode_text to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.read_mode_text to i64)) to i32)]
define i8* @read_mode_text() {
%1 = tail call i8* (...) @read_mode()
%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, 3
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 ([3 x i32]* @reltable.read_mode_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.4, i64 0, i64 0), %4 ]
ret i8* %12
}