#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 gzFile_s {
  int dummy;
};

/* Variables and functions */
char *AE_Print_Betriebsdaten(int, int);
char *AE_Print_Bit_Betrieb(int, int);
char *AE_Print_Bit_Fehler(int, int);
char *AE_Print_Bit_Stoerung(int, int);
char *AE_Print_Laender(int, int);
char *AE_Print_Parameter(int, int);
char *AE_Print_Schueco(int, int);
char *AE_Print_Statistikdaten(int);
int /*<<< orphan*/ AE_Request(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ AE_Request_Schueco(int);
int /*<<< orphan*/ close_gz(struct gzFile_s *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ gzprintf(struct gzFile_s *, char *);
struct gzFile_s *open_gz();
int /*<<< orphan*/ send_gz(int);
int /*<<< orphan*/ set_wakeup(int);
void write_Fragment(int fd, int id, int what) {
  char *t_ptr;
  switch (what) {
  case 0:
    set_wakeup(id);
    t_ptr = AE_Print_Betriebsdaten(1, id);
    break;
  case 1:
    t_ptr = AE_Print_Bit_Betrieb(1, id);
    break;
  case 2:
    t_ptr = AE_Print_Bit_Stoerung(1, id);
    break;
  case 3:
    t_ptr = AE_Print_Bit_Fehler(1, id);
    break;
  case 4:
    AE_Request_Schueco(id);
    t_ptr = AE_Print_Schueco(1, id);
    break;
  case 5:
    AE_Request(id, 1007, 0);
    t_ptr = AE_Print_Laender(1, id);
    break;
  case 6:
    t_ptr = AE_Print_Parameter(1, id);
    break;
  case 7:
    t_ptr = AE_Print_Statistikdaten(1);
    break;
  default:
    return;
    break;
  }
  struct gzFile_s *tmp = open_gz();
  gzprintf(tmp, t_ptr);
  free(t_ptr);
  close_gz(tmp);
  send_gz(fd);
}


x86 assembly (clang, -O0):
<write_Fragment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x7,%rax
ja     1302 <write_Fragment+0x102>
mov    -0x28(%rbp),%rax
lea    0xdd3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
call   1060 <set_wakeup@plt>
mov    -0x8(%rbp),%esi
mov    $0x1,%edi
call   1050 <AE_Print_Betriebsdaten@plt>
mov    %rax,-0x18(%rbp)
jmp    1307 <write_Fragment+0x107>
mov    -0x8(%rbp),%esi
mov    $0x1,%edi
call   10a0 <AE_Print_Bit_Betrieb@plt>
mov    %rax,-0x18(%rbp)
jmp    1307 <write_Fragment+0x107>
mov    -0x8(%rbp),%esi
mov    $0x1,%edi
call   10d0 <AE_Print_Bit_Stoerung@plt>
mov    %rax,-0x18(%rbp)
jmp    1307 <write_Fragment+0x107>
mov    -0x8(%rbp),%esi
mov    $0x1,%edi
call   1040 <AE_Print_Bit_Fehler@plt>
mov    %rax,-0x18(%rbp)
jmp    1307 <write_Fragment+0x107>
mov    -0x8(%rbp),%edi
call   1080 <AE_Request_Schueco@plt>
mov    -0x8(%rbp),%esi
mov    $0x1,%edi
call   1120 <AE_Print_Schueco@plt>
mov    %rax,-0x18(%rbp)
jmp    1307 <write_Fragment+0x107>
mov    -0x8(%rbp),%edi
mov    $0x3ef,%esi
xor    %edx,%edx
call   10f0 <AE_Request@plt>
mov    -0x8(%rbp),%esi
mov    $0x1,%edi
call   1110 <AE_Print_Laender@plt>
mov    %rax,-0x18(%rbp)
jmp    1307 <write_Fragment+0x107>
mov    -0x8(%rbp),%esi
mov    $0x1,%edi
call   10c0 <AE_Print_Parameter@plt>
mov    %rax,-0x18(%rbp)
jmp    1307 <write_Fragment+0x107>
mov    $0x1,%edi
call   10b0 <AE_Print_Statistikdaten@plt>
mov    %rax,-0x18(%rbp)
jmp    1307 <write_Fragment+0x107>
jmp    1339 <write_Fragment+0x139>
mov    $0x0,%al
call   1090 <open_gz@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <gzprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   10e0 <close_gz@plt>
mov    -0x4(%rbp),%edi
call   1100 <send_gz@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_Fragment>:
cmp    $0x7,%edx
ja     1235 <write_Fragment+0x35>
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%r14d
mov    %edx,%eax
lea    0xde9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %ebp,%edi
call   1060 <set_wakeup@plt>
mov    $0x1,%edi
mov    %ebp,%esi
call   1050 <AE_Print_Betriebsdaten@plt>
jmp    12a9 <write_Fragment+0xa9>
ret
mov    $0x1,%edi
mov    %ebp,%esi
call   10a0 <AE_Print_Bit_Betrieb@plt>
jmp    12a9 <write_Fragment+0xa9>
mov    $0x1,%edi
mov    %ebp,%esi
call   10d0 <AE_Print_Bit_Stoerung@plt>
jmp    12a9 <write_Fragment+0xa9>
mov    $0x1,%edi
mov    %ebp,%esi
call   1040 <AE_Print_Bit_Fehler@plt>
jmp    12a9 <write_Fragment+0xa9>
mov    %ebp,%edi
call   1080 <AE_Request_Schueco@plt>
mov    $0x1,%edi
mov    %ebp,%esi
call   1120 <AE_Print_Schueco@plt>
jmp    12a9 <write_Fragment+0xa9>
mov    %ebp,%edi
mov    $0x3ef,%esi
xor    %edx,%edx
call   10f0 <AE_Request@plt>
mov    $0x1,%edi
mov    %ebp,%esi
call   1110 <AE_Print_Laender@plt>
jmp    12a9 <write_Fragment+0xa9>
mov    $0x1,%edi
mov    %ebp,%esi
call   10c0 <AE_Print_Parameter@plt>
jmp    12a9 <write_Fragment+0xa9>
mov    $0x1,%edi
call   10b0 <AE_Print_Statistikdaten@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1090 <open_gz@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1070 <gzprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   10e0 <close_gz@plt>
mov    %r14d,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1100 <send_gz@plt>

LLVM IR (-O0):
%struct.gzFile_s = type { i32 }
define void @write_Fragment(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca %struct.gzFile_s*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
switch i32 %9, label %39 [
i32 0, label %10
i32 1, label %15
i32 2, label %18
i32 3, label %21
i32 4, label %24
i32 5, label %29
i32 6, label %34
i32 7, label %37
]
10: ; preds = %3
%11 = load i32, i32* %5
%12 = call i32 @set_wakeup(i32 %11)
%13 = load i32, i32* %5
%14 = call i8* @AE_Print_Betriebsdaten(i32 1, i32 %13)
store i8* %14, i8** %7
br label %40
15: ; preds = %3
%16 = load i32, i32* %5
%17 = call i8* @AE_Print_Bit_Betrieb(i32 1, i32 %16)
store i8* %17, i8** %7
br label %40
18: ; preds = %3
%19 = load i32, i32* %5
%20 = call i8* @AE_Print_Bit_Stoerung(i32 1, i32 %19)
store i8* %20, i8** %7
br label %40
21: ; preds = %3
%22 = load i32, i32* %5
%23 = call i8* @AE_Print_Bit_Fehler(i32 1, i32 %22)
store i8* %23, i8** %7
br label %40
24: ; preds = %3
%25 = load i32, i32* %5
%26 = call i32 @AE_Request_Schueco(i32 %25)
%27 = load i32, i32* %5
%28 = call i8* @AE_Print_Schueco(i32 1, i32 %27)
store i8* %28, i8** %7
br label %40
29: ; preds = %3
%30 = load i32, i32* %5
%31 = call i32 @AE_Request(i32 %30, i32 1007, i32 0)
%32 = load i32, i32* %5
%33 = call i8* @AE_Print_Laender(i32 1, i32 %32)
store i8* %33, i8** %7
br label %40
34: ; preds = %3
%35 = load i32, i32* %5
%36 = call i8* @AE_Print_Parameter(i32 1, i32 %35)
store i8* %36, i8** %7
br label %40
37: ; preds = %3
%38 = call i8* @AE_Print_Statistikdaten(i32 1)
store i8* %38, i8** %7
br label %40
39: ; preds = %3
br label %51
40: ; preds = %37, %34, %29, %24, %21, %18, %15, %10
%41 = call %struct.gzFile_s* (...) @open_gz()
store %struct.gzFile_s* %41, %struct.gzFile_s** %8
%42 = load %struct.gzFile_s*, %struct.gzFile_s** %8
%43 = load i8*, i8** %7
%44 = call i32 @gzprintf(%struct.gzFile_s* %42, i8* %43)
%45 = load i8*, i8** %7
%46 = call i32 @free(i8* %45)
%47 = load %struct.gzFile_s*, %struct.gzFile_s** %8
%48 = call i32 @close_gz(%struct.gzFile_s* %47)
%49 = load i32, i32* %4
%50 = call i32 @send_gz(i32 %49)
br label %51
51: ; preds = %40, %39
ret void
}

LLVM IR (-O2):
%struct.gzFile_s = type { i32 }
define void @write_Fragment(i32 %0, i32 %1, i32 %2) {
switch i32 %2, label %30 [
i32 0, label %4
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %16
i32 6, label %19
i32 7, label %21
]
4: ; preds = %3
%5 = tail call i32 @set_wakeup(i32 %1)
%6 = tail call i8* @AE_Print_Betriebsdaten(i32 1, i32 %1)
br label %23
7: ; preds = %3
%8 = tail call i8* @AE_Print_Bit_Betrieb(i32 1, i32 %1)
br label %23
9: ; preds = %3
%10 = tail call i8* @AE_Print_Bit_Stoerung(i32 1, i32 %1)
br label %23
11: ; preds = %3
%12 = tail call i8* @AE_Print_Bit_Fehler(i32 1, i32 %1)
br label %23
13: ; preds = %3
%14 = tail call i32 @AE_Request_Schueco(i32 %1)
%15 = tail call i8* @AE_Print_Schueco(i32 1, i32 %1)
br label %23
16: ; preds = %3
%17 = tail call i32 @AE_Request(i32 %1, i32 1007, i32 0)
%18 = tail call i8* @AE_Print_Laender(i32 1, i32 %1)
br label %23
19: ; preds = %3
%20 = tail call i8* @AE_Print_Parameter(i32 1, i32 %1)
br label %23
21: ; preds = %3
%22 = tail call i8* @AE_Print_Statistikdaten(i32 1)
br label %23
23: ; preds = %21, %19, %16, %13, %11, %9, %7, %4
%24 = phi i8* [ %22, %21 ], [ %20, %19 ], [ %18, %16 ], [ %15, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %4 ]
%25 = tail call %struct.gzFile_s* (...) @open_gz()
%26 = tail call i32 @gzprintf(%struct.gzFile_s* %25, i8* %24)
%27 = tail call i32 @free(i8* %24)
%28 = tail call i32 @close_gz(%struct.gzFile_s* %25)
%29 = tail call i32 @send_gz(i32 %0)
br label %30
30: ; preds = %3, %23
ret void
}