#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char **);
int whoStarts() {
  char buf[10];
  printf("Will this program start as the SERVER or RECEIVER? (Please input "
         "one): ");
  scanf("%s", &buf);
  if (buf[0] == 'S') {
    return 0;
  } else if (buf[0] == 'R') {
    return 1;
  }
  return -1;
}


x86 assembly (clang, -O0):
<whoStarts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    -0xe(%rbp),%rsi
lea    0xf09(%rip),%rdi
call   1040 <scanf@plt>
movsbl -0xe(%rbp),%eax
cmp    $0x53,%eax
jne    115d <whoStarts+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    1182 <whoStarts+0x62>
movsbl -0xe(%rbp),%eax
cmp    $0x52,%eax
jne    1176 <whoStarts+0x56>
movl   $0x1,-0x4(%rbp)
jmp    1182 <whoStarts+0x62>
jmp    117b <whoStarts+0x5b>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<whoStarts>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xf11(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xe(%rsp),%cl
xor    %eax,%eax
cmp    $0x52,%cl
sete   %al
lea    (%rax,%rax,1),%edx
add    $0xffffffff,%edx
xor    %eax,%eax
cmp    $0x53,%cl
cmovne %edx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [72 x i8] c"Will this program start as the SERVER or RECEIVER? (Please input one): \00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @whoStarts() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [10 x i8]* %2 to i8**
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %4)
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 83
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 0, i32* %1
br label %19
11: ; preds = %0
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 82
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 1, i32* %1
br label %19
17: ; preds = %11
br label %18
18: ; preds = %17
store i32 -1, i32* %1
br label %19
19: ; preds = %18, %16, %10
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [72 x i8] c"Will this program start as the SERVER or RECEIVER? (Please input one): \00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @whoStarts() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [10 x i8]* %1 to i8**
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %4)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 82
%8 = select i1 %7, i32 1, i32 -1
%9 = icmp eq i8 %6, 83
%10 = select i1 %9, i32 0, i32 %8
ret i32 %10
}