#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 /*<<< orphan*/ strncpy(char *, char *, int);
void getServiceInput(int port, char *msg) {
  switch (port) {
  case 25:
    strncpy(msg, "ehlo ffff\r\nquit\r\n", 80);
    break;
  case 21:
    strncpy(msg, "HELP\r\nQUIT\r\n\r\n", 80);
    break;
  case 80:
    strncpy(msg, "GET / HTTP/1.0\r\nConnection: close\r\n\r\n", 80);
    break;
  case 8080:
    strncpy(msg, "GET / HTTP/1.0\r\n\r\n", 80);
    break;
  case 554:
    strncpy(msg, "GET / HTTP/1.0\r\n\r\n", 80);
    break;
  case 5555:
    strncpy(msg, "GET / HTTP/1.0\r\n\r\n", 80);
    break;
  default:
    strncpy(msg, "whololllo?\r\n\r\n", 80);
    break;
  }
}


x86 assembly (clang, -O0):
<getServiceInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x15,%eax
je     11a8 <getServiceInput+0x98>
jmp    1133 <getServiceInput+0x23>
mov    -0x14(%rbp),%eax
sub    $0x19,%eax
je     118e <getServiceInput+0x7e>
jmp    1144 <getServiceInput+0x34>
mov    -0x14(%rbp),%eax
sub    $0x50,%eax
je     11c2 <getServiceInput+0xb2>
jmp    1155 <getServiceInput+0x45>
mov    -0x14(%rbp),%eax
sub    $0x22a,%eax
je     11f6 <getServiceInput+0xe6>
jmp    1168 <getServiceInput+0x58>
mov    -0x14(%rbp),%eax
sub    $0x15b3,%eax
je     1210 <getServiceInput+0x100>
jmp    117b <getServiceInput+0x6b>
mov    -0x14(%rbp),%eax
sub    $0x1f90,%eax
je     11dc <getServiceInput+0xcc>
jmp    122a <getServiceInput+0x11a>
mov    -0x10(%rbp),%rdi
lea    0xe67(%rip),%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
jmp    123f <getServiceInput+0x12f>
mov    -0x10(%rbp),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
jmp    123f <getServiceInput+0x12f>
mov    -0x10(%rbp),%rdi
lea    0xe54(%rip),%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
jmp    123f <getServiceInput+0x12f>
mov    -0x10(%rbp),%rdi
lea    0xe60(%rip),%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
jmp    123f <getServiceInput+0x12f>
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
jmp    123f <getServiceInput+0x12f>
mov    -0x10(%rbp),%rdi
lea    0xe2c(%rip),%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
jmp    123f <getServiceInput+0x12f>
mov    -0x10(%rbp),%rdi
lea    0xe25(%rip),%rsi
mov    $0x50,%edx
call   1030 <strncpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getServiceInput>:
mov    %rsi,%rax
cmp    $0x229,%edi
jg     1133 <getServiceInput+0x23>
cmp    $0x15,%edi
je     1154 <getServiceInput+0x44>
cmp    $0x19,%edi
je     115d <getServiceInput+0x4d>
cmp    $0x50,%edi
jne    1166 <getServiceInput+0x56>
lea    0xef0(%rip),%rsi
jmp    116d <getServiceInput+0x5d>
cmp    $0x22a,%edi
je     114b <getServiceInput+0x3b>
cmp    $0x15b3,%edi
je     114b <getServiceInput+0x3b>
cmp    $0x1f90,%edi
jne    1166 <getServiceInput+0x56>
lea    0xef5(%rip),%rsi
jmp    116d <getServiceInput+0x5d>
lea    0xeb7(%rip),%rsi
jmp    116d <getServiceInput+0x5d>
lea    0xe9c(%rip),%rsi
jmp    116d <getServiceInput+0x5d>
lea    0xeed(%rip),%rsi
mov    %rax,%rdi
mov    $0x50,%edx
jmp    1030 <strncpy@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"ehlo ffff\0D\0Aquit\0D\0A\00"
@.str.1 = [15 x i8] c"HELP\0D\0AQUIT\0D\0A\0D\0A\00"
@.str.2 = [38 x i8] c"GET / HTTP/1.0\0D\0AConnection: close\0D\0A\0D\0A\00"
@.str.3 = [19 x i8] c"GET / HTTP/1.0\0D\0A\0D\0A\00"
@.str.4 = [15 x i8] c"whololllo?\0D\0A\0D\0A\00"
define void @getServiceInput(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
switch i32 %5, label %24 [
i32 25, label %6
i32 21, label %9
i32 80, label %12
i32 8080, label %15
i32 554, label %18
i32 5555, label %21
]
6: ; preds = %2
%7 = load i8*, i8** %4
%8 = call i32 @strncpy(i8* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 80)
br label %27
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 @strncpy(i8* %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 80)
br label %27
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i32 @strncpy(i8* %13, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 80)
br label %27
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = call i32 @strncpy(i8* %16, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 80)
br label %27
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = call i32 @strncpy(i8* %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 80)
br label %27
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = call i32 @strncpy(i8* %22, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 80)
br label %27
24: ; preds = %2
%25 = load i8*, i8** %4
%26 = call i32 @strncpy(i8* %25, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 80)
br label %27
27: ; preds = %24, %21, %18, %15, %12, %9, %6
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"ehlo ffff\0D\0Aquit\0D\0A\00"
@.str.1 = [15 x i8] c"HELP\0D\0AQUIT\0D\0A\0D\0A\00"
@.str.2 = [38 x i8] c"GET / HTTP/1.0\0D\0AConnection: close\0D\0A\0D\0A\00"
@.str.3 = [19 x i8] c"GET / HTTP/1.0\0D\0A\0D\0A\00"
@.str.4 = [15 x i8] c"whololllo?\0D\0A\0D\0A\00"
define void @getServiceInput(i32 %0, i8* %1) {
switch i32 %0, label %8 [
i32 25, label %9
i32 21, label %3
i32 80, label %4
i32 8080, label %5
i32 554, label %6
i32 5555, label %7
]
3: ; preds = %2
br label %9
4: ; preds = %2
br label %9
5: ; preds = %2
br label %9
6: ; preds = %2
br label %9
7: ; preds = %2
br label %9
8: ; preds = %2
br label %9
9: ; preds = %2, %8, %7, %6, %5, %4, %3
%10 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %2 ]
%11 = tail call i32 @strncpy(i8* %1, i8* %10, i32 80)
ret void
}