#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 write(int, char *, int /*<<< orphan*/);
int gprs_deal(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);
  int ret = write(fd_uart, send_num, strlen(send_num));
  printf("_____%d______\n", ret);
  usleep(100 * 1000);
  sprintf(send_msg, "%s\032\n", phone_msg);
  ret = write(fd_uart, send_msg, strlen(send_msg));
  printf("_____%d______\n", ret);
  printf("===over===\n");
  close(fd_uart);
  return 0;
}


x86 assembly (clang, -O0):
<gprs_deal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%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,-0x114(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x110(%rbp)
lea    -0x80(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x114(%rbp),%edi
mov    -0x110(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0xf4(%rbp)
mov    -0xf4(%rbp),%esi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x186a0,%edi
call   10b0 <usleep@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xdbb(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x104(%rbp)
lea    -0xf0(%rbp),%rax
mov    %rax,-0x100(%rbp)
lea    -0xf0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x104(%rbp),%edi
mov    -0x100(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0xf4(%rbp)
mov    -0xf4(%rbp),%esi
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gprs_deal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xd8,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1090 <Uart_Init@plt>
mov    %eax,%ebp
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    0xded(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%edi
call   1050 <GPRS_init@plt>
mov    $0x30d40,%edi
call   10b0 <usleep@plt>
lea    0xdd8(%rip),%rsi
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
lea    0xdbb(%rip),%r15
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x186a0,%edi
call   10b0 <usleep@plt>
lea    0xdad(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd7d(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
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 = [15 x i8] c"_____%d______\0A\00"
@.str.3 = [5 x i8] c"%s\1A\0A\00"
@.str.4 = [12 x i8] c"===over===\0A\00"
define i32 @gprs_deal(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [100 x i8]
%7 = alloca [100 x i8]
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = call i32 (...) @Uart_Init()
store i32 %9, i32* %5
%10 = bitcast [100 x i8]* %6 to i8*
%11 = bitcast [100 x i8]* %7 to i8*
%12 = load i32, i32* %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %5
%15 = call i32 @GPRS_init(i32 %14)
%16 = call i32 @usleep(i32 200000)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%18 = load i8*, i8** %3
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %5
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = call i32 @write(i32 %20, i8* %21, i32 %23)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = call i32 @usleep(i32 100000)
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%29 = load i8*, i8** %4
%30 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = load i32, i32* %5
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%34 = call i32 @strlen(i8* %33)
%35 = call i32 @write(i32 %31, i8* %32, i32 %34)
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%39 = load i32, i32* %5
%40 = call i32 @close(i32 %39)
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 = [15 x i8] c"_____%d______\0A\00"
@.str.3 = [5 x i8] c"%s\1A\0A\00"
@str = [11 x i8] c"===over===\00"
define i32 @gprs_deal(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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = call i32 @usleep(i32 100000)
%16 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%17 = call i32 @strlen(i8* %7)
%18 = call i32 @write(i32 %5, i8* %7, i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%21 = call i32 @close(i32 %5)
ret i32 0
}