#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 /*<<< orphan*/ GPRS_init(int);
int Uart_Init();
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int gprs_msg_send(char *phone_num, char *phone_msg) {
  int fd_uart = Uart_Init();
  char send_num[100] = {0};
  char send_msg[100] = {0};
  printf("fd_uart=%d\n", fd_uart);
  GPRS_init(fd_uart);
  usleep(200 * 1000);
  sprintf(send_num, "AT+CMGS=\"%s\"\n", phone_num);
  write(fd_uart, send_num, strlen(send_num));
  usleep(100 * 1000);
  sprintf(send_msg, "%s\032\n", phone_msg);
  write(fd_uart, send_msg, strlen(send_msg));
  printf("===over===\n");
  close(fd_uart);
  return 0;
}


x86 assembly (clang, -O0):
<gprs_msg_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1090 <Uart_Init@plt>
mov    %eax,-0x14(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <memset@plt>
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <memset@plt>
mov    -0x14(%rbp),%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <GPRS_init@plt>
mov    $0x30d40,%edi
call   10b0 <usleep@plt>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe0a(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10c(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x108(%rbp)
lea    -0x80(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x10c(%rbp),%edi
mov    -0x108(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x186a0,%edi
call   10b0 <usleep@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xdc6(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0xfc(%rbp)
lea    -0xf0(%rbp),%rax
mov    %rax,-0xf8(%rbp)
lea    -0xf0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xfc(%rbp),%edi
mov    -0xf8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gprs_msg_send>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1090 <Uart_Init@plt>
mov    %eax,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xdec(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebx,%edi
call   1050 <GPRS_init@plt>
mov    $0x30d40,%edi
call   10b0 <usleep@plt>
lea    0xdd7(%rip),%rsi
lea    0x70(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rdx
call   10a0 <sprintf@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    $0x186a0,%edi
call   10b0 <usleep@plt>
lea    0xdb0(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rdx
call   10a0 <sprintf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <write@plt>
lea    0xd8c(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"fd_uart=%d\0A\00"
@.str.1 = [14 x i8] c"AT+CMGS=\22%s\22\0A\00"
@.str.2 = [5 x i8] c"%s\1A\0A\00"
@.str.3 = [12 x i8] c"===over===\0A\00"
define i32 @gprs_msg_send(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i32 (...) @Uart_Init()
store i32 %8, i32* %5
%9 = bitcast [100 x i8]* %6 to i8*
%10 = bitcast [100 x i8]* %7 to i8*
%11 = load i32, i32* %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %5
%14 = call i32 @GPRS_init(i32 %13)
%15 = call i32 @usleep(i32 200000)
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %3
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i32, i32* %5
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = call i32 @write(i32 %19, i8* %20, i32 %22)
%24 = call i32 @usleep(i32 100000)
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%26 = load i8*, i8** %4
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %26)
%28 = load i32, i32* %5
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%31 = call i32 @strlen(i8* %30)
%32 = call i32 @write(i32 %28, i8* %29, i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* %5
%35 = call i32 @close(i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"fd_uart=%d\0A\00"
@.str.1 = [14 x i8] c"AT+CMGS=\22%s\22\0A\00"
@.str.2 = [5 x i8] c"%s\1A\0A\00"
@str = [11 x i8] c"===over===\00"
define i32 @gprs_msg_send(i8* %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = tail call i32 (...) @Uart_Init()
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5)
%9 = tail call i32 @GPRS_init(i32 %5)
%10 = tail call i32 @usleep(i32 200000)
%11 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = call i32 @strlen(i8* %6)
%13 = call i32 @write(i32 %5, i8* %6, i32 %12)
%14 = call i32 @usleep(i32 100000)
%15 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%16 = call i32 @strlen(i8* %7)
%17 = call i32 @write(i32 %5, i8* %7, i32 %16)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%19 = call i32 @close(i32 %5)
ret i32 0
}