#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 exoHAL_SocketRecv(long, char *, int);
int get_http_status(long socket) {
  char rxBuf[12];
  int rxLen = 0;
  int code = 0;
  rxLen = exoHAL_SocketRecv(socket, rxBuf, 12);
  if (12 == rxLen) {
    code = (((rxBuf[9] - 0x30) * 100) + ((rxBuf[10] - 0x30) * 10) +
            (rxBuf[11] - 0x30));
    return code;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_http_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0xc,%edx
call   1030 <exoHAL_SocketRecv@plt>
mov    %eax,-0x20(%rbp)
mov    $0xc,%eax
cmp    -0x20(%rbp),%eax
jne    117a <get_http_status+0x6a>
movsbl -0x13(%rbp),%eax
sub    $0x30,%eax
imul   $0x64,%eax,%eax
movsbl -0x12(%rbp),%ecx
sub    $0x30,%ecx
imul   $0xa,%ecx,%ecx
add    %ecx,%eax
movsbl -0x11(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1181 <get_http_status+0x71>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_http_status>:
sub    $0x18,%rsp
lea    0xc(%rsp),%rsi
mov    $0xc,%edx
call   1030 <exoHAL_SocketRecv@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xc,%ecx
jne    114b <get_http_status+0x3b>
movsbl 0x15(%rsp),%eax
imul   $0x64,%eax,%eax
movsbl 0x16(%rsp),%ecx
lea    (%rcx,%rcx,4),%ecx
movsbl 0x17(%rsp),%edx
lea    (%rax,%rcx,2),%eax
add    %edx,%eax
add    $0xffffeb30,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define i32 @get_http_status(i64 %0) {
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%4 = call i32 @exoHAL_SocketRecv(i64 %0, i8* %3, i32 12)
%5 = icmp eq i32 %4, 12
br i1 %5, label %6, label %21
6: ; preds = %1
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 9
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = mul nsw i32 %9, 100
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = mul nsw i32 %13, 10
%15 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 11
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = add nsw i32 %10, -5328
%19 = add nsw i32 %18, %14
%20 = add nsw i32 %19, %17
br label %21
21: ; preds = %1, %6
%22 = phi i32 [ %20, %6 ], [ 0, %1 ]
ret i32 %22
}