#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*/ free(char *);
char *get_line(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, unsigned short *);
int /*<<< orphan*/ stdin;
char *AskForPlace(unsigned short *port) {
  char *text, *machine;
  printf("enter machine where server is running (return if same as client)\n");
  machine = get_line(stdin);
  if (*machine == '\0') {
    free(machine);
    machine = NULL;
  }
  printf("enter port number (return if 5000)\n");
  text = get_line(stdin);
  if (*text == '\0')
    *port = 5000;
  else
    sscanf(text, "%u", port);
  free(text);
  return machine;
}


x86 assembly (clang, -O0):
<AskForPlace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1040 <get_line@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    118b <AskForPlace+0x4b>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
lea    0xeb0(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
call   1040 <get_line@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11c7 <AskForPlace+0x87>
mov    -0x8(%rbp),%rax
movw   $0x1388,(%rax)
jmp    11db <AskForPlace+0x9b>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe90(%rip),%rsi
call   1060 <sscanf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AskForPlace>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e8d(%rip),%rbx
mov    (%rbx),%edi
call   1050 <get_line@plt>
mov    %rax,%r15
cmpb   $0x0,(%rax)
jne    1175 <AskForPlace+0x35>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %r15d,%r15d
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%edi
call   1050 <get_line@plt>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
je     11a4 <AskForPlace+0x64>
lea    0xe69(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1060 <sscanf@plt>
jmp    11aa <AskForPlace+0x6a>
movw   $0x1388,(%r14)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [66 x i8] c"enter machine where server is running (return if same as client)\0A\00"
@stdin = global i32 0
@.str.1 = [36 x i8] c"enter port number (return if 5000)\0A\00"
@.str.2 = [3 x i8] c"%u\00"
define i8* @AskForPlace(i16* %0) {
%2 = alloca i16*
%3 = alloca i8*
%4 = alloca i8*
store i16* %0, i16** %2
%5 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i8* @get_line(i32 %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i8*, i8** %4
%14 = call i32 @free(i8* %13)
store i8* null, i8** %4
br label %15
15: ; preds = %12, %1
%16 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stdin
%18 = call i8* @get_line(i32 %17)
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %15
%24 = load i16*, i16** %2
store i16 5000, i16* %24
br label %29
25: ; preds = %15
%26 = load i8*, i8** %3
%27 = load i16*, i16** %2
%28 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i16* %27)
br label %29
29: ; preds = %25, %23
%30 = load i8*, i8** %3
%31 = call i32 @free(i8* %30)
%32 = load i8*, i8** %4
ret i8* %32
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.2 = [3 x i8] c"%u\00"
@str = [65 x i8] c"enter machine where server is running (return if same as client)\00"
@str.3 = [35 x i8] c"enter port number (return if 5000)\00"
define i8* @AskForPlace(i16* %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%3 = load i32, i32* @stdin
%4 = tail call i8* @get_line(i32 %3)
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @free(i8* %4)
br label %9
9: ; preds = %7, %1
%10 = phi i8* [ null, %7 ], [ %4, %1 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.3, i64 0, i64 0))
%12 = load i32, i32* @stdin
%13 = tail call i8* @get_line(i32 %12)
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %9
store i16 5000, i16* %0
br label %19
17: ; preds = %9
%18 = tail call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i16* %0)
br label %19
19: ; preds = %17, %16
%20 = tail call i32 @free(i8* %13)
ret i8* %10
}