#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 O_CREAT;
int O_RDWR;
int Uart_Init();
int /*<<< orphan*/ close(int);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ strlen(char *);
scalar_t__ time(int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int gprs_login_num_send(char *phone_num) {
  int fd_uart = Uart_Init();
  char send_num[100] = {0};
  char send_msg[100] = {0};
  char phone_msg[256] = {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);
  srand((int)time(0));
  int login_num = rand() % (1000000);
  int fd_login = open("./login_num_log", O_CREAT | O_RDWR);
  if (fd_login < 0) {
    perror("open");
    return 0;
  }
  sprintf(phone_msg, "%s:%d", phone_num, login_num);
  write(fd_login, phone_msg, strlen(phone_msg));
  sprintf(send_msg, "%d\032\n", login_num);
  write(fd_uart, send_msg, strlen(send_msg));
  printf("===over===\n");
  close(fd_uart);
  return 0;
}


x86 assembly (clang, -O0):
<gprs_login_num_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   10b0 <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>
lea    -0x1f0(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
mov    -0x14(%rbp),%esi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1040 <GPRS_init@plt>
mov    $0x30d40,%edi
call   1100 <usleep@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xdab(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x204(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x200(%rbp)
lea    -0x80(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x204(%rbp),%edi
mov    -0x200(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    $0x186a0,%edi
call   1100 <usleep@plt>
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
mov    $0x0,%al
call   10f0 <rand@plt>
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1f4(%rbp)
mov    0x2d2b(%rip),%rax
mov    (%rax),%esi
mov    0x2d0a(%rip),%rax
or     (%rax),%esi
lea    0xd3b(%rip),%rdi
call   10c0 <open@plt>
mov    %eax,-0x1f8(%rbp)
cmpl   $0x0,-0x1f8(%rbp)
jge    130f <gprs_login_num_send+0x12f>
lea    0xd2c(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    13d7 <gprs_login_num_send+0x1f7>
lea    -0x1f0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x1f4(%rbp),%ecx
lea    0xd08(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x1f8(%rbp),%eax
mov    %eax,-0x224(%rbp)
lea    -0x1f0(%rbp),%rax
mov    %rax,-0x220(%rbp)
lea    -0x1f0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x224(%rbp),%edi
mov    -0x220(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x1f4(%rbp),%edx
lea    0xcb9(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x214(%rbp)
lea    -0xf0(%rbp),%rax
mov    %rax,-0x210(%rbp)
lea    -0xf0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x214(%rbp),%edi
mov    -0x210(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xc79(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gprs_login_num_send>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1e0,%rsp
mov    %rdi,%r14
xor    %eax,%eax
call   10b0 <Uart_Init@plt>
mov    %eax,%r15d
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)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
lea    0xd1d(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15d,%edi
call   1050 <GPRS_init@plt>
mov    $0x30d40,%edi
call   1100 <usleep@plt>
lea    0xd07(%rip),%rsi
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   10e0 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    $0x186a0,%edi
call   1100 <usleep@plt>
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
xor    %eax,%eax
call   10f0 <rand@plt>
mov    %eax,%ebx
mov    0x2ca4(%rip),%rax
mov    0x2c85(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xcb4(%rip),%rdi
call   10c0 <open@plt>
test   %eax,%eax
js     1419 <gprs_login_num_send+0x239>
mov    %eax,%r12d
movslq %ebx,%rbx
imul   $0x431bde83,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x32,%rax
add    %ecx,%eax
imul   $0xf4240,%eax,%eax
sub    %eax,%ebx
lea    0xc93(%rip),%rsi
lea    0xe0(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   10e0 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
lea    0xc66(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   10e0 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
lea    0xc40(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x1e0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc0a(%rip),%rdi
call   10d0 <perror@plt>
jmp    1407 <gprs_login_num_send+0x227>

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 = [16 x i8] c"./login_num_log\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@.str.3 = [5 x i8] c"open\00"
@.str.4 = [6 x i8] c"%s:%d\00"
@.str.5 = [5 x i8] c"%d\1A\0A\00"
@.str.6 = [12 x i8] c"===over===\0A\00"
define i32 @gprs_login_num_send(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
%7 = alloca [256 x i8]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
%10 = call i32 (...) @Uart_Init()
store i32 %10, i32* %4
%11 = bitcast [100 x i8]* %5 to i8*
%12 = bitcast [100 x i8]* %6 to i8*
%13 = bitcast [256 x i8]* %7 to i8*
%14 = load i32, i32* %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %4
%17 = call i32 @GPRS_init(i32 %16)
%18 = call i32 @usleep(i32 200000)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%20 = load i8*, i8** %3
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* %4
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
%26 = call i32 @write(i32 %22, i8* %23, i32 %25)
%27 = call i32 @usleep(i32 100000)
%28 = call i64 @time(i32 0)
%29 = trunc i64 %28 to i32
%30 = call i32 @srand(i32 %29)
%31 = call i32 (...) @rand()
%32 = srem i32 %31, 1000000
store i32 %32, i32* %8
%33 = load i32, i32* @O_CREAT
%34 = load i32, i32* @O_RDWR
%35 = or i32 %33, %34
%36 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %35)
store i32 %36, i32* %9
%37 = load i32, i32* %9
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %1
%40 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
br label %62
41: ; preds = %1
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%43 = load i8*, i8** %3
%44 = load i32, i32* %8
%45 = call i32 (i8*, i8*, ...) @sprintf(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %43, i32 %44)
%46 = load i32, i32* %9
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%49 = call i32 @strlen(i8* %48)
%50 = call i32 @write(i32 %46, i8* %47, i32 %49)
%51 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%52 = load i32, i32* %8
%53 = call i32 (i8*, i8*, ...) @sprintf(i8* %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %4
%55 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%57 = call i32 @strlen(i8* %56)
%58 = call i32 @write(i32 %54, i8* %55, i32 %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%60 = load i32, i32* %4
%61 = call i32 @close(i32 %60)
store i32 0, i32* %2
br label %62
62: ; preds = %41, %39
%63 = load i32, i32* %2
ret i32 %63
}

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 = [16 x i8] c"./login_num_log\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@.str.3 = [5 x i8] c"open\00"
@.str.4 = [6 x i8] c"%s:%d\00"
@.str.5 = [5 x i8] c"%d\1A\0A\00"
@str = [11 x i8] c"===over===\00"
define i32 @gprs_login_num_send(i8* %0) {
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca [256 x i8]
%5 = tail call i32 (...) @Uart_Init()
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5)
%10 = tail call i32 @GPRS_init(i32 %5)
%11 = tail call i32 @usleep(i32 200000)
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%13 = call i32 @strlen(i8* %6)
%14 = call i32 @write(i32 %5, i8* %6, i32 %13)
%15 = call i32 @usleep(i32 100000)
%16 = call i64 @time(i32 0)
%17 = trunc i64 %16 to i32
%18 = call i32 @srand(i32 %17)
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 1000000
%21 = load i32, i32* @O_CREAT
%22 = load i32, i32* @O_RDWR
%23 = or i32 %22, %21
%24 = call i32 @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %1
%27 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %37
28: ; preds = %1
%29 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %0, i32 %20)
%30 = call i32 @strlen(i8* %8)
%31 = call i32 @write(i32 %24, i8* %8, i32 %30)
%32 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%33 = call i32 @strlen(i8* %7)
%34 = call i32 @write(i32 %5, i8* %7, i32 %33)
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%36 = call i32 @close(i32 %5)
br label %37
37: ; preds = %28, %26
ret i32 0
}