#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*/ cWriteData;

/* Variables and functions */
int /*<<< orphan*/ bzero(char **, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ stdout;
int strlen(char *);
int write(int, char *, int);
int SendString(int iPort, char *string) {
  char cWriteData[100];
  int iBytes = 0;
  int iBytesIn = 0;
  char azucReadBuffer[1024];
  bzero(&cWriteData, sizeof(cWriteData));
  sprintf(cWriteData, string);
  fprintf(stdout, "%s Tx: %s\n", "[Novatel Store]", string);
  iBytes = write(iPort, string, strlen(string));
  if (iBytes < 0) {
    perror("write()");
  }
  write(iPort, "\r\n", 2);
  return iBytes;
}


x86 assembly (clang, -O0):
<SendString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4a0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
mov    $0x64,%esi
call   1070 <bzero@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <sprintf@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rcx
lea    0xe4b(%rip),%rsi
lea    0xe4f(%rip),%rdx
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x49c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x498(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x49c(%rbp),%edi
mov    -0x498(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    1211 <SendString+0xb1>
lea    0xe0f(%rip),%rdi
call   1060 <perror@plt>
mov    -0x4(%rbp),%edi
lea    0xe08(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    -0x84(%rbp),%eax
add    $0x4a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SendString>:
push   %rbp
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
mov    %rsp,%rdi
call   1070 <sprintf@plt>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
lea    0xe91(%rip),%rdx
mov    %rbp,%rcx
call   1050 <fprintf@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,%ebp
test   %eax,%eax
js     11b8 <SendString+0x68>
lea    0xe80(%rip),%rsi
mov    %ebx,%edi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %ebp,%eax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe5c(%rip),%rdi
call   1060 <perror@plt>
jmp    119c <SendString+0x4c>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [11 x i8] c"%s Tx: %s\0A\00"
@.str.1 = [16 x i8] c"[Novatel Store]\00"
@.str.2 = [8 x i8] c"write()\00"
@.str.3 = [3 x i8] c"\0D\0A\00"
define i32 @SendString(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [100 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1024 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %6
store i32 0, i32* %7
%9 = bitcast [100 x i8]* %5 to i8**
%10 = call i32 @bzero(i8** %9, i32 100)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%12 = load i8*, i8** %4
%13 = call i32 @sprintf(i8* %11, i8* %12)
%14 = load i32, i32* @stdout
%15 = load i8*, i8** %4
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %3
%18 = load i8*, i8** %4
%19 = load i8*, i8** %4
%20 = call i32 @strlen(i8* %19)
%21 = call i32 @write(i32 %17, i8* %18, i32 %20)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %2
%25 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %2
%27 = load i32, i32* %3
%28 = call i32 @write(i32 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%29 = load i32, i32* %6
ret i32 %29
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [11 x i8] c"%s Tx: %s\0A\00"
@.str.1 = [16 x i8] c"[Novatel Store]\00"
@.str.2 = [8 x i8] c"write()\00"
@.str.3 = [3 x i8] c"\0D\0A\00"
define i32 @SendString(i32 %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) %1)
%6 = load i32, i32* @stdout
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%8 = tail call i32 @strlen(i8* %1)
%9 = tail call i32 @write(i32 %0, i8* %1, i32 %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
ret i32 %9
}