#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 atoi(char *);
int IRC_GetServerResponse(char *serverMessage) {
  char *currentChar = serverMessage;
  char temp[5];
  int tempPos = 0;
  int numSpacesPassed = 0;
  while (numSpacesPassed < 1) {
    if (*currentChar == ' ')
      ++numSpacesPassed;
    ++currentChar;
  }
  while (*currentChar != ' ') {
    if (*currentChar >= 0x30 && *currentChar <= 0x39) {
      temp[tempPos] = *currentChar;
      temp[tempPos + 1] = '\0';
      tempPos += 1;
    }
    ++currentChar;
  }
  return atoi(temp);
}


x86 assembly (clang, -O0):
<IRC_GetServerResponse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jge    1166 <IRC_GetServerResponse+0x56>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    1155 <IRC_GetServerResponse+0x45>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1132 <IRC_GetServerResponse+0x22>
jmp    116b <IRC_GetServerResponse+0x5b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11d0 <IRC_GetServerResponse+0xc0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     11bf <IRC_GetServerResponse+0xaf>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     11bf <IRC_GetServerResponse+0xaf>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x15(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x15(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    116b <IRC_GetServerResponse+0x5b>
lea    -0x15(%rbp),%rdi
call   1030 <atoi@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IRC_GetServerResponse>:
push   %rax
add    $0x1,%rdi
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x20,-0x1(%rdi)
lea    0x1(%rdi),%rdi
jne    1120 <IRC_GetServerResponse+0x10>
mov    -0x1(%rdi),%cl
cmp    $0x20,%cl
jne    113e <IRC_GetServerResponse+0x2e>
lea    0x3(%rsp),%rdi
call   1030 <atoi@plt>
pop    %rcx
ret
xor    %eax,%eax
jmp    115c <IRC_GetServerResponse+0x4c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rdi),%ecx
add    $0x1,%rdi
cmp    $0x20,%cl
je     1132 <IRC_GetServerResponse+0x22>
lea    -0x30(%rcx),%edx
cmp    $0x9,%dl
ja     1150 <IRC_GetServerResponse+0x40>
cltq
mov    %cl,0x3(%rsp,%rax,1)
movb   $0x0,0x4(%rsp,%rax,1)
add    $0x1,%rax
jmp    1150 <IRC_GetServerResponse+0x40>

LLVM IR (-O0):
define i32 @IRC_GetServerResponse(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [5 x i8]
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
store i8* %7, i8** %3
store i32 0, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %19, %1
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 32
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %19
19: ; preds = %16, %11
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
br label %8
22: ; preds = %8
br label %23
23: ; preds = %50, %22
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 32
br i1 %27, label %28, label %53
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp sge i32 %31, 48
br i1 %32, label %33, label %50
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp sle i32 %36, 57
br i1 %37, label %38, label %50
38: ; preds = %33
%39 = load i8*, i8** %3
%40 = load i8, i8* %39
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %42
store i8 %40, i8* %43
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %46
store i8 0, i8* %47
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %50
50: ; preds = %38, %33, %28
%51 = load i8*, i8** %3
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %3
br label %23
53: ; preds = %23
%54 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%55 = call i32 @atoi(i8* %54)
ret i32 %55
}

LLVM IR (-O2):
define i32 @IRC_GetServerResponse(i8* nocapture %0) {
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
br label %7
4: ; preds = %7
%5 = load i8, i8* %11
%6 = icmp eq i8 %5, 32
br i1 %6, label %29, label %12
7: ; preds = %1, %7
%8 = phi i8* [ %0, %1 ], [ %11, %7 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 32
%11 = getelementptr inbounds i8, i8* %8, i64 1
br i1 %10, label %4, label %7
12: ; preds = %4, %24
%13 = phi i8 [ %27, %24 ], [ %5, %4 ]
%14 = phi i32 [ %25, %24 ], [ 0, %4 ]
%15 = phi i8* [ %26, %24 ], [ %11, %4 ]
%16 = add i8 %13, -48
%17 = icmp ult i8 %16, 10
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = sext i32 %14 to i64
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %19
store i8 %13, i8* %20
%21 = add nsw i32 %14, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %18, %12
%25 = phi i32 [ %21, %18 ], [ %14, %12 ]
%26 = getelementptr inbounds i8, i8* %15, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 32
br i1 %28, label %29, label %12
29: ; preds = %24, %4
%30 = call i32 @atoi(i8* %3)
ret i32 %30
}