#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_rest_of_line();
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void player_names(char *player1, char *player2) {
  int finished = 0;
  int finished2 = 0;
  char tempString[10 + 2];
  do {
    printf("Player 1 Enter name (1-20 Characters): ");
    fgets(tempString, 10 + 2, stdin);
    if (tempString[strlen(tempString) - 1] != '\n') {
      printf("Input was too long.\n");
      read_rest_of_line();
    } else {
      finished = 1;
    }
  } while (finished == 0);
  tempString[strlen(tempString) - 1] = '\0';
  strcpy(player1, tempString);
  do {
    printf("Player 2 Enter name (1-20 Characters): ");
    fgets(tempString, 10 + 2, stdin);
    if (tempString[strlen(tempString) - 1] != '\n') {
      printf("Input was too long.\n");
      read_rest_of_line();
    } else {
      finished2 = 1;
    }
  } while (finished2 == 0);
  tempString[strlen(tempString) - 1] = '\0';
  strcpy(player2, tempString);
}


x86 assembly (clang, -O0):
<player_names>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe8b(%rip),%rdi
call   1050 <printf@plt>
lea    -0x24(%rbp),%rdi
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
mov    $0xc,%esi
call   1060 <fgets@plt>
lea    -0x24(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x24(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     11c5 <player_names+0x75>
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <read_rest_of_line@plt>
jmp    11cc <player_names+0x7c>
movl   $0x1,-0x14(%rbp)
jmp    11d1 <player_names+0x81>
cmpl   $0x0,-0x14(%rbp)
je     116e <player_names+0x1e>
lea    -0x24(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x24(%rbp,%rax,1)
mov    -0x8(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1030 <strcpy@plt>
lea    0xe3b(%rip),%rdi
call   1050 <printf@plt>
lea    -0x24(%rbp),%rdi
mov    0x2dd6(%rip),%rax
mov    (%rax),%edx
mov    $0xc,%esi
call   1060 <fgets@plt>
lea    -0x24(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x24(%rbp,%rax,1),%eax
cmp    $0xa,%eax
je     1252 <player_names+0x102>
lea    0xde7(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <read_rest_of_line@plt>
jmp    1259 <player_names+0x109>
movl   $0x1,-0x18(%rbp)
jmp    125e <player_names+0x10e>
cmpl   $0x0,-0x18(%rbp)
je     11fb <player_names+0xab>
lea    -0x24(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x24(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<player_names>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe85(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e61(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     11f8 <player_names+0x98>
lea    0xe9c(%rip),%r12
lea    0xe45(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <read_rest_of_line@plt>
mov    %r13,%rdi
call   1060 <printf@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    11c0 <player_names+0x60>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe0f(%rip),%rdi
call   1060 <printf@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     1288 <player_names+0x128>
lea    0xe0a(%rip),%r15
lea    0xddb(%rip),%r12
nopl   (%rax)
mov    %r15,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <read_rest_of_line@plt>
mov    %r12,%rdi
call   1060 <printf@plt>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1250 <player_names+0xf0>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Player 1 Enter name (1-20 Characters): \00"
@stdin = global i32 0
@.str.1 = [21 x i8] c"Input was too long.\0A\00"
@.str.2 = [40 x i8] c"Player 2 Enter name (1-20 Characters): \00"
define void @player_names(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [12 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %26, %2
%9 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 12, i32 %11)
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %24
21: ; preds = %8
%22 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 (...) @read_rest_of_line()
br label %25
24: ; preds = %8
store i32 1, i32* %5
br label %25
25: ; preds = %24, %21
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 0
br i1 %28, label %8, label %29
29: ; preds = %26
%30 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%31 = call i32 @strlen(i8* %30)
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %33
store i8 0, i8* %34
%35 = load i8*, i8** %3
%36 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%37 = call i32 @strcpy(i8* %35, i8* %36)
br label %38
38: ; preds = %56, %29
%39 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%40 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%41 = load i32, i32* @stdin
%42 = call i32 @fgets(i8* %40, i32 12, i32 %41)
%43 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%44 = call i32 @strlen(i8* %43)
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 10
br i1 %50, label %51, label %54
51: ; preds = %38
%52 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%53 = call i32 (...) @read_rest_of_line()
br label %55
54: ; preds = %38
store i32 1, i32* %6
br label %55
55: ; preds = %54, %51
br label %56
56: ; preds = %55
%57 = load i32, i32* %6
%58 = icmp eq i32 %57, 0
br i1 %58, label %38, label %59
59: ; preds = %56
%60 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%61 = call i32 @strlen(i8* %60)
%62 = sub nsw i32 %61, 1
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %63
store i8 0, i8* %64
%65 = load i8*, i8** %4
%66 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%67 = call i32 @strcpy(i8* %65, i8* %66)
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"Player 1 Enter name (1-20 Characters): \00"
@stdin = global i32 0
@.str.2 = [40 x i8] c"Player 2 Enter name (1-20 Characters): \00"
@str.3 = [20 x i8] c"Input was too long.\00"
define void @player_names(i8* %0, i8* %1) {
%3 = alloca [12 x i8]
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %4, i32 12, i32 %6)
%8 = call i32 @strlen(i8* %4)
%9 = add nsw i32 %8, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 10
br i1 %13, label %26, label %14
14: ; preds = %2, %14
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0))
%16 = call i32 (...) @read_rest_of_line()
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @stdin
%19 = call i32 @fgets(i8* %4, i32 12, i32 %18)
%20 = call i32 @strlen(i8* %4)
%21 = add nsw i32 %20, -1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 10
br i1 %25, label %26, label %14
26: ; preds = %14, %2
%27 = call i32 @strlen(i8* %4)
%28 = add nsw i32 %27, -1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %29
store i8 0, i8* %30
%31 = call i32 @strcpy(i8* %0, i8* %4)
%32 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%33 = load i32, i32* @stdin
%34 = call i32 @fgets(i8* %4, i32 12, i32 %33)
%35 = call i32 @strlen(i8* %4)
%36 = add nsw i32 %35, -1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 10
br i1 %40, label %53, label %41
41: ; preds = %26, %41
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.3, i64 0, i64 0))
%43 = call i32 (...) @read_rest_of_line()
%44 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%45 = load i32, i32* @stdin
%46 = call i32 @fgets(i8* %4, i32 12, i32 %45)
%47 = call i32 @strlen(i8* %4)
%48 = add nsw i32 %47, -1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, 10
br i1 %52, label %53, label %41
53: ; preds = %41, %26
%54 = call i32 @strlen(i8* %4)
%55 = add nsw i32 %54, -1
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %56
store i8 0, i8* %57
%58 = call i32 @strcpy(i8* %1, i8* %4)
ret void
}