#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int at_cmd(int /*<<< orphan*/ *, char *, char *, char const *);
int /*<<< orphan*/ at_parse_message(int /*<<< orphan*/ *, size_t);
int sscanf(char *, char *, size_t *, size_t *);
int at_parse_message_storage(FILE *fp, const char *name) {
  char buf[0x1000];
  size_t i, msgnum, size;
  if (at_cmd(fp, buf, "+CPMS=%s", name) != 1)
    return -1;
  do {
  } while (1 != 1);
  ;
  if (sscanf(buf, "+CPMS: %u,%u", &msgnum, &size) != 2)
    return -1;
  for (i = 1; i <= msgnum; i++)
    at_parse_message(fp, i);
  return 0;
}


x86 assembly (clang, -O0):
<at_parse_message_storage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
mov    -0x18(%rbp),%rcx
lea    0xea7(%rip),%rdx
call   1030 <at_cmd@plt>
cmp    $0x1,%eax
je     1173 <at_parse_message_storage+0x43>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <at_parse_message_storage+0xd0>
jmp    1178 <at_parse_message_storage+0x48>
jmp    117d <at_parse_message_storage+0x4d>
lea    -0x1020(%rbp),%rdi
lea    0xe7e(%rip),%rsi
lea    -0x1030(%rbp),%rdx
lea    -0x1038(%rbp),%rcx
call   1040 <sscanf@plt>
cmp    $0x2,%eax
je     11b3 <at_parse_message_storage+0x83>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <at_parse_message_storage+0xd0>
movq   $0x1,-0x1028(%rbp)
mov    -0x1028(%rbp),%rax
cmp    -0x1030(%rbp),%rax
ja     11f9 <at_parse_message_storage+0xc9>
mov    -0x10(%rbp),%rdi
mov    -0x1028(%rbp),%rsi
call   1050 <at_parse_message@plt>
mov    -0x1028(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1028(%rbp)
jmp    11be <at_parse_message_storage+0x8e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<at_parse_message_storage>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1010,%rsp
mov    %rsi,%rcx
mov    %rdi,%rbx
lea    0xeb8(%rip),%rdx
lea    0x10(%rsp),%rsi
call   1030 <at_cmd@plt>
mov    $0xffffffff,%r14d
cmp    $0x1,%eax
jne    11a5 <at_parse_message_storage+0x75>
lea    0xea5(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %rsp,%rdx
lea    0x8(%rsp),%rcx
call   1040 <sscanf@plt>
cmp    $0x2,%eax
jne    11a5 <at_parse_message_storage+0x75>
xor    %r14d,%r14d
cmpq   $0x0,(%rsp)
je     11a5 <at_parse_message_storage+0x75>
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <at_parse_message@plt>
add    $0x1,%rbp
cmp    (%rsp),%rbp
jbe    1190 <at_parse_message_storage+0x60>
mov    %r14d,%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"+CPMS=%s\00"
@.str.1 = [13 x i8] c"+CPMS: %u,%u\00"
define i32 @at_parse_message_storage(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca [4096 x i8]
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i32* %0, i32** %4
store i8* %1, i8** %5
%10 = load i32*, i32** %4
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%12 = load i8*, i8** %5
%13 = call i32 @at_cmd(i32* %10, i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %2
store i32 -1, i32* %3
br label %36
16: ; preds = %2
br label %17
17: ; preds = %16
br label %18
18: ; preds = %17
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64* %8, i64* %9)
%21 = icmp ne i32 %20, 2
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 -1, i32* %3
br label %36
23: ; preds = %18
store i64 1, i64* %7
br label %24
24: ; preds = %32, %23
%25 = load i64, i64* %7
%26 = load i64, i64* %8
%27 = icmp ule i64 %25, %26
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = load i32*, i32** %4
%30 = load i64, i64* %7
%31 = call i32 @at_parse_message(i32* %29, i64 %30)
br label %32
32: ; preds = %28
%33 = load i64, i64* %7
%34 = add i64 %33, 1
store i64 %34, i64* %7
br label %24
35: ; preds = %24
store i32 0, i32* %3
br label %36
36: ; preds = %35, %22, %15
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [9 x i8] c"+CPMS=%s\00"
@.str.1 = [13 x i8] c"+CPMS: %u,%u\00"
define i32 @at_parse_message_storage(i32* %0, i8* %1) {
%3 = alloca [4096 x i8]
%4 = alloca i64
%5 = alloca i64
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = bitcast i64* %4 to i8*
%8 = bitcast i64* %5 to i8*
%9 = call i32 @at_cmd(i32* %0, i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %23
11: ; preds = %2
%12 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64* %4, i64* %5)
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i64, i64* %4
%16 = icmp eq i64 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %14, %17
%18 = phi i64 [ %20, %17 ], [ 1, %14 ]
%19 = call i32 @at_parse_message(i32* %0, i64 %18)
%20 = add i64 %18, 1
%21 = load i64, i64* %4
%22 = icmp ugt i64 %20, %21
br i1 %22, label %23, label %17
23: ; preds = %17, %14, %11, %2
%24 = phi i32 [ -1, %2 ], [ -1, %11 ], [ 0, %14 ], [ 0, %17 ]
ret i32 %24
}