void display_data(char *buf) {
  char *res = "test";
  char flag[5];
  switch (getFlag(buf)) {
  case 1:
    printf("Flag: RRQ\n");
    break;
  case 2:
    printf("Flag: WRQ\n");
    break;
  case 3:
    printf("Flag: DATA\n");
    break;
  case 6:
    printf("Flag: OACK\n");
    break;
  case 5:
    printf("Flag: ERROR\n");
    break;
  default:
    printf("Unknown flag !\n");
  }
  switch (getFlag(buf)) {
  case 1:
    printf("File: %s\n", buf + 2);
    break;
  case 2:
    printf("File: %s\n", buf + 2);
    break;
  case 4:
    printf("Block: %d \n", getNblock(buf));
    break;
  case 3:
    printf("Block: %d \n", getNblock(buf));
    break;
  case 5:
    printf("Error: %s\n", getData(buf, res));
    break;
  }
  return;
}


x86 assembly (clang, -O0):
<display_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xed9(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
call   1060 <getFlag@plt>
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     11e7 <display_data+0xa7>
mov    -0x20(%rbp),%rax
lea    0xe81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f5 <display_data+0xb5>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f5 <display_data+0xb5>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f5 <display_data+0xb5>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f5 <display_data+0xb5>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f5 <display_data+0xb5>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
call   1060 <getFlag@plt>
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x4,%eax
ja     12bb <display_data+0x17b>
mov    -0x28(%rbp),%rax
lea    0xdfb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rsi
add    $0x2,%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bb <display_data+0x17b>
mov    -0x8(%rbp),%rsi
add    $0x2,%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bb <display_data+0x17b>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1050 <getNblock@plt>
mov    %eax,%esi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bb <display_data+0x17b>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1050 <getNblock@plt>
mov    %eax,%esi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bb <display_data+0x17b>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1030 <getData@plt>
mov    %eax,%esi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_data>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <getFlag@plt>
add    $0xffffffff,%eax
cmp    $0x5,%eax
ja     1175 <display_data+0x25>
cltq
lea    0xea8(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    117c <display_data+0x2c>
lea    0xf0c(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <getFlag@plt>
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     11cc <display_data+0x7c>
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
add    $0x2,%rbx
lea    0xe83(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
pop    %rbx
jmp    1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <getNblock@plt>
lea    0xe71(%rip),%rdi
jmp    11e6 <display_data+0x96>
pop    %rbx
ret
lea    0xe57(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <getData@plt>
lea    0xe61(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rbx
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"test\00"
@.str.1 = [11 x i8] c"Flag: RRQ\0A\00"
@.str.2 = [11 x i8] c"Flag: WRQ\0A\00"
@.str.3 = [12 x i8] c"Flag: DATA\0A\00"
@.str.4 = [12 x i8] c"Flag: OACK\0A\00"
@.str.5 = [13 x i8] c"Flag: ERROR\0A\00"
@.str.6 = [16 x i8] c"Unknown flag !\0A\00"
@.str.7 = [10 x i8] c"File: %s\0A\00"
@.str.8 = [12 x i8] c"Block: %d \0A\00"
@.str.9 = [11 x i8] c"Error: %s\0A\00"
define void @display_data(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [5 x i8]
store i8* %0, i8** %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %2
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @getFlag to i32 (i8*, ...)*)(i8* %5)
switch i32 %6, label %17 [
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 6, label %13
i32 5, label %15
]
7: ; preds = %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %19
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %19
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %19
13: ; preds = %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %19
15: ; preds = %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %19
17: ; preds = %1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %19
19: ; preds = %17, %15, %13, %11, %9, %7
%20 = load i8*, i8** %2
%21 = call i32 (i8*, ...) bitcast (i32 (...)* @getFlag to i32 (i8*, ...)*)(i8* %20)
switch i32 %21, label %43 [
i32 1, label %22
i32 2, label %26
i32 4, label %30
i32 3, label %34
i32 5, label %38
]
22: ; preds = %19
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %24)
br label %43
26: ; preds = %19
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i64 2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %28)
br label %43
30: ; preds = %19
%31 = load i8*, i8** %2
%32 = call i32 (i8*, ...) bitcast (i32 (...)* @getNblock to i32 (i8*, ...)*)(i8* %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i32 %32)
br label %43
34: ; preds = %19
%35 = load i8*, i8** %2
%36 = call i32 (i8*, ...) bitcast (i32 (...)* @getNblock to i32 (i8*, ...)*)(i8* %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i32 %36)
br label %43
38: ; preds = %19
%39 = load i8*, i8** %2
%40 = load i8*, i8** %3
%41 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @getData to i32 (i8*, i8*, ...)*)(i8* %39, i8* %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %19, %38, %34, %30, %26, %22
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"test\00"
@.str.7 = [10 x i8] c"File: %s\0A\00"
@.str.8 = [12 x i8] c"Block: %d \0A\00"
@.str.9 = [11 x i8] c"Error: %s\0A\00"
@str = [12 x i8] c"Flag: ERROR\00"
@str.10 = [11 x i8] c"Flag: OACK\00"
@str.11 = [11 x i8] c"Flag: DATA\00"
@str.12 = [10 x i8] c"Flag: WRQ\00"
@str.13 = [10 x i8] c"Flag: RRQ\00"
@str.14 = [15 x i8] c"Unknown flag !\00"
@reltable.display_data = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.13 to i64), i64 ptrtoint ([6 x i32]* @reltable.display_data to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @str.12 to i64), i64 ptrtoint ([6 x i32]* @reltable.display_data to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.11 to i64), i64 ptrtoint ([6 x i32]* @reltable.display_data to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @str.14 to i64), i64 ptrtoint ([6 x i32]* @reltable.display_data to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @str to i64), i64 ptrtoint ([6 x i32]* @reltable.display_data to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.10 to i64), i64 ptrtoint ([6 x i32]* @reltable.display_data to i64)) to i32)]
define void @display_data(i8* %0) {
%2 = tail call i32 (i8*, ...) bitcast (i32 (...)* @getFlag to i32 (i8*, ...)*)(i8* %0)
%3 = add i32 %2, -1
%4 = icmp ult i32 %3, 6
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i32 %3 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.display_data to i8*), i64 %7)
br label %9
9: ; preds = %1, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.14, i64 0, i64 0), %1 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
%12 = tail call i32 (i8*, ...) bitcast (i32 (...)* @getFlag to i32 (i8*, ...)*)(i8* %0)
switch i32 %12, label %28 [
i32 1, label %13
i32 2, label %16
i32 4, label %19
i32 3, label %22
i32 5, label %25
]
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %0, i64 2
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %14)
br label %28
16: ; preds = %9
%17 = getelementptr inbounds i8, i8* %0, i64 2
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %17)
br label %28
19: ; preds = %9
%20 = tail call i32 (i8*, ...) bitcast (i32 (...)* @getNblock to i32 (i8*, ...)*)(i8* %0)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i32 %20)
br label %28
22: ; preds = %9
%23 = tail call i32 (i8*, ...) bitcast (i32 (...)* @getNblock to i32 (i8*, ...)*)(i8* %0)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i32 %23)
br label %28
25: ; preds = %9
%26 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @getData to i32 (i8*, i8*, ...)*)(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %9, %25, %22, %19, %16, %13
ret void
}