#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*/ Modem_SendCmd(int, char *, int);
int /*<<< orphan*/ Modem_WaitResponse(int, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *);
void SMS_SetFunction(int fd) {
  char cmd[256];
  memset(cmd, 0, 256);
  sprintf(cmd, "AT+CNMI=2,1,0,0,0\r");
  Modem_SendCmd(fd, cmd, 5);
  Modem_WaitResponse(fd, "OK", 5);
  memset(cmd, 0, 256);
  sprintf(cmd, "AT+CMGF=1\r");
  Modem_SendCmd(fd, cmd, 5);
  Modem_WaitResponse(fd, "OK", 5);
  memset(cmd, 0, 256);
  sprintf(cmd, "AT+CPMS=\"SM\",\"SM\",\"SM\"\r");
  Modem_SendCmd(fd, cmd, 5);
  Modem_WaitResponse(fd, "OK", 5);
  return;
}


x86 assembly (clang, -O0):
<SMS_SetFunction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
lea    -0x110(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x5,%edx
call   1040 <Modem_SendCmd@plt>
mov    -0x4(%rbp),%edi
lea    0xe81(%rip),%rsi
mov    $0x5,%edx
call   1050 <Modem_WaitResponse@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
lea    -0x110(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x5,%edx
call   1040 <Modem_SendCmd@plt>
mov    -0x4(%rbp),%edi
lea    0xe33(%rip),%rsi
mov    $0x5,%edx
call   1050 <Modem_WaitResponse@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
lea    -0x110(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x5,%edx
call   1040 <Modem_SendCmd@plt>
mov    -0x4(%rbp),%edi
lea    0xde5(%rip),%rsi
mov    $0x5,%edx
call   1050 <Modem_WaitResponse@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SMS_SetFunction>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
movups 0xea9(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0xd302c,0xf(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1040 <Modem_SendCmd@plt>
lea    0xe9a(%rip),%r15
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x5,%edx
call   1050 <Modem_WaitResponse@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
movabs $0x3d46474d432b5441,%rax
47 46 3d
mov    %rax,(%rsp)
movl   $0xd313d,0x7(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1040 <Modem_SendCmd@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x5,%edx
call   1050 <Modem_WaitResponse@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1030 <memset@plt>
movabs $0xd224d53222c22,%rax
mov    %rax,0x10(%rsp)
movups 0xe31(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x5,%edx
call   1040 <Modem_SendCmd@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x5,%edx
call   1050 <Modem_WaitResponse@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"AT+CNMI=2,1,0,0,0\0D\00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [11 x i8] c"AT+CMGF=1\0D\00"
@.str.3 = [24 x i8] c"AT+CPMS=\22SM\22,\22SM\22,\22SM\22\0D\00"
define void @SMS_SetFunction(i32 %0) {
%2 = alloca i32
%3 = alloca [256 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 256)
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%10 = call i32 @Modem_SendCmd(i32 %8, i8* %9, i32 5)
%11 = load i32, i32* %2
%12 = call i32 @Modem_WaitResponse(i32 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 5)
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i32 0, i32 256)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%16 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* %2
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%19 = call i32 @Modem_SendCmd(i32 %17, i8* %18, i32 5)
%20 = load i32, i32* %2
%21 = call i32 @Modem_WaitResponse(i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 5)
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%23 = call i32 @memset(i8* %22, i32 0, i32 256)
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%25 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* %2
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%28 = call i32 @Modem_SendCmd(i32 %26, i8* %27, i32 5)
%29 = load i32, i32* %2
%30 = call i32 @Modem_WaitResponse(i32 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 5)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"AT+CNMI=2,1,0,0,0\0D\00"
@.str.1 = [3 x i8] c"OK\00"
@.str.2 = [11 x i8] c"AT+CMGF=1\0D\00"
@.str.3 = [24 x i8] c"AT+CPMS=\22SM\22,\22SM\22,\22SM\22\0D\00"
define void @SMS_SetFunction(i32 %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 256)
%5 = call i32 @Modem_SendCmd(i32 %0, i8* %3, i32 5)
%6 = call i32 @Modem_WaitResponse(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 5)
%7 = call i32 @memset(i8* %3, i32 0, i32 256)
%8 = call i32 @Modem_SendCmd(i32 %0, i8* %3, i32 5)
%9 = call i32 @Modem_WaitResponse(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 5)
%10 = call i32 @memset(i8* %3, i32 0, i32 256)
%11 = call i32 @Modem_SendCmd(i32 %0, i8* %3, i32 5)
%12 = call i32 @Modem_WaitResponse(i32 %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 5)
ret void
}