#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 /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
scalar_t__ zalloc(int);
int extract_status_code(char *buffer, int size) {
  char *buf_code;
  char *begin;
  char *end = buffer + size;
  int inc = 0;
  buf_code = (char *)(zalloc(10));
  while (buffer < end && *buffer++ != ' ')
    ;
  begin = buffer;
  while (buffer < end && *buffer++ != ' ')
    inc++;
  strncat(buf_code, begin, inc);
  inc = atoi(buf_code);
  (free(buf_code), (buf_code) = NULL);
  return inc;
}


x86 assembly (clang, -O0):
<extract_status_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    $0xa,%edi
call   1060 <zalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmp    -0x28(%rbp),%rcx
mov    %al,-0x2d(%rbp)
jae    11a1 <extract_status_code+0x61>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    11b1 <extract_status_code+0x71>
jmp    11b6 <extract_status_code+0x76>
jmp    1173 <extract_status_code+0x33>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmp    -0x28(%rbp),%rcx
mov    %al,-0x2e(%rbp)
jae    11ec <extract_status_code+0xac>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x2e(%rbp)
mov    -0x2e(%rbp),%al
test   $0x1,%al
jne    11fc <extract_status_code+0xbc>
jmp    120a <extract_status_code+0xca>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11be <extract_status_code+0x7e>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1040 <strncat@plt>
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_status_code>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
movslq %esi,%rbp
add    %rdi,%rbp
mov    $0xa,%edi
call   1060 <zalloc@plt>
mov    %rax,%r14
mov    %rbx,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %rbp,%rax
jae    1183 <extract_status_code+0x43>
lea    0x1(%rax),%rsi
cmpb   $0x20,(%rax)
mov    %rsi,%rax
jne    1170 <extract_status_code+0x30>
jmp    1186 <extract_status_code+0x46>
mov    %rax,%rsi
xor    %edx,%edx
cmp    %rbp,%rsi
jae    11bb <extract_status_code+0x7b>
add    %r15d,%ebx
mov    %ebx,%edx
sub    %esi,%edx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x20,(%rsi,%rax,1)
je     11b9 <extract_status_code+0x79>
lea    (%rsi,%rax,1),%rcx
add    $0x1,%rcx
add    $0x1,%rax
cmp    %rbp,%rcx
jb     11a0 <extract_status_code+0x60>
jmp    11bb <extract_status_code+0x7b>
mov    %eax,%edx
mov    %r14,%rdi
call   1040 <strncat@plt>
mov    %r14,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @extract_status_code(i8* %0, i32 %1) {
%3 = ptrtoint i8* %0 to i64
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = tail call i64 @zalloc(i32 10)
%7 = inttoptr i64 %6 to i8*
br label %8
8: ; preds = %11, %2
%9 = phi i8* [ %0, %2 ], [ %12, %11 ]
%10 = icmp ult i8* %9, %5
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = load i8, i8* %9
%14 = icmp eq i8 %13, 32
br i1 %14, label %15, label %8
15: ; preds = %8, %11
%16 = phi i8* [ %12, %11 ], [ %9, %8 ]
%17 = icmp ult i8* %16, %5
br i1 %17, label %18, label %33
18: ; preds = %15
%19 = ptrtoint i8* %16 to i64
%20 = trunc i64 %3 to i32
%21 = add i32 %20, %1
%22 = trunc i64 %19 to i32
%23 = sub i32 %21, %22
br label %24
24: ; preds = %18, %29
%25 = phi i32 [ %31, %29 ], [ 0, %18 ]
%26 = phi i8* [ %30, %29 ], [ %16, %18 ]
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 32
br i1 %28, label %33, label %29
29: ; preds = %24
%30 = getelementptr inbounds i8, i8* %26, i64 1
%31 = add nuw nsw i32 %25, 1
%32 = icmp ult i8* %30, %5
br i1 %32, label %24, label %33
33: ; preds = %24, %29, %15
%34 = phi i32 [ 0, %15 ], [ %23, %29 ], [ %25, %24 ]
%35 = tail call i32 @strncat(i8* %7, i8* %16, i32 %34)
%36 = tail call i32 @atoi(i8* %7)
%37 = tail call i32 @free(i8* %7)
ret i32 %36
}