#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 sendATComm(char *, char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
int gsmSendData(char *message) {
  char temp[150];
  sprintf(temp, "AT+CIPSEND=%d", strlen(message));
  if (sendATComm(temp, ">", "ERROR", 10000) == 1)
    return sendATComm(message, "SEND OK", "ERROR", 10000);
  return 0;
}


x86 assembly (clang, -O0):
<gsmSendData>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xb8(%rbp),%rdi
mov    %eax,%edx
lea    0xe9a(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
lea    0xe95(%rip),%rsi
lea    0xe90(%rip),%rdx
mov    $0x2710,%ecx
call   1040 <sendATComm@plt>
cmp    $0x1,%eax
jne    11b7 <gsmSendData+0x87>
mov    -0x10(%rbp),%rdi
lea    0xe78(%rip),%rsi
lea    0xe6b(%rip),%rdx
mov    $0x2710,%ecx
call   1040 <sendATComm@plt>
mov    %eax,-0x4(%rbp)
jmp    11be <gsmSendData+0x8e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gsmSendData>:
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%r14
call   1030 <strlen@plt>
lea    0xeb7(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1050 <sprintf@plt>
lea    0xeb1(%rip),%rsi
lea    0xeac(%rip),%rdx
mov    %rbx,%rdi
mov    $0x2710,%ecx
call   1040 <sendATComm@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
jne    1195 <gsmSendData+0x65>
lea    0xe95(%rip),%rsi
lea    0xe88(%rip),%rdx
mov    %r14,%rdi
mov    $0x2710,%ecx
call   1040 <sendATComm@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"AT+CIPSEND=%d\00"
@.str.1 = [2 x i8] c">\00"
@.str.2 = [6 x i8] c"ERROR\00"
@.str.3 = [8 x i8] c"SEND OK\00"
define i32 @gsmSendData(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [150 x i8]
store i8* %0, i8** %3
%5 = getelementptr inbounds [150 x i8], [150 x i8]* %4, i64 0, i64 0
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [150 x i8], [150 x i8]* %4, i64 0, i64 0
%10 = call i32 @sendATComm(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 10000)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @sendATComm(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 10000)
store i32 %14, i32* %2
br label %16
15: ; preds = %1
store i32 0, i32* %2
br label %16
16: ; preds = %15, %12
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@.str = [14 x i8] c"AT+CIPSEND=%d\00"
@.str.1 = [2 x i8] c">\00"
@.str.2 = [6 x i8] c"ERROR\00"
@.str.3 = [8 x i8] c"SEND OK\00"
define i32 @gsmSendData(i8* %0) {
%2 = alloca [150 x i8]
%3 = getelementptr inbounds [150 x i8], [150 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @strlen(i8* %0)
%5 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @sendATComm(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 10000)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @sendATComm(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 10000)
br label %10
10: ; preds = %1, %8
%11 = phi i32 [ %9, %8 ], [ 0, %1 ]
ret i32 %11
}