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

/* Variables and functions */
int atol(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ isdigit(char);
int GetResponse(FILE *ps) {
  char szLine[1024];
  char *psz;
  int hr;
  fflush(ps);
  do {
    fgets(szLine, sizeof(szLine), ps);
    for (psz = szLine; isdigit(*psz); psz++)
      ;
  } while (*psz != '\0' && *psz != ' ');
  hr = atol(szLine);
  return hr;
}


x86 assembly (clang, -O0):
<GetResponse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fflush@plt>
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11b0 <GetResponse+0x70>
jmp    1199 <GetResponse+0x59>
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    117b <GetResponse+0x3b>
jmp    11b5 <GetResponse+0x75>
mov    -0x418(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x41d(%rbp)
je     11e6 <GetResponse+0xa6>
mov    -0x418(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x41d(%rbp)
mov    -0x41d(%rbp),%al
test   $0x1,%al
jne    1158 <GetResponse+0x18>
lea    -0x410(%rbp),%rdi
call   1060 <atol@plt>
mov    %eax,-0x41c(%rbp)
mov    -0x41c(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetResponse>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%r14
call   1050 <fflush@plt>
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1180 <GetResponse+0x40>
testb  $0xdf,-0x1(%rbx)
jne    1160 <GetResponse+0x20>
mov    %rsp,%rdi
call   1060 <atol@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @GetResponse(i32* %0) {
%2 = alloca i32*
%3 = alloca [1024 x i8]
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %2
%6 = load i32*, i32** %2
%7 = call i32 @fflush(i32* %6)
br label %8
8: ; preds = %33, %1
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = load i32*, i32** %2
%11 = call i32 @fgets(i8* %9, i32 1024, i32* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i8* %12, i8** %4
br label %13
13: ; preds = %19, %8
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = call i64 @isdigit(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %13
br label %19
19: ; preds = %18
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
br label %13
22: ; preds = %13
br label %23
23: ; preds = %22
%24 = load i8*, i8** %4
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 32
br label %33
33: ; preds = %28, %23
%34 = phi i1 [ false, %23 ], [ %32, %28 ]
br i1 %34, label %8, label %35
35: ; preds = %33
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%37 = call i32 @atol(i8* %36)
store i32 %37, i32* %5
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
define i32 @GetResponse(i32* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @fflush(i32* %0)
br label %5
5: ; preds = %13, %1
%6 = call i32 @fgets(i8* %3, i32 1024, i32* %0)
br label %7
7: ; preds = %7, %5
%8 = phi i8* [ %3, %5 ], [ %12, %7 ]
%9 = load i8, i8* %8
%10 = call i64 @isdigit(i8 signext %9)
%11 = icmp eq i64 %10, 0
%12 = getelementptr inbounds i8, i8* %8, i64 1
br i1 %11, label %13, label %7
13: ; preds = %7
%14 = load i8, i8* %8
switch i8 %14, label %5 [
i8 0, label %15
i8 32, label %15
]
15: ; preds = %13, %13
%16 = call i32 @atol(i8* %3)
ret i32 %16
}