#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*/ EXIT_FAILURE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
void getServer(char *server) {
  assert(NULL != server);
  char temp[1024] = {0};
  unsigned pos = 0;
  fprintf(stdout, "Enter server: ");
  if (NULL == fgets(temp, 1024, stdin)) {
    perror("fgets error");
    exit(EXIT_FAILURE);
  }
  while (!isspace(temp[pos])) {
    server[pos] = temp[pos];
    pos++;
  }
}


x86 assembly (clang, -O0):
<getServer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1030 <memset@plt>
movl   $0x0,-0x414(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
call   1070 <fprintf@plt>
lea    -0x410(%rbp),%rdi
mov    0x2e16(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1050 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1206 <getServer+0x96>
lea    0xe1c(%rip),%rdi
call   1080 <perror@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    120b <getServer+0x9b>
mov    -0x414(%rbp),%eax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1040 <isspace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1233 <getServer+0xc3>
jmp    1261 <getServer+0xf1>
mov    -0x414(%rbp),%eax
mov    -0x410(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x414(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    120b <getServer+0x9b>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getServer>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%r15
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1060 <assert@plt>
mov    %rsp,%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe51(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1205 <getServer+0x95>
movsbl (%rsp),%edi
call   1040 <isspace@plt>
test   %eax,%eax
jne    11f8 <getServer+0x88>
xor    %ebx,%ebx
xchg   %ax,%ax
movzbl (%rsp,%rbx,1),%eax
mov    %al,(%r15,%rbx,1)
add    $0x1,%ebx
movsbl (%rsp,%rbx,1),%edi
call   1040 <isspace@plt>
test   %eax,%eax
je     11e0 <getServer+0x70>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe03(%rip),%rdi
call   1080 <perror@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [15 x i8] c"Enter server: \00"
@stdin = global i32 0
@.str.1 = [12 x i8] c"fgets error\00"
@EXIT_FAILURE = global i32 0
define void @getServer(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* null, %5
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = bitcast [1024 x i8]* %3 to i8*
store i32 0, i32* %4
%10 = load i32, i32* @stdout
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32* @fgets(i8* %12, i32 1024, i32 %13)
%15 = icmp eq i32* null, %14
br i1 %15, label %16, label %20
16: ; preds = %1
%17 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %1
br label %21
21: ; preds = %29, %20
%22 = load i32, i32* %4
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @isspace(i8 signext %25)
%27 = icmp ne i32 %26, 0
%28 = xor i1 %27, true
br i1 %28, label %29, label %40
29: ; preds = %21
%30 = load i32, i32* %4
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = load i8*, i8** %2
%35 = load i32, i32* %4
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 %33, i8* %37
%38 = load i32, i32* %4
%39 = add i32 %38, 1
store i32 %39, i32* %4
br label %21
40: ; preds = %21
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [15 x i8] c"Enter server: \00"
@stdin = global i32 0
@.str.1 = [12 x i8] c"fgets error\00"
@EXIT_FAILURE = global i32 0
define void @getServer(i8* writeonly %0) {
%2 = alloca [1024 x i8]
%3 = icmp ne i8* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%7 = load i32, i32* @stdout
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stdin
%10 = call i32* @fgets(i8* %6, i32 1024, i32 %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %16, label %12
12: ; preds = %1
%13 = load i8, i8* %6
%14 = call i32 @isspace(i8 signext %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %31
16: ; preds = %1
%17 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %12, %20
%21 = phi i8* [ %27, %20 ], [ %6, %12 ]
%22 = phi i64 [ %26, %20 ], [ 0, %12 ]
%23 = load i8, i8* %21
%24 = getelementptr inbounds i8, i8* %0, i64 %22
store i8 %23, i8* %24
%25 = add nuw nsw i64 %22, 1
%26 = and i64 %25, 4294967295
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = call i32 @isspace(i8 signext %28)
%30 = icmp eq i32 %29, 0
br i1 %30, label %20, label %31
31: ; preds = %20, %12
ret void
}