#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int libSSI_parse_answer(unsigned char *buffer, unsigned char *address,
                        unsigned char *version, unsigned char *buffer_sz,
                        unsigned char *msg_delay, unsigned char *reserved) {
  if (buffer[1] != 0x41 && buffer[1] != 0x61) {
    return (-1);
  }
  address = (unsigned char *)malloc(sizeof(unsigned char));
  version = (unsigned char *)malloc(2 * sizeof(unsigned char));
  buffer_sz = (unsigned char *)malloc(2 * sizeof(unsigned char));
  msg_delay = (unsigned char *)malloc(2 * sizeof(unsigned char));
  reserved = (unsigned char *)malloc(2 * sizeof(unsigned char));
  *address = buffer[0];
  memcpy(version, &(buffer[2]), 2);
  memcpy(buffer_sz, &(buffer[4]), 2);
  memcpy(msg_delay, &(buffer[6]), 2);
  memcpy(reserved, &(buffer[8]), 2);
  return (1);
}


x86 assembly (clang, -O0):
<libSSI_parse_answer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x41,%eax
je     116e <libSSI_parse_answer+0x4e>
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
cmp    $0x61,%eax
je     116e <libSSI_parse_answer+0x4e>
movl   $0xffffffff,-0x4(%rbp)
jmp    121f <libSSI_parse_answer+0xff>
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x2,%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x4,%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x6,%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libSSI_parse_answer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x1(%rdi),%al
or     $0x20,%al
cmp    $0x61,%al
jne    11cf <libSSI_parse_answer+0xaf>
mov    %rdi,%rbx
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%rbp
mov    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%r13
mov    $0x2,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    (%rbx),%al
mov    %al,(%r15)
lea    0x2(%rbx),%rsi
mov    %rbp,%rdi
mov    $0x2,%edx
call   1030 <memcpy@plt>
lea    0x4(%rbx),%rsi
mov    %r12,%rdi
mov    $0x2,%edx
call   1030 <memcpy@plt>
lea    0x6(%rbx),%rsi
mov    %r13,%rdi
mov    $0x2,%edx
call   1030 <memcpy@plt>
add    $0x8,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
mov    $0x1,%eax
jmp    11d4 <libSSI_parse_answer+0xb4>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @libSSI_parse_answer(i8* %0, i8* nocapture readnone %1, i8* nocapture readnone %2, i8* nocapture readnone %3, i8* nocapture readnone %4, i8* nocapture readnone %5) {
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
switch i8 %8, label %29 [
i8 65, label %9
i8 97, label %9
]
9: ; preds = %6, %6
%10 = tail call i64 @malloc(i32 1)
%11 = inttoptr i64 %10 to i8*
%12 = tail call i64 @malloc(i32 2)
%13 = inttoptr i64 %12 to i8*
%14 = tail call i64 @malloc(i32 2)
%15 = inttoptr i64 %14 to i8*
%16 = tail call i64 @malloc(i32 2)
%17 = inttoptr i64 %16 to i8*
%18 = tail call i64 @malloc(i32 2)
%19 = inttoptr i64 %18 to i8*
%20 = load i8, i8* %0
store i8 %20, i8* %11
%21 = getelementptr inbounds i8, i8* %0, i64 2
%22 = tail call i32 @memcpy(i8* %13, i8* %21, i32 2)
%23 = getelementptr inbounds i8, i8* %0, i64 4
%24 = tail call i32 @memcpy(i8* %15, i8* %23, i32 2)
%25 = getelementptr inbounds i8, i8* %0, i64 6
%26 = tail call i32 @memcpy(i8* %17, i8* %25, i32 2)
%27 = getelementptr inbounds i8, i8* %0, i64 8
%28 = tail call i32 @memcpy(i8* %19, i8* %27, i32 2)
br label %29
29: ; preds = %6, %9
%30 = phi i32 [ 1, %9 ], [ -1, %6 ]
ret i32 %30
}