#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 *, char *);
int /*<<< orphan*/ stdin;
scalar_t__ strstr(char *, char *);
scalar_t__ strtol(char *, char **, int);
int readmaxtime(char *opponent) {
  int maxtime = 0;
  char buf[32];
  while (maxtime <= 0) {
    printf("\nEnter %s's time in seconds: ", opponent);
    fgets(buf, sizeof(buf), stdin);
    if (strstr(buf, "part"))
      return -3;
    if (strstr(buf, "quit") || strstr(buf, "exit"))
      return -4;
    maxtime = (int)strtol(buf, (char **)NULL, 10);
  }
  return maxtime;
}


x86 assembly (clang, -O0):
<readmaxtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     1204 <readmaxtime+0xc4>
mov    -0x10(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1040 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11aa <readmaxtime+0x6a>
movl   $0xfffffffd,-0x4(%rbp)
jmp    120a <readmaxtime+0xca>
lea    -0x40(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
jne    11de <readmaxtime+0x9e>
lea    -0x40(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11ea <readmaxtime+0xaa>
movl   $0xfffffffc,-0x4(%rbp)
jmp    120a <readmaxtime+0xca>
lea    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0x14(%rbp)
jmp    1153 <readmaxtime+0x13>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readmaxtime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r15
mov    %rsp,%rbx
lea    0xec3(%rip),%r12
lea    0xec1(%rip),%r13
lea    0xebf(%rip),%rbp
nopl   0x0(%rax)
lea    0xe89(%rip),%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11e4 <readmaxtime+0xa4>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strstr@plt>
mov    $0xfffffffc,%r14d
test   %rax,%rax
jne    11ea <readmaxtime+0xaa>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11ea <readmaxtime+0xaa>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%r14
test   %r14d,%r14d
jle    1170 <readmaxtime+0x30>
jmp    11ea <readmaxtime+0xaa>
mov    $0xfffffffd,%r14d
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"\0AEnter %s's time in seconds: \00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"part\00"
@.str.2 = [5 x i8] c"quit\00"
@.str.3 = [5 x i8] c"exit\00"
define i32 @readmaxtime(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [32 x i8]
store i8* %0, i8** %3
store i32 0, i32* %4
br label %6
6: ; preds = %28, %1
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 0
br i1 %8, label %9, label %32
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %12, i32 32, i32 %13)
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%16 = call i64 @strstr(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %9
store i32 -3, i32* %2
br label %34
19: ; preds = %9
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%21 = call i64 @strstr(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%25 = call i64 @strstr(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23, %19
store i32 -4, i32* %2
br label %34
28: ; preds = %23
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%30 = call i64 @strtol(i8* %29, i8** null, i32 10)
%31 = trunc i64 %30 to i32
store i32 %31, i32* %4
br label %6
32: ; preds = %6
%33 = load i32, i32* %4
store i32 %33, i32* %2
br label %34
34: ; preds = %32, %27, %18
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [30 x i8] c"\0AEnter %s's time in seconds: \00"
@stdin = global i32 0
@.str.1 = [5 x i8] c"part\00"
@.str.2 = [5 x i8] c"quit\00"
@.str.3 = [5 x i8] c"exit\00"
define i32 @readmaxtime(i8* %0) {
%2 = alloca [32 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %1, %16
%5 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %3, i32 32, i32 %6)
%8 = call i64 @strstr(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %4
%11 = call i64 @strstr(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = call i64 @strstr(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = call i64 @strtol(i8* nocapture %3, i8** null, i32 10)
%18 = trunc i64 %17 to i32
%19 = icmp slt i32 %18, 1
br i1 %19, label %4, label %20
20: ; preds = %16
%21 = trunc i64 %17 to i32
br label %22
22: ; preds = %10, %13, %4, %20
%23 = phi i32 [ %21, %20 ], [ -3, %4 ], [ -4, %13 ], [ -4, %10 ]
ret i32 %23
}