#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 sscanf(char const *, char *, int *);
char *strchr(char const *, char);
int respcode(const char *response) {
  int resp = 0;
  int i;
  const char *respoff = response;
  if (!response) {
    return 0;
  }
  while (respoff[3] != ' ') {
    respoff = strchr(respoff, '\n');
    if (!respoff) {
      return -1;
    } else {
      respoff++;
    }
  }
  i = sscanf(respoff, "%d ", &resp);
  if (i != 1 && resp < 100) {
    return -1;
  }
  return resp;
}


x86 assembly (clang, -O0):
<respcode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1152 <respcode+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11df <respcode+0xbf>
jmp    1157 <respcode+0x37>
mov    -0x20(%rbp),%rax
movsbl 0x3(%rax),%eax
cmp    $0x20,%eax
je     11a2 <respcode+0x82>
mov    -0x20(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1191 <respcode+0x71>
movl   $0xffffffff,-0x4(%rbp)
jmp    11df <respcode+0xbf>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1157 <respcode+0x37>
mov    -0x20(%rbp),%rdi
lea    0xe53(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     11d9 <respcode+0xb9>
cmpl   $0x64,-0x14(%rbp)
jge    11d9 <respcode+0xb9>
movl   $0xffffffff,-0x4(%rbp)
jmp    11df <respcode+0xbf>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<respcode>:
push   %rax
movl   $0x0,0x4(%rsp)
test   %rdi,%rdi
je     1184 <respcode+0x64>
cmpb   $0x20,0x3(%rdi)
je     115c <respcode+0x3c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1188 <respcode+0x68>
mov    %rax,%rdi
add    $0x1,%rdi
cmpb   $0x20,0x4(%rax)
jne    1140 <respcode+0x20>
lea    0xe9d(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1040 <sscanf@plt>
mov    0x4(%rsp),%edx
cmp    $0x64,%edx
mov    $0xffffffff,%ecx
cmovge %edx,%ecx
cmp    $0x1,%eax
cmove  %edx,%ecx
jmp    118d <respcode+0x6d>
xor    %ecx,%ecx
jmp    118d <respcode+0x6d>
mov    $0xffffffff,%ecx
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
define i32 @respcode(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
%7 = load i8*, i8** %3
store i8* %7, i8** %6
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 0, i32* %2
br label %39
11: ; preds = %1
br label %12
12: ; preds = %27, %11
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 32
br i1 %17, label %18, label %28
18: ; preds = %12
%19 = load i8*, i8** %6
%20 = call i8* @strchr(i8* %19, i8 signext 10)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = icmp ne i8* %21, null
br i1 %22, label %24, label %23
23: ; preds = %18
store i32 -1, i32* %2
br label %39
24: ; preds = %18
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %6
br label %27
27: ; preds = %24
br label %12
28: ; preds = %12
%29 = load i8*, i8** %6
%30 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = icmp ne i32 %31, 1
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i32, i32* %4
%35 = icmp slt i32 %34, 100
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 -1, i32* %2
br label %39
37: ; preds = %33, %28
%38 = load i32, i32* %4
store i32 %38, i32* %2
br label %39
39: ; preds = %37, %36, %23, %10
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @respcode(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%4 = icmp eq i8* %0, null
br i1 %4, label %26, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 3
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 32
br i1 %8, label %18, label %13
9: ; preds = %13
%10 = getelementptr inbounds i8, i8* %15, i64 4
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 32
br i1 %12, label %18, label %13
13: ; preds = %5, %9
%14 = phi i8* [ %17, %9 ], [ %0, %5 ]
%15 = tail call i8* @strchr(i8* dereferenceable(1) %14, i8 signext 10)
%16 = icmp eq i8* %15, null
%17 = getelementptr inbounds i8, i8* %15, i64 1
br i1 %16, label %26, label %9
18: ; preds = %9, %5
%19 = phi i8* [ %0, %5 ], [ %17, %9 ]
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
%21 = icmp ne i32 %20, 1
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 100
%24 = select i1 %21, i1 %23, i1 false
%25 = select i1 %24, i32 -1, i32 %22
br label %26
26: ; preds = %13, %18, %1
%27 = phi i32 [ 0, %1 ], [ %25, %18 ], [ -1, %13 ]
ret i32 %27
}