#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 */
size_t strlen(char *);
int /*<<< orphan*/ write(int, ...);
int handleAckNack(int fd, char msg) {
  char *tempMsg;
  size_t tempLen;
  if (msg == '0')
    tempMsg = "2.nick - login, 6. - user list";
  else if (msg == '1') {
    tempMsg = "Nie mozna Cie Zalogowac, podany nick juz istnieje";
  } else if (msg == '2') {
    tempMsg = "Zalogowano";
  } else if (msg == '3')
    return 1;
  else if (msg == '4')
    tempMsg = "Jestes juz zalogowany";
  tempLen = strlen(tempMsg);
  write(fd, &tempLen, sizeof(size_t));
  write(fd, tempMsg, tempLen);
  return 0;
}


x86 assembly (clang, -O0):
<handleAckNack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x30,%eax
jne    114e <handleAckNack+0x2e>
lea    0xebb(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11cd <handleAckNack+0xad>
movsbl -0x9(%rbp),%eax
cmp    $0x31,%eax
jne    116b <handleAckNack+0x4b>
lea    0xebd(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11c8 <handleAckNack+0xa8>
movsbl -0x9(%rbp),%eax
cmp    $0x32,%eax
jne    1188 <handleAckNack+0x68>
lea    0xed2(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11c3 <handleAckNack+0xa3>
movsbl -0x9(%rbp),%eax
cmp    $0x33,%eax
jne    11a1 <handleAckNack+0x81>
movl   $0x1,-0x4(%rbp)
jmp    1206 <handleAckNack+0xe6>
movsbl -0x9(%rbp),%eax
cmp    $0x34,%eax
jne    11b9 <handleAckNack+0x99>
lea    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11be <handleAckNack+0x9e>
jmp    11c3 <handleAckNack+0xa3>
jmp    11c8 <handleAckNack+0xa8>
jmp    11cd <handleAckNack+0xad>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <write@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleAckNack>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
add    $0xcf,%sil
cmp    $0x3,%sil
ja     1157 <handleAckNack+0x37>
mov    $0x1,%ebp
movzbl %sil,%eax
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeda(%rip),%rbx
jmp    1170 <handleAckNack+0x50>
lea    0xeb2(%rip),%rbx
jmp    1170 <handleAckNack+0x50>
lea    0xefa(%rip),%rbx
jmp    1170 <handleAckNack+0x50>
lea    0xefc(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,0x8(%rsp)
xor    %ebp,%ebp
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
mov    %r14d,%edi
xor    %eax,%eax
call   1030 <write@plt>
mov    0x8(%rsp),%rdx
mov    %r14d,%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <write@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"2.nick - login, 6. - user list\00"
@.str.1 = [50 x i8] c"Nie mozna Cie Zalogowac, podany nick juz istnieje\00"
@.str.2 = [11 x i8] c"Zalogowano\00"
@.str.3 = [22 x i8] c"Jestes juz zalogowany\00"
define i32 @handleAckNack(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i64
store i32 %0, i32* %4
store i8 %1, i8* %5
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 48
br i1 %10, label %11, label %12
11: ; preds = %2
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8** %6
br label %36
12: ; preds = %2
%13 = load i8, i8* %5
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 49
br i1 %15, label %16, label %17
16: ; preds = %12
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %35
17: ; preds = %12
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 50
br i1 %20, label %21, label %22
21: ; preds = %17
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %6
br label %34
22: ; preds = %17
%23 = load i8, i8* %5
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 51
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 1, i32* %3
br label %45
27: ; preds = %22
%28 = load i8, i8* %5
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 52
br i1 %30, label %31, label %32
31: ; preds = %27
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8** %6
br label %32
32: ; preds = %31, %27
br label %33
33: ; preds = %32
br label %34
34: ; preds = %33, %21
br label %35
35: ; preds = %34, %16
br label %36
36: ; preds = %35, %11
%37 = load i8*, i8** %6
%38 = call i64 @strlen(i8* %37)
store i64 %38, i64* %7
%39 = load i32, i32* %4
%40 = call i32 (i32, ...) @write(i32 %39, i64* %7, i64 8)
%41 = load i32, i32* %4
%42 = load i8*, i8** %6
%43 = load i64, i64* %7
%44 = call i32 (i32, ...) @write(i32 %41, i8* %42, i64 %43)
store i32 0, i32* %3
br label %45
45: ; preds = %36, %26
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [31 x i8] c"2.nick - login, 6. - user list\00"
@.str.1 = [50 x i8] c"Nie mozna Cie Zalogowac, podany nick juz istnieje\00"
@.str.2 = [11 x i8] c"Zalogowano\00"
@.str.3 = [22 x i8] c"Jestes juz zalogowany\00"
define i32 @handleAckNack(i32 %0, i8 signext %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
switch i8 %1, label %8 [
i8 52, label %7
i8 49, label %5
i8 50, label %6
i8 51, label %14
]
5: ; preds = %2
br label %8
6: ; preds = %2
br label %8
7: ; preds = %2
br label %8
8: ; preds = %2, %5, %7, %6
%9 = phi i8* [ getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), %2 ]
%10 = tail call i64 @strlen(i8* dereferenceable(1) %9)
store i64 %10, i64* %3
%11 = call i32 (i32, ...) @write(i32 %0, i64* %3, i64 8)
%12 = load i64, i64* %3
%13 = call i32 (i32, ...) @write(i32 %0, i8* %9, i64 %12)
br label %14
14: ; preds = %2, %8
%15 = phi i32 [ 0, %8 ], [ 1, %2 ]
ret i32 %15
}