#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*/ str_i;

/* Variables and functions */
scalar_t__ exist_argument(char *);
char getchar();
int /*<<< orphan*/ log_print_int(int);
int /*<<< orphan*/ log_print_str(char *);
int /*<<< orphan*/ log_println_str(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int get_nb_teams() {
  int i;
  char str_i[33];
  int result = 0;
  char c;
  for (i = 1; i <= 6; ++i) {
    {
      {
        memset(((str_i)), 0, (sizeof(str_i)));
        snprintf(((str_i)), (sizeof(str_i)) - 1, (("%d")), ((i)));
        ((str_i))[(sizeof(str_i)) - 1] = '\0';
      };
    };
    if (exist_argument(str_i)) {
      result = i;
    }
  }
  if (result < 2 || result > 6) {
    log_print_str("How many teams will connect to this server? ");
    while ((c = getchar()) == '\n')
      ;
    if (c >= '2' && c <= '0' + 6) {
      result = c - '0';
      log_print_str("Use \"-");
      log_print_int(result);
      log_println_str("\" to get rid of this question.");
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<get_nb_teams>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x34(%rbp)
movl   $0x1,-0x4(%rbp)
cmpl   $0x6,-0x4(%rbp)
jg     11e8 <get_nb_teams+0x78>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0x20,%esi
lea    0xe4d(%rip),%rdx
call   1030 <snprintf@plt>
movb   $0x0,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
call   1060 <exist_argument@plt>
cmp    $0x0,%rax
je     11d5 <get_nb_teams+0x65>
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    11da <get_nb_teams+0x6a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <get_nb_teams+0x16>
cmpl   $0x2,-0x34(%rbp)
jl     11fc <get_nb_teams+0x8c>
cmpl   $0x6,-0x34(%rbp)
jle    126c <get_nb_teams+0xfc>
lea    0xe00(%rip),%rdi
call   1070 <log_print_str@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x35(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
jne    1223 <get_nb_teams+0xb3>
jmp    1208 <get_nb_teams+0x98>
movsbl -0x35(%rbp),%eax
cmp    $0x32,%eax
jl     1267 <get_nb_teams+0xf7>
movsbl -0x35(%rbp),%eax
cmp    $0x36,%eax
jg     1267 <get_nb_teams+0xf7>
movsbl -0x35(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x34(%rbp)
lea    0xde2(%rip),%rdi
call   1070 <log_print_str@plt>
mov    -0x34(%rbp),%edi
call   1080 <log_print_int@plt>
lea    0xdd5(%rip),%rdi
call   1090 <log_println_str@plt>
jmp    126c <get_nb_teams+0xfc>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_nb_teams>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1040 <memset@plt>
lea    0xe6d(%rip),%r15
mov    %r14,%rdi
mov    $0x20,%esi
mov    %r15,%rdx
mov    $0x1,%ecx
call   1030 <snprintf@plt>
movb   $0x0,0x20(%rsp)
mov    %r14,%rdi
call   1060 <exist_argument@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1040 <memset@plt>
mov    $0x2,%ebp
mov    %r14,%rdi
mov    $0x20,%esi
mov    %r15,%rdx
mov    $0x2,%ecx
call   1030 <snprintf@plt>
movb   $0x0,0x20(%rsp)
mov    %r14,%rdi
call   1060 <exist_argument@plt>
test   %rax,%rax
cmovne %ebp,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1040 <memset@plt>
mov    $0x3,%ebp
mov    %r14,%rdi
mov    $0x20,%esi
mov    %r15,%rdx
mov    $0x3,%ecx
call   1030 <snprintf@plt>
movb   $0x0,0x20(%rsp)
mov    %r14,%rdi
call   1060 <exist_argument@plt>
test   %rax,%rax
cmovne %ebp,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1040 <memset@plt>
mov    $0x4,%ebp
mov    %r14,%rdi
mov    $0x20,%esi
mov    %r15,%rdx
mov    $0x4,%ecx
call   1030 <snprintf@plt>
movb   $0x0,0x20(%rsp)
mov    %r14,%rdi
call   1060 <exist_argument@plt>
test   %rax,%rax
cmovne %ebp,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1040 <memset@plt>
mov    $0x5,%ebp
mov    %r14,%rdi
mov    $0x20,%esi
mov    %r15,%rdx
mov    $0x5,%ecx
call   1030 <snprintf@plt>
movb   $0x0,0x20(%rsp)
mov    %r14,%rdi
call   1060 <exist_argument@plt>
test   %rax,%rax
cmovne %ebp,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1040 <memset@plt>
mov    $0x6,%ebp
mov    %r14,%rdi
mov    $0x20,%esi
mov    %r15,%rdx
mov    $0x6,%ecx
call   1030 <snprintf@plt>
movb   $0x0,0x20(%rsp)
mov    %r14,%rdi
call   1060 <exist_argument@plt>
test   %rax,%rax
cmovne %ebp,%ebx
cmp    $0x1,%ebx
ja     1338 <get_nb_teams+0x1c8>
lea    0xd0e(%rip),%rdi
call   1070 <log_print_str@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1300 <get_nb_teams+0x190>
lea    -0x32(%rax),%ecx
cmp    $0x4,%cl
ja     1338 <get_nb_teams+0x1c8>
movzbl %al,%ebx
add    $0xffffffd0,%ebx
lea    0xd10(%rip),%rdi
call   1070 <log_print_str@plt>
mov    %ebx,%edi
call   1080 <log_print_int@plt>
lea    0xd04(%rip),%rdi
call   1090 <log_println_str@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [45 x i8] c"How many teams will connect to this server? \00"
@.str.2 = [7 x i8] c"Use \22-\00"
@.str.3 = [31 x i8] c"\22 to get rid of this question.\00"
define i32 @get_nb_teams() {
%1 = alloca i32
%2 = alloca [33 x i8]
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %3
store i32 1, i32* %1
br label %5
5: ; preds = %21, %0
%6 = load i32, i32* %1
%7 = icmp sle i32 %6, 6
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i32 0, i32 33)
%11 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 0
%12 = load i32, i32* %1
%13 = call i32 @snprintf(i8* %11, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 32
store i8 0, i8* %14
%15 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 0
%16 = call i64 @exist_argument(i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %8
%19 = load i32, i32* %1
store i32 %19, i32* %3
br label %20
20: ; preds = %18, %8
br label %21
21: ; preds = %20
%22 = load i32, i32* %1
%23 = add nsw i32 %22, 1
store i32 %23, i32* %1
br label %5
24: ; preds = %5
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 2
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 6
br i1 %29, label %30, label %54
30: ; preds = %27, %24
%31 = call i32 @log_print_str(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %36, %30
%33 = call signext i8 (...) @getchar()
store i8 %33, i8* %4
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %37
36: ; preds = %32
br label %32
37: ; preds = %32
%38 = load i8, i8* %4
%39 = sext i8 %38 to i32
%40 = icmp sge i32 %39, 50
br i1 %40, label %41, label %53
41: ; preds = %37
%42 = load i8, i8* %4
%43 = sext i8 %42 to i32
%44 = icmp sle i32 %43, 54
br i1 %44, label %45, label %53
45: ; preds = %41
%46 = load i8, i8* %4
%47 = sext i8 %46 to i32
%48 = sub nsw i32 %47, 48
store i32 %48, i32* %3
%49 = call i32 @log_print_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%50 = load i32, i32* %3
%51 = call i32 @log_print_int(i32 %50)
%52 = call i32 @log_println_str(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %45, %41, %37
br label %54
54: ; preds = %53, %27
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [45 x i8] c"How many teams will connect to this server? \00"
@.str.2 = [7 x i8] c"Use \22-\00"
@.str.3 = [31 x i8] c"\22 to get rid of this question.\00"
define i32 @get_nb_teams() {
%1 = alloca [33 x i8]
%2 = getelementptr inbounds [33 x i8], [33 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [33 x i8], [33 x i8]* %1, i64 0, i64 32
%4 = call i32 @memset(i8* %2, i32 0, i32 33)
%5 = call i32 @snprintf(i8* %2, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 1)
store i8 0, i8* %3
%6 = call i64 @exist_argument(i8* %2)
%7 = icmp ne i64 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @memset(i8* %2, i32 0, i32 33)
%10 = call i32 @snprintf(i8* %2, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
store i8 0, i8* %3
%11 = call i64 @exist_argument(i8* %2)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i32 %8, i32 2
%14 = call i32 @memset(i8* %2, i32 0, i32 33)
%15 = call i32 @snprintf(i8* %2, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 3)
store i8 0, i8* %3
%16 = call i64 @exist_argument(i8* %2)
%17 = icmp eq i64 %16, 0
%18 = select i1 %17, i32 %13, i32 3
%19 = call i32 @memset(i8* %2, i32 0, i32 33)
%20 = call i32 @snprintf(i8* %2, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 4)
store i8 0, i8* %3
%21 = call i64 @exist_argument(i8* %2)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i32 %18, i32 4
%24 = call i32 @memset(i8* %2, i32 0, i32 33)
%25 = call i32 @snprintf(i8* %2, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 5)
store i8 0, i8* %3
%26 = call i64 @exist_argument(i8* %2)
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i32 %23, i32 5
%29 = call i32 @memset(i8* %2, i32 0, i32 33)
%30 = call i32 @snprintf(i8* %2, i32 32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 6)
store i8 0, i8* %3
%31 = call i64 @exist_argument(i8* %2)
%32 = icmp eq i64 %31, 0
%33 = select i1 %32, i32 %28, i32 6
%34 = icmp ult i32 %33, 2
br i1 %34, label %35, label %49
35: ; preds = %0
%36 = call i32 @log_print_str(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %37, %35
%38 = call signext i8 (...) @getchar()
%39 = icmp eq i8 %38, 10
br i1 %39, label %37, label %40
40: ; preds = %37
%41 = add i8 %38, -50
%42 = icmp ult i8 %41, 5
br i1 %42, label %43, label %49
43: ; preds = %40
%44 = zext i8 %38 to i32
%45 = add nsw i32 %44, -48
%46 = call i32 @log_print_str(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 @log_print_int(i32 %45)
%48 = call i32 @log_println_str(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %40, %43, %0
%50 = phi i32 [ %45, %43 ], [ %33, %40 ], [ %33, %0 ]
ret i32 %50
}