#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 *);
scalar_t__ strstr(char *, char *);
scalar_t__ strtol(char *, char **, int);
int getmaxtime() {
  int maxtime = 0;
  char str[6];
  while (!maxtime) {
    printf("\nenter cake's time in seconds: ");
    scanf("%5s", &str[0]);
    if (strstr(str, "quit"))
      return 0;
    maxtime = (int)strtol(str, (char **)NULL, 10);
  }
  return maxtime;
}


x86 assembly (clang, -O0):
<getmaxtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1165 <getmaxtime+0x25>
jmp    11c1 <getmaxtime+0x81>
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
lea    -0xe(%rbp),%rsi
lea    0xea4(%rip),%rdi
call   1050 <scanf@plt>
lea    -0xe(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1060 <strstr@plt>
cmp    $0x0,%rax
je     11a7 <getmaxtime+0x67>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <getmaxtime+0x87>
lea    -0xe(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,-0x8(%rbp)
jmp    114f <getmaxtime+0xf>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getmaxtime>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%r15
lea    0xec5(%rip),%r12
lea    0xa(%rsp),%rbx
lea    0xebd(%rip),%r13
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11a9 <getmaxtime+0x69>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
test   %eax,%eax
je     1170 <getmaxtime+0x30>
mov    %eax,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c"\0Aenter cake's time in seconds: \00"
@.str.1 = [4 x i8] c"%5s\00"
@.str.2 = [5 x i8] c"quit\00"
define i32 @getmaxtime() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [6 x i8]
store i32 0, i32* %2
br label %4
4: ; preds = %16, %0
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
%7 = xor i1 %6, true
br i1 %7, label %8, label %20
8: ; preds = %4
%9 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%13 = call i64 @strstr(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %8
store i32 0, i32* %1
br label %22
16: ; preds = %8
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%18 = call i64 @strtol(i8* %17, i8** null, i32 10)
%19 = trunc i64 %18 to i32
store i32 %19, i32* %2
br label %4
20: ; preds = %4
%21 = load i32, i32* %2
store i32 %21, i32* %1
br label %22
22: ; preds = %20, %15
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [32 x i8] c"\0Aenter cake's time in seconds: \00"
@.str.1 = [4 x i8] c"%5s\00"
@.str.2 = [5 x i8] c"quit\00"
define i32 @getmaxtime() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %8
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = call i64 @strstr(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %3
%9 = call i64 @strtol(i8* nocapture %2, i8** null, i32 10)
%10 = trunc i64 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %3, label %12
12: ; preds = %8
%13 = trunc i64 %9 to i32
br label %14
14: ; preds = %3, %12
%15 = phi i32 [ %13, %12 ], [ 0, %3 ]
ret i32 %15
}