#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ str_trim_space(char *);
scalar_t__ strchr(char *, char);
char *strdup(char *);
char *inputget(const char *prompt) {
  char buf[2048];
  while (1) {
    printf("%s", prompt);
    if (!fgets(buf, sizeof(buf), stdin)) {
      printf("Failed to get group.\n");
      return NULL;
    }
    if (strchr(buf, ':')) {
      printf("Colon is not a valid charactor.\n");
      continue;
    }
    if (strchr(buf, '#')) {
      printf("# is not a valid charactor.\n");
      continue;
    }
    break;
  }
  str_trim_space(buf);
  return strdup(buf);
}


x86 assembly (clang, -O0):
<inputget>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x810(%rbp),%rdi
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
mov    $0x800,%esi
call   1060 <fgets@plt>
cmp    $0x0,%eax
jne    11af <inputget+0x5f>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    122c <inputget+0xdc>
lea    -0x810(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11dd <inputget+0x8d>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    115f <inputget+0xf>
lea    -0x810(%rbp),%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     120b <inputget+0xbb>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    115f <inputget+0xf>
jmp    1210 <inputget+0xc0>
lea    -0x810(%rbp),%rdi
call   1030 <str_trim_space@plt>
lea    -0x810(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inputget>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rdi,%r14
lea    0xe85(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e5c(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%rdi
mov    $0x800,%esi
call   1070 <fgets@plt>
test   %eax,%eax
je     1226 <inputget+0xc6>
mov    %rsp,%rbx
lea    0xe85(%rip),%r13
lea    0xe62(%rip),%rbp
lea    0xe43(%rip),%r15
jmp    11e7 <inputget+0x87>
nop
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x800,%esi
call   1070 <fgets@plt>
test   %eax,%eax
je     1226 <inputget+0xc6>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1050 <strchr@plt>
mov    %r13,%rdi
test   %rax,%rax
jne    11c0 <inputget+0x60>
mov    %rbx,%rdi
mov    $0x23,%esi
call   1050 <strchr@plt>
mov    %rbp,%rdi
test   %rax,%rax
jne    11c0 <inputget+0x60>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <str_trim_space@plt>
mov    %rbx,%rdi
call   1080 <strdup@plt>
jmp    1234 <inputget+0xd4>
lea    0xdd6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
@.str.1 = [22 x i8] c"Failed to get group.\0A\00"
@.str.2 = [33 x i8] c"Colon is not a valid charactor.\0A\00"
@.str.3 = [29 x i8] c"# is not a valid charactor.\0A\00"
define i8* @inputget(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [2048 x i8]
store i8* %0, i8** %3
br label %5
5: ; preds = %1, %18, %24
%6 = load i8*, i8** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %8, i32 2048, i32 %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %2
br label %32
14: ; preds = %5
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%16 = call i64 @strchr(i8* %15, i8 signext 58)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %5
20: ; preds = %14
%21 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%22 = call i64 @strchr(i8* %21, i8 signext 35)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
br label %5
26: ; preds = %20
br label %27
27: ; preds = %26
%28 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%29 = call i32 @str_trim_space(i8* %28)
%30 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%31 = call i8* @strdup(i8* %30)
store i8* %31, i8** %2
br label %32
32: ; preds = %27, %12
%33 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
@str = [21 x i8] c"Failed to get group.\00"
@str.4 = [28 x i8] c"# is not a valid charactor.\00"
@str.5 = [32 x i8] c"Colon is not a valid charactor.\00"
define noalias i8* @inputget(i8* %0) {
%2 = alloca [2048 x i8]
%3 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %3, i32 2048, i32 %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %13, %1
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %26
10: ; preds = %1, %13
%11 = call i64 @strchr(i8* %3, i8 signext 58)
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10, %20
%14 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0), %20 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0), %10 ]
%15 = call i32 @puts(i8* dereferenceable(1) %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %3, i32 2048, i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %8, label %10
20: ; preds = %10
%21 = call i64 @strchr(i8* %3, i8 signext 35)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %13
23: ; preds = %20
%24 = call i32 @str_trim_space(i8* %3)
%25 = call i8* @strdup(i8* %3)
br label %26
26: ; preds = %23, %8
%27 = phi i8* [ %25, %23 ], [ null, %8 ]
ret i8* %27
}